Documentation ¶
Index ¶
- Variables
- func HTTPHandler() http.Handler
- func InitializePrometheusMetrics()
- func LazyLoad[T any](f func() T) func() T
- func LazyLoadCounter(name string) func() CountMeter
- func LazyLoadCounterVec(name string, labels []string) func() CountVecMeter
- func LazyLoadGauge(name string) func() GaugeMeter
- func LazyLoadGaugeVec(name string, labels []string) func() GaugeVecMeter
- func LazyLoadHistogram(name string, buckets []int64) func() HistogramMeter
- func LazyLoadHistogramVec(name string, labels []string, buckets []int64) func() HistogramVecMeter
- type CountMeter
- type CountVecMeter
- type GaugeMeter
- type GaugeVecMeter
- type HistogramMeter
- type HistogramVecMeter
- type Metrics
Constants ¶
This section is empty.
Variables ¶
var ( Bucket10s = []int64{0, 500, 1000, 2000, 3000, 4000, 5000, 7500, 10_000} BucketHTTPReqs = []int64{0, 150, 300, 450, 600, 900, 1200, 1500, 3000} )
Define standard buckets for histograms
Functions ¶
func HTTPHandler ¶
HTTPHandler returns the http handler for retrieving metrics
func InitializePrometheusMetrics ¶
func InitializePrometheusMetrics()
InitializePrometheusMetrics creates a new instance of the Prometheus service and sets the implementation as the default metrics services
func LazyLoad ¶
func LazyLoad[T any](f func() T) func() T
LazyLoad allows to defer the instantiation of the metric while allowing its definition. More clearly: - it allow metrics to be defined and used package wide (using var) - it avoid metrics definition to determine the singleton to use (noop vs prometheus)
func LazyLoadCounter ¶
func LazyLoadCounter(name string) func() CountMeter
func LazyLoadCounterVec ¶
func LazyLoadCounterVec(name string, labels []string) func() CountVecMeter
func LazyLoadGauge ¶
func LazyLoadGauge(name string) func() GaugeMeter
func LazyLoadGaugeVec ¶
func LazyLoadGaugeVec(name string, labels []string) func() GaugeVecMeter
func LazyLoadHistogram ¶
func LazyLoadHistogram(name string, buckets []int64) func() HistogramMeter
func LazyLoadHistogramVec ¶
func LazyLoadHistogramVec(name string, labels []string, buckets []int64) func() HistogramVecMeter
Types ¶
type CountMeter ¶
type CountMeter interface {
Add(int64)
}
CountMeter is a cumulative metric that represents a single monotonically increasing counter whose value can only increase or be reset to zero on restart.
func Counter ¶
func Counter(name string) CountMeter
type CountVecMeter ¶
CountVecMeter is a cumulative metric that represents a single monotonically increasing counter whose value can only increase or be reset to zero on restart with a vector of values.
func CounterVec ¶
func CounterVec(name string, labels []string) CountVecMeter
type GaugeMeter ¶
GaugeMeter is a metric that represents a single numeric value, which can arbitrarily go up and down.
func Gauge ¶
func Gauge(name string) GaugeMeter
type GaugeVecMeter ¶
type GaugeVecMeter interface { AddWithLabel(int64, map[string]string) SetWithLabel(int64, map[string]string) }
GaugeVecMeter is a metric that represents a single numeric value, which can arbitrarily go up and down with multiple labels.
func GaugeVec ¶
func GaugeVec(name string, labels []string) GaugeVecMeter
type HistogramMeter ¶
type HistogramMeter interface {
Observe(int64)
}
HistogramMeter represents the type of metric that is calculated by aggregating as a Histogram of all reported measurements over a time interval.
func Histogram ¶
func Histogram(name string, buckets []int64) HistogramMeter
type HistogramVecMeter ¶
HistogramVecMeter same as the Histogram but with labels
func HistogramVec ¶
func HistogramVec(name string, labels []string, buckets []int64) HistogramVecMeter
type Metrics ¶
type Metrics interface { GetOrCreateCountMeter(name string) CountMeter GetOrCreateCountVecMeter(name string, labels []string) CountVecMeter GetOrCreateGaugeMeter(name string) GaugeMeter GetOrCreateGaugeVecMeter(name string, labels []string) GaugeVecMeter GetOrCreateHistogramMeter(name string, buckets []int64) HistogramMeter GetOrCreateHistogramVecMeter(name string, labels []string, buckets []int64) HistogramVecMeter GetOrCreateHandler() http.Handler }
Metrics defines the interface for metrics service implementations