Component evidence

SetCircuitBreakerStateSource (metrics/circuitbreaker.go)

ferro-labs/ai-gateway · pkg/metrics/circuitbreaker.go · go · Apache-2.0
analytics

A Prometheus collector that exports the current state of circuit breakers to enable real-time monitoring of service stability.

Source preview first 800 characters · full source over MCP
// Source: https://github.com/ferro-labs/ai-gateway | License: Apache-2.0 | Copyright You must retain, in the Source form of any Derivative Works
// Provided via justclaw.it.com; keep this notice with the code.
package metrics

import (
	"sync/atomic"

	"github.com/prometheus/client_golang/prometheus"
)

// Circuit-breaker states as encoded by gateway_circuit_breaker_state.
const (
	CircuitClosed   = 0
	CircuitOpen     = 1
	CircuitHalfOpen = 2
)

// CircuitBreakerStateSource reports the current state of every circuit breaker
// the process has configured, keyed by provider name and valued with one of the
// Circuit* constants above.
//
// It must be safe for concurrent use and must not block: it is called on every
// Prometheus scrape.
type CircuitBreakerStateSource func() map[string]float

... (truncated -- full source via MCP)