Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type FireflyDefaultLabels ¶
type FireflyDefaultLabels struct {
Namespace string
}
type MetricsManager ¶
type MetricsManager interface {
// functions for defining metrics
NewCounterMetric(ctx context.Context, metricName string, helpText string, withDefaultLabels bool)
NewCounterMetricWithLabels(ctx context.Context, metricName string, helpText string, labelNames []string, withDefaultLabels bool)
NewGaugeMetric(ctx context.Context, metricName string, helpText string, withDefaultLabels bool)
NewGaugeMetricWithLabels(ctx context.Context, metricName string, helpText string, labelNames []string, withDefaultLabels bool)
NewHistogramMetric(ctx context.Context, metricName string, helpText string, buckets []float64, withDefaultLabels bool)
NewHistogramMetricWithLabels(ctx context.Context, metricName string, helpText string, buckets []float64, labelNames []string, withDefaultLabels bool)
NewSummaryMetric(ctx context.Context, metricName string, helpText string, withDefaultLabels bool)
NewSummaryMetricWithLabels(ctx context.Context, metricName string, helpText string, labelNames []string, withDefaultLabels bool)
// functions for emitting metrics
SetGaugeMetric(ctx context.Context, metricName string, number float64, defaultLabels *FireflyDefaultLabels)
SetGaugeMetricWithLabels(ctx context.Context, metricName string, number float64, labels map[string]string, defaultLabels *FireflyDefaultLabels)
IncGaugeMetric(ctx context.Context, metricName string, defaultLabels *FireflyDefaultLabels)
IncGaugeMetricWithLabels(ctx context.Context, metricName string, labels map[string]string, defaultLabels *FireflyDefaultLabels)
DecGaugeMetric(ctx context.Context, metricName string, defaultLabels *FireflyDefaultLabels)
DecGaugeMetricWithLabels(ctx context.Context, metricName string, labels map[string]string, defaultLabels *FireflyDefaultLabels)
IncCounterMetric(ctx context.Context, metricName string, defaultLabels *FireflyDefaultLabels)
IncCounterMetricWithLabels(ctx context.Context, metricName string, labels map[string]string, defaultLabels *FireflyDefaultLabels)
ObserveHistogramMetric(ctx context.Context, metricName string, number float64, defaultLabels *FireflyDefaultLabels)
ObserveHistogramMetricWithLabels(ctx context.Context, metricName string, number float64, labels map[string]string, defaultLabels *FireflyDefaultLabels)
ObserveSummaryMetric(ctx context.Context, metricName string, number float64, defaultLabels *FireflyDefaultLabels)
ObserveSummaryMetricWithLabels(ctx context.Context, metricName string, number float64, labels map[string]string, defaultLabels *FireflyDefaultLabels)
}
MetricsManager is used to defined and emit metrics in a subsystem All functions in this interface should swallow errors as metrics are auxiliary
type MetricsRegistry ¶
type MetricsRegistry interface {
// NewMetricsManagerForSubsystem returns a MetricsManager which can be used to add custom metrics
NewMetricsManagerForSubsystem(ctx context.Context, subsystem string) (MetricsManager, error)
// HTTPHandler returns the HTTP handler of this metrics registry
HTTPHandler(ctx context.Context, handlerOpts promhttp.HandlerOpts) (http.Handler, error)
// Predefined HTTP Metrics Instrumentations
// NewHTTPMetricsInstrumentationsForSubsystem adds predefined HTTP metrics to a subsystem
NewHTTPMetricsInstrumentationsForSubsystem(ctx context.Context, subsystem string, useRouteTemplate bool, reqDurationBuckets []float64, labels map[string]string) error
// GetHTTPMetricsInstrumentationsMiddlewareForSubsystem returns the HTTP middleware of a subsystem that used predefined HTTP metrics
GetHTTPMetricsInstrumentationsMiddlewareForSubsystem(ctx context.Context, subsystem string) (func(next http.Handler) http.Handler, error)
MustRegisterCollector(collector prometheus.Collector)
}
MetricsRegistry contains all metrics defined in a micro-service.
- All metrics will have the default "ff" prefix
- A component name can be provided to add a "ff_component" label to separate metrics with same names from other components
- Metrics are defined in subsystems, a subsystem can only use one of the two options for creating metrics: 1. create a metrics manager to defined custom metrics manually 2. use out-of-box predefined metrics for a common resource type (e.g. HTTP request)
func NewPrometheusMetricsRegistry ¶
func NewPrometheusMetricsRegistry(componentName string) MetricsRegistry
func NewPrometheusMetricsRegistryWithOptions ¶ added in v1.4.14
func NewPrometheusMetricsRegistryWithOptions(componentName string, opts Options) MetricsRegistry
Click to show internal directories.
Click to hide internal directories.