Documentation
¶
Overview ¶
Package metrics provides a metrics-tracking implementation for the service.
What to use and when:
Use Counters for counting things that always go up. Use Gauges for things that can go up or down. Use Histograms or Summaries for distributions of values.
Index ¶
- type Float64Counter
- type Float64CounterImpl
- type Float64Gauge
- type Float64GaugeImpl
- type Float64Histogram
- type Float64HistogramImpl
- type Float64UpDownCounter
- type Float64UpDownCounterImpl
- type Int64Counter
- type Int64CounterImpl
- type Int64Gauge
- type Int64GaugeImpl
- type Int64Histogram
- type Int64HistogramImpl
- type Int64UpDownCounter
- type Int64UpDownCounterImpl
- type OperationSet
- type Provider
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Float64Counter ¶
type Float64CounterImpl ¶
type Float64CounterImpl struct {
X metric.Float64Counter
}
type Float64Gauge ¶
type Float64Gauge interface {
Record(ctx context.Context, value float64, options ...metric.RecordOption)
}
type Float64GaugeImpl ¶
type Float64GaugeImpl struct {
X metric.Float64Gauge
}
func (*Float64GaugeImpl) Record ¶
func (y *Float64GaugeImpl) Record(ctx context.Context, value float64, options ...metric.RecordOption)
Record wraps the metric float64Gauge interface.
type Float64Histogram ¶
type Float64Histogram interface {
Record(ctx context.Context, incr float64, options ...metric.RecordOption)
}
type Float64HistogramImpl ¶
type Float64HistogramImpl struct {
X metric.Float64Histogram
}
func (*Float64HistogramImpl) Record ¶
func (y *Float64HistogramImpl) Record(ctx context.Context, incr float64, options ...metric.RecordOption)
Record wraps the metric float64Histogram interface.
type Float64UpDownCounter ¶
type Float64UpDownCounterImpl ¶
type Float64UpDownCounterImpl struct {
X metric.Float64UpDownCounter
}
type Int64Counter ¶
type Int64CounterImpl ¶
type Int64CounterImpl struct {
X metric.Int64Counter
}
type Int64Gauge ¶
type Int64Gauge interface {
Record(ctx context.Context, value int64, options ...metric.RecordOption)
}
type Int64GaugeImpl ¶
type Int64GaugeImpl struct {
X metric.Int64Gauge
}
func (*Int64GaugeImpl) Record ¶
func (y *Int64GaugeImpl) Record(ctx context.Context, value int64, options ...metric.RecordOption)
Record wraps the metric int64Gauge interface.
type Int64Histogram ¶
type Int64Histogram interface {
Record(ctx context.Context, incr int64, options ...metric.RecordOption)
}
type Int64HistogramImpl ¶
type Int64HistogramImpl struct {
X metric.Int64Histogram
}
func (*Int64HistogramImpl) Record ¶
func (y *Int64HistogramImpl) Record(ctx context.Context, incr int64, options ...metric.RecordOption)
Record wraps the metric int64Histogram interface.
type Int64UpDownCounter ¶
type Int64UpDownCounterImpl ¶
type Int64UpDownCounterImpl struct {
X metric.Int64UpDownCounter
}
type OperationSet ¶
type OperationSet struct {
// Requests counts attempts — incremented before the work runs, not after.
// Counting successes here and calling it "requests" is what makes
// requests-minus-errors a number with no interpretation.
Requests Int64Counter
// Errors counts the attempts that failed.
Errors Int64Counter
// Latency records how long an attempt took, in milliseconds. Milliseconds
// because that is what every other histogram in this module reports, and a
// unit that varies per package is a unit nobody can chart together.
Latency Float64Histogram
}
OperationSet is the three instruments nearly every component in this module records: how often it was asked to do something, how often that failed, and how long it took.
The three belong together because none of them means anything alone. A climbing error count is a crisis or a rounding error depending on the request count beside it; a latency histogram with no request count cannot distinguish "fast" from "idle". Twenty-five constructors had built this trio by hand, and what varied between them was only which suffixes they chose — which is the one thing that should not vary.
The zero value is usable and records nothing, so a component that has no metrics provider does not need a nil check at each call site.
func NewOperationSet ¶
func NewOperationSet(mp Provider, name string) (*OperationSet, error)
NewOperationSet builds the trio under name, which is the component's instrument prefix: "cache", "llm_openai", "webhooks_dispatcher".
A nil provider resolves to the noop one, so a caller that was given no metrics provider gets a working set rather than an error.
func (*OperationSet) Attempt ¶
func (s *OperationSet) Attempt(ctx context.Context, opts ...metric.AddOption)
Attempt counts one attempt.
func (*OperationSet) Failed ¶
func (s *OperationSet) Failed(ctx context.Context, opts ...metric.AddOption)
Failed counts one failed attempt.
It does not also count an attempt. Errors is a subset of Requests, not a series beside it, which is what makes their ratio the error rate rather than a number that exceeds one.
type Provider ¶
type Provider interface {
NewFloat64Counter(name string, options ...metric.Float64CounterOption) (Float64Counter, error)
NewFloat64Gauge(name string, options ...metric.Float64GaugeOption) (Float64Gauge, error)
NewFloat64UpDownCounter(name string, options ...metric.Float64UpDownCounterOption) (Float64UpDownCounter, error)
NewFloat64Histogram(name string, options ...metric.Float64HistogramOption) (Float64Histogram, error)
NewInt64Counter(name string, options ...metric.Int64CounterOption) (Int64Counter, error)
NewInt64Gauge(name string, options ...metric.Int64GaugeOption) (Int64Gauge, error)
NewInt64UpDownCounter(name string, options ...metric.Int64UpDownCounterOption) (Int64UpDownCounter, error)
NewInt64Histogram(name string, options ...metric.Int64HistogramOption) (Int64Histogram, error)
Shutdown(ctx context.Context) error
MeterProvider() metric.MeterProvider
}
func EnsureMetricsProvider ¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package metricscfg selects and builds a metrics.Provider from configuration: the OTel gRPC exporter, or no metrics at all.
|
Package metricscfg selects and builds a metrics.Provider from configuration: the OTel gRPC exporter, or no metrics at all. |
|
Package metricstest provides metric instruments for tests.
|
Package metricstest provides metric instruments for tests. |
|
Package metricsmock provides moq-generated mocks for the metrics package.
|
Package metricsmock provides moq-generated mocks for the metrics package. |
|
Package noop is the metrics.Provider that exports nothing.
|
Package noop is the metrics.Provider that exports nothing. |
|
Package otelgrpc implements metrics.Provider against an OTLP collector reached over gRPC.
|
Package otelgrpc implements metrics.Provider against an OTLP collector reached over gRPC. |