metric

package
v1.4.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 29, 2024 License: Apache-2.0 Imports: 11 Imported by: 3

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)
	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)
}

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(fireflyComponentName string) MetricsRegistry

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL