mirror of
https://github.com/lukaszraczylo/traefik-llmgateway.git
synced 2026-11-26 10:06:31 +00:00
docs(metrics): say the provider health gauge is shared with sharedState
The HELP text claimed the discovery breaker is never shared via Redis. With redis.sharedState on it is shared, so every replica reports the same value and max() applies. The golden scrape changes by this line.
This commit is contained in:
+4
-6
@@ -442,12 +442,10 @@ const aggregationNoteStoreBacked = " AGGREGATION ACROSS REPLICAS: with Redis con
|
||||
const aggregationNotePerProcess = " AGGREGATION ACROSS REPLICAS: this counter lives only in this process's memory, never in Redis, regardless of Config.Redis — aggregate with sum(), which is always correct for it, unlike the store-backed families above."
|
||||
|
||||
// aggregationNoteProviderHealthy is appended to llmgateway_provider_
|
||||
// healthy's HELP text: the discovery circuit breaker (registry.go's
|
||||
// providerState.health) is per-process state, set by each replica's own
|
||||
// discovery polling loop, and is never written to Redis — two replicas
|
||||
// can legitimately disagree about one provider's health at the same
|
||||
// instant (e.g. one mid-backoff, one already recovered).
|
||||
const aggregationNoteProviderHealthy = " AGGREGATION ACROSS REPLICAS: each replica runs its own discovery circuit breaker in-process, never shared via Redis, so this can legitimately differ per replica. Read it per-instance where possible; if you must aggregate, use min() to surface \"at least one replica sees this provider as unhealthy\" — sum() is meaningless for a 0/1 gauge."
|
||||
// healthy's HELP text: with redis.sharedState on, the discovery circuit
|
||||
// breaker (registry.go's providerState.health) is shared through Redis;
|
||||
// without it, each replica's own discovery loop sets it in-process.
|
||||
const aggregationNoteProviderHealthy = " AGGREGATION ACROSS REPLICAS: with redis.sharedState on, the discovery circuit breaker is shared via Redis, so every replica reports the same value and max() is correct. Without it, each replica runs its own breaker, so the value can differ per replica; use min() to surface \"at least one replica sees this provider as unhealthy\". sum() is meaningless for a 0/1 gauge."
|
||||
|
||||
// aggregationNoteTargetHealthy is appended to llmgateway_target_healthy's
|
||||
// HELP text (feat/target-health): the tracker behind this gauge
|
||||
|
||||
@@ -441,3 +441,14 @@ func TestFleetLatencyEntriesOnlyWithStore(t *testing.T) {
|
||||
t.Errorf("fleet latency sum in the store = %d, want 300", got)
|
||||
}
|
||||
}
|
||||
|
||||
func TestProviderHealthyHelpNamesSharedState(t *testing.T) {
|
||||
for _, want := range []string{"redis.sharedState", "max()", "per replica", "min()"} {
|
||||
if !strings.Contains(aggregationNoteProviderHealthy, want) {
|
||||
t.Errorf("provider_healthy HELP note lacks %q: %s", want, aggregationNoteProviderHealthy)
|
||||
}
|
||||
}
|
||||
if strings.Contains(aggregationNoteProviderHealthy, "never shared via Redis") {
|
||||
t.Error("provider_healthy HELP note still says the breaker is never shared via Redis")
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -28,7 +28,7 @@ llmgateway_provider_attempts_total{provider="gamma"} 0
|
||||
llmgateway_provider_failures_total{provider="alpha"} 0
|
||||
llmgateway_provider_failures_total{provider="beta"} 0
|
||||
llmgateway_provider_failures_total{provider="gamma"} 0
|
||||
# HELP llmgateway_provider_healthy 1 when the provider's discovery circuit breaker is not open (closed or half-open), 0 when open (discoveryHealthy, registry.go). AGGREGATION ACROSS REPLICAS: each replica runs its own discovery circuit breaker in-process, never shared via Redis, so this can legitimately differ per replica. Read it per-instance where possible; if you must aggregate, use min() to surface "at least one replica sees this provider as unhealthy" — sum() is meaningless for a 0/1 gauge.
|
||||
# HELP llmgateway_provider_healthy 1 when the provider's discovery circuit breaker is not open (closed or half-open), 0 when open (discoveryHealthy, registry.go). AGGREGATION ACROSS REPLICAS: with redis.sharedState on, the discovery circuit breaker is shared via Redis, so every replica reports the same value and max() is correct. Without it, each replica runs its own breaker, so the value can differ per replica; use min() to surface "at least one replica sees this provider as unhealthy". sum() is meaningless for a 0/1 gauge.
|
||||
# TYPE llmgateway_provider_healthy gauge
|
||||
llmgateway_provider_healthy{provider="alpha"} 1
|
||||
llmgateway_provider_healthy{provider="beta"} 1
|
||||
|
||||
Reference in New Issue
Block a user