Skip to main content

PrometheusMetrics

Struct PrometheusMetrics 

Source
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

MetricTypeLabelsDescription
solti_runner_tasks_started_totalCounterrunnerTask spawn events
solti_runner_tasks_completed_totalCounterrunner, outcomeTask completion events
solti_runner_task_duration_secondsHistogramrunner, outcomePer-attempt execution duration
solti_runner_errors_totalCounterrunner, errorRunner setup/teardown errors

§Labels

All label sets have low, bounded cardinality:

LabelValuesCardinality
runnersubprocess, wasm, containerLow
outcomesuccess, failure, canceled, timeoutLow
errorcgroup_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

Implementations§

Source§

impl PrometheusMetrics

Source

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).

Source

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.

Source

pub 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

Deprecated alias of Self::new.

Source

pub fn gather(&self) -> Vec<MetricFamily>

Gather all metrics for exposition.

Source

pub fn registry(&self) -> &Arc<Registry>

Get reference to underlying prometheus registry.

Trait Implementations§

Source§

impl Debug for PrometheusMetrics

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl MetricsBackend for PrometheusMetrics

Source§

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, )

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, )

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.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<A, B, T> HttpServerConnExec<A, B> for T
where B: Body,