Expand description
Provider health dashboard snapshot.
ProviderHealthSnapshot aggregates per-provider health metrics into a
single value that can be serialised to JSON for a /health/providers REST
endpoint or logged on demand.
§What It Aggregates
For each registered provider the snapshot captures:
| Field | Source |
|---|---|
last_success_at | Unix timestamp (seconds) of the most recent success |
last_failure_at | Unix timestamp (seconds) of the most recent failure |
consecutive_failures | Failures since the last success |
success_rate_1h | Fraction of calls that succeeded in the last hour |
p50_latency_ms | Median latency over all recorded calls |
p95_latency_ms | 95th-percentile latency over all recorded calls |
§Usage
use tokio_prompt_orchestrator::routing::health::{ProviderHealthBuilder, ProviderHealthSnapshot};
use tokio_prompt_orchestrator::config::WorkerKind;
let mut builder = ProviderHealthBuilder::new();
builder.record_success(WorkerKind::Anthropic, 120);
builder.record_failure(WorkerKind::OpenAi);
let snapshot = builder.snapshot();
let json = snapshot.to_json();
assert!(json.is_object());Structs§
- Provider
Health Builder - Mutable builder that accumulates per-provider health observations and can
produce a
ProviderHealthSnapshoton demand. - Provider
Health Snapshot - An immutable snapshot of health metrics for all tracked providers.
- Provider
Metrics - Health metrics for a single provider at a point in time.