metric

package
v1.6.7 Latest Latest
Warning

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

Go to latest
Published: Oct 6, 2026 License: Apache-2.0 Imports: 11 Imported by: 3 modules, 7 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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 allows for registering a customer collector within the metrics registry, outside of the manager/subsystem context
	MustRegisterCollector(collector prometheus.Collector)
	// GetGatherer returns the gatherer of the metrics registry, allowing for programmatic metrics exporting
	GetGatherer() prometheus.Gatherer
}

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

func NewPrometheusMetricsRegistryWithOptions(componentName string, opts Options) MetricsRegistry

type Options

type Options struct {
	MetricsPrefix string
}

Jump to

Keyboard shortcuts

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