metrics

package
v2.38.1 Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2026 License: AGPL-3.0 Imports: 2 Imported by: 1 module, 0 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

View Source
const (
	PrometheusMetricPrefix = "coder_ai_gateway_"

	InterceptionCountStatusFailed    = "failed"
	InterceptionCountStatusCompleted = "completed"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Metrics

type Metrics struct {
	// Interception-related metrics.
	InterceptionDuration  *prometheus.HistogramVec
	InterceptionCount     *prometheus.CounterVec
	InterceptionsInflight *prometheus.GaugeVec
	PassthroughCount      *prometheus.CounterVec

	// Prompt-related metrics.
	PromptCount *prometheus.CounterVec

	// Token-related metrics.
	TokenUseCount *prometheus.CounterVec

	// Tool-related metrics.
	InjectedToolUseCount    *prometheus.CounterVec
	NonInjectedToolUseCount *prometheus.CounterVec

	// Circuit breaker metrics.
	CircuitBreakerState   *prometheus.GaugeVec   // Current state (0=closed, 0.5=half-open, 1=open)
	CircuitBreakerTrips   *prometheus.CounterVec // Total times circuit opened
	CircuitBreakerRejects *prometheus.CounterVec // Requests rejected due to open circuit

	// Key pool failover metrics.
	KeyPoolStateTransitions *prometheus.CounterVec // Key state transitions during failover.
	KeyPoolExhaustions      *prometheus.CounterVec // Times the pool ran out of usable keys.
	// Keys attempted before success or exhaustion, per interception for
	// bridged requests and per request for passthrough requests.
	KeyPoolFailoverAttempts *prometheus.HistogramVec
}

func NewMetrics

func NewMetrics(reg prometheus.Registerer) *Metrics

NewMetrics creates AND registers metrics. It will panic if a collector has already been registered. Note: we are not specifying namespace in the metrics; the provided registerer may specify a "namespace" using prometheus.WrapRegistererWithPrefix.

Jump to

Keyboard shortcuts

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