Skip to main content

PrometheusSubscriber

Struct PrometheusSubscriber 

Source
pub struct PrometheusSubscriber { /* private fields */ }
Expand description

Prometheus subscriber for supervision-level metrics.

Implements Subscribe and captures metrics from the taskvisor event stream. Must share a Registry with crate::PrometheusMetrics for a unified /metrics endpoint.

§Event → metric mapping

TaskStarting        → tasks_in_flight.inc()
                      + task_restarts.inc()  (if attempt > 1)
TaskStopped         → tasks_in_flight.dec()
TaskFailed          → tasks_in_flight.dec()
TimeoutHit          → task_timeouts.inc()
BackoffScheduled    → task_backoff_count{source}.inc()
                      + task_backoff_duration.observe(delay)
ActorExhausted      → task_terminal{reason="exhausted"}.inc()
                      + attempts_to_finalize{outcome="exhausted"}.observe(attempt)
ActorDead           → task_terminal{reason="fatal"}.inc()
                      + attempts_to_finalize{outcome="fatal"}.observe(attempt)
SubscriberOverflow  → subscriber_overflow.inc() + tracing::warn
SubscriberPanicked  → subscriber_panicked.inc() + tracing::warn
ControllerSubmitted → controller_submissions.inc()
ControllerRejected  → controller_rejections{reason}.inc()  (reason classified from Event.reason)

§Supervision metrics (solti_sv_*)

MetricTypeLabelsDescription
solti_sv_tasks_in_flightGauge-Currently executing tasks
solti_sv_task_restarts_totalCounter-Restarts (attempt > 1)
solti_sv_task_backoff_count_totalCountersourceBackoff events
solti_sv_task_backoff_duration_secondsHistogram-Backoff delay duration
solti_sv_task_terminal_totalCounterreasonTerminal task states
solti_sv_attempts_to_finalizeHistogramoutcomeAttempts when task left loop
solti_sv_task_timeouts_totalCounter-Timeout events
solti_sv_subscriber_overflow_totalCounter-Queue overflow (lost events)
solti_sv_subscriber_panicked_totalCounter-Subscriber panics

§Controller metrics (solti_ctrl_*)

MetricTypeLabelsDescription
solti_ctrl_submissions_totalCounter-Controller submissions
solti_ctrl_rejections_totalCounterVecreasonController rejections grouped by cause

§Labels

LabelValuesSource
sourcefailure, successBackoffSource on the event
reason (terminal)exhausted, fatalTerminal event kind
outcome (attempts)exhausted, fatalAttempts-to-finalize histogram
reason (rejection)slot_full, slot_busy, add_failed, remove_failed, queue_failed, recovery_failed, bus_lagged, controller_exited, other, unknownClassified from Event.reason by classify_rejection_reason (private)

§Notes

§Also

Implementations§

Source§

impl PrometheusSubscriber

Source

pub fn new(registry: Arc<Registry>) -> Result<Self, Error>

Create a new subscriber with the default event-bus queue capacity (DEFAULT_QUEUE_CAPACITY).

Source

pub fn with_queue_capacity( registry: Arc<Registry>, queue_capacity: usize, ) -> Result<Self, Error>

Create a new subscriber with a specific event-bus queue capacity.

Trait Implementations§

Source§

impl Debug for PrometheusSubscriber

Source§

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

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

impl Subscribe for PrometheusSubscriber

Source§

fn on_event(&self, event: &Event)

Translates a taskvisor event into prometheus metric updates.

Source§

fn name(&self) -> &'static str

Returns "prometheus"

Source§

fn queue_capacity(&self) -> usize

Returns the per-subscriber queue capacity configured via PrometheusSubscriber::new or PrometheusSubscriber::with_queue_capacity.

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,