Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Counter ¶ added in v0.4.0
type Counter interface {
Inc()
Add(float64)
}
Counter is an interface that allows for incrementing and adding a float64 value.
type MetricCollector ¶ added in v0.4.0
type MetricCollector interface {
// RegisterHistogram registers a histogram metric with the given name and labels.
RegisterHistogram(ctx context.Context, name string, labels ...string) (Observable, error)
// RegisterGauge registers a gauge metric with the given name and labels.
RegisterGauge(ctx context.Context, name string, labels ...string) (Counter, error)
// RegisterCounter registers a counter metric with the given name and labels.
RegisterCounter(ctx context.Context, name string, labels ...string) (Counter, error)
// ObserveHistogram observes a value for the histogram metric with the given name and labels.
ObserveHistogram(ctx context.Context, name string, value float64, labels ...string) error
// SetGauge sets a value for the gauge metric with the given name and labels.
SetGauge(ctx context.Context, name string, value float64, labels ...string) error
// AddCounter adds a value to the counter metric with the given name and labels.
AddCounter(ctx context.Context, name string, value float64, labels ...string) error
// MetricsHandler returns an http.Handler for serving the metrics.
MetricsHandler() http.Handler
// MeasureFunctionExecutionTime measures the execution time of a function with the given name.
MeasureFunctionExecutionTime(ctx context.Context, name string) (func(), error)
// UnregisterCounter unregisters the counter metric with the given name and labels.
UnregisterCounter(ctx context.Context, name string, labels ...string) error
// UnregisterHistogram unregisters the histogram metric with the given name and labels.
UnregisterHistogram(ctx context.Context, name string, labels ...string) error
// UnregisterGauge unregisters the gauge metric with the given name and labels.
UnregisterGauge(ctx context.Context, name string, labels ...string) error
// MeasureGraphQLResponseDuration returns a http.Handler that measures the response duration of the given handler.
MeasureGraphQLResponseDuration(next http.Handler) http.Handler
}
MetricCollector is an interface that provides methods for registering and manipulating metrics.
func FromContext ¶ added in v0.4.0
func FromContext(ctx context.Context, name string) MetricCollector
FromContext returns the MetricCollector from the context.
func NewPrometheus ¶
func NewPrometheus(name string) MetricCollector
NewPrometheus creates a new prometheusCollector with empty sync.Maps for histograms, gauges, and counters.
type Observable ¶ added in v0.4.0
type Observable interface {
Observe(float64)
}
Observable is an interface that allows for observing a float64 value.
Click to show internal directories.
Click to hide internal directories.