veylant/internal/metrics/metrics.go
2026-02-23 13:35:04 +01:00

44 lines
1.5 KiB
Go

// Package metrics registers Prometheus metrics for the Veylant proxy.
package metrics
import (
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promauto"
)
// Prometheus metrics exposed by the Veylant proxy.
// Labels follow the naming conventions of the OpenTelemetry semantic conventions
// where applicable.
var (
// RequestsTotal counts all proxy requests by HTTP method, path, status code,
// and provider name.
RequestsTotal = promauto.NewCounterVec(
prometheus.CounterOpts{
Name: "veylant_requests_total",
Help: "Total number of proxy requests.",
},
[]string{"method", "path", "status", "provider"},
)
// RequestDuration measures the end-to-end latency of each proxy request in
// seconds, broken down by method, path, and status code.
RequestDuration = promauto.NewHistogramVec(
prometheus.HistogramOpts{
Name: "veylant_request_duration_seconds",
Help: "End-to-end proxy request duration in seconds.",
Buckets: []float64{.005, .01, .025, .05, .1, .25, .5, 1, 2.5, 5, 10},
},
[]string{"method", "path", "status"},
)
// RequestErrors counts requests that resulted in an error, labelled by the
// OpenAI error type (authentication_error, rate_limit_error, etc.).
RequestErrors = promauto.NewCounterVec(
prometheus.CounterOpts{
Name: "veylant_request_errors_total",
Help: "Total number of proxy request errors by error type.",
},
[]string{"method", "path", "error_type"},
)
)