pub struct PrometheusMetrics { /* private fields */ }Expand description
Prometheus metrics backend for solti runners.
Implements MetricsBackend and exposes runner-level metrics in Prometheus format.
Runners call the trait methods during task lifecycle.
§Metrics
| Metric | Type | Labels | Description |
|---|---|---|---|
solti_runner_tasks_started_total | Counter | runner | Task spawn events |
solti_runner_tasks_completed_total | Counter | runner, outcome | Task completion events |
solti_runner_task_duration_seconds | Histogram | runner, outcome | Per-attempt execution duration |
solti_runner_errors_total | Counter | runner, error | Runner setup/teardown errors |
§Labels
All label sets have low, bounded cardinality:
| Label | Values | Cardinality |
|---|---|---|
runner | subprocess, wasm, container | Low |
outcome | success, failure, canceled, timeout | Low |
error | cgroup_prepare_failed, backend_config_failed, spawn_failed, module_load_failed (from RunnerErrorKind) | Low |
§Duration histogram buckets
Buckets (seconds): 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1, 2.5, 5, 10, 30, 60, 300, 1800, 3600.
§Also
PrometheusSubscriberis a supervision-level metrics from the event stream.Registryis a shared registry for unified/metricsendpoint.
Implementations§
Source§impl PrometheusMetrics
impl PrometheusMetrics
Sourcepub fn new(registry: Arc<Registry>) -> Result<Self, Error>
pub fn new(registry: Arc<Registry>) -> Result<Self, Error>
Create a new metrics backend, registering all counters and histograms into the given Registry.
Primary constructor — mirrors the shape used by other backends in this
crate (PrometheusSubscriber::new,
PrometheusApiMetrics::new, PrometheusDiscoverMetrics::new).
Sourcepub fn new_isolated() -> Result<Self, Error>
pub fn new_isolated() -> Result<Self, Error>
Create a new metrics backend with an isolated registry.
Convenience for tests / standalone use. Most agents share a single
registry across collectors via Self::new.
Sourcepub fn new_with_registry(registry: Arc<Registry>) -> Result<Self, Error>
👎Deprecated since 0.0.2: use PrometheusMetrics::new(registry) — same signature, consistent with the other backends
pub fn new_with_registry(registry: Arc<Registry>) -> Result<Self, Error>
use PrometheusMetrics::new(registry) — same signature, consistent with the other backends
Deprecated alias of Self::new.
Sourcepub fn gather(&self) -> Vec<MetricFamily>
pub fn gather(&self) -> Vec<MetricFamily>
Gather all metrics for exposition.
Trait Implementations§
Source§impl Debug for PrometheusMetrics
impl Debug for PrometheusMetrics
Source§impl MetricsBackend for PrometheusMetrics
impl MetricsBackend for PrometheusMetrics
Source§fn record_task_started(&self, runner_type: RunnerType)
fn record_task_started(&self, runner_type: RunnerType)
Increments solti_runner_tasks_started_total{runner=<runner_type>}.
Source§fn record_task_completed(
&self,
runner_type: RunnerType,
outcome: TaskOutcome,
duration_ms: u64,
)
fn record_task_completed( &self, runner_type: RunnerType, outcome: TaskOutcome, duration_ms: u64, )
Records a task completion event.
Updates two metrics:
solti_runner_tasks_completed_total{runner, outcome}- incremented by 1.solti_runner_task_duration_seconds{runner, outcome}- observes the duration converted from milliseconds to seconds.
The outcome label is derived from TaskOutcome::as_label: success | failure | canceled | timeout.
Source§fn record_runner_error(
&self,
runner_type: RunnerType,
error_kind: RunnerErrorKind,
)
fn record_runner_error( &self, runner_type: RunnerType, error_kind: RunnerErrorKind, )
Increments solti_runner_errors_total{runner=<runner_type>, error=<error_kind>}.
Called for runner setup/teardown errors (e.g. spawn failures), not for task-level failures
which go through record_task_completed.