pub struct PrometheusMetrics { /* private fields */ }Expand description
A ReconcileObserver that exports Prometheus metrics. Requires the
prometheus feature.
The metrics, each prefixed with the namespace given to
new, are:
<namespace>_reconciliations_total{controller, phase, outcome}: count of reconciliation passes. Anoutcomeoffailedis the signal to alert on.waitingis normal while a resource converges.<namespace>_reconciliation_duration_seconds{controller, phase}: histogram of time spent in each pass. Reconcilers that wait by requeueing, rather than by blocking, return promptly, so this measures work done rather than time to converge.<namespace>_reconciliation_steps_total{controller, step, outcome}: count of steps. Since a step that an error propagates out of is reported asabandoned, as is one in a pass that was cancelled,abandonedlocates where passes stop, but is not itself a failure signal.<namespace>_reconciliation_step_duration_seconds{controller, step}: histogram of time spent in each step.
Label values are the controller name,
Phase::as_str,
Outcome::as_str, and the step name.
This is a Collector, so it must be registered with a registry to be
exported, and then shared by every controller that reports to it:
let metrics = k8s_controller::PrometheusMetrics::new("my_operator")?;
let registry = prometheus::Registry::new();
registry.register(Box::new(metrics.clone()))?;
let observer: Arc<dyn k8s_controller::ReconcileObserver> = Arc::new(metrics);
// pass `Arc::clone(&observer)` to each `Controller::with_observer`Implementations§
Source§impl PrometheusMetrics
impl PrometheusMetrics
Sourcepub const DEFAULT_BUCKETS: &[f64]
pub const DEFAULT_BUCKETS: &[f64]
The default histogram buckets, in seconds.
Trait Implementations§
Source§impl Clone for PrometheusMetrics
impl Clone for PrometheusMetrics
Source§fn clone(&self) -> PrometheusMetrics
fn clone(&self) -> PrometheusMetrics
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Collector for PrometheusMetrics
impl Collector for PrometheusMetrics
Source§impl Debug for PrometheusMetrics
impl Debug for PrometheusMetrics
Source§impl ReconcileObserver for PrometheusMetrics
impl ReconcileObserver for PrometheusMetrics
Source§fn reconciled(&self, record: &ReconcileRecord<'_>)
fn reconciled(&self, record: &ReconcileRecord<'_>)
Called when a reconciliation pass ends, including when it is
cancelled.
Source§fn step_finished(&self, record: &StepRecord<'_>)
fn step_finished(&self, record: &StepRecord<'_>)
Called when a
Step is finished or dropped.Auto Trait Implementations§
impl !RefUnwindSafe for PrometheusMetrics
impl !UnwindSafe for PrometheusMetrics
impl Freeze for PrometheusMetrics
impl Send for PrometheusMetrics
impl Sync for PrometheusMetrics
impl Unpin for PrometheusMetrics
impl UnsafeUnpin for PrometheusMetrics
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<T> ServiceExt for T
impl<T> ServiceExt for T
Source§fn map_response_body<F>(self, f: F) -> MapResponseBody<Self, F>where
Self: Sized,
fn map_response_body<F>(self, f: F) -> MapResponseBody<Self, F>where
Self: Sized,
Apply a transformation to the response body. Read more
Source§fn trace_for_http(self) -> Trace<Self, SharedClassifier<ServerErrorsAsFailures>>where
Self: Sized,
fn trace_for_http(self) -> Trace<Self, SharedClassifier<ServerErrorsAsFailures>>where
Self: Sized,
High level tracing that classifies responses using HTTP status codes. Read more
Source§fn trace_for_grpc(self) -> Trace<Self, SharedClassifier<GrpcErrorsAsFailures>>where
Self: Sized,
fn trace_for_grpc(self) -> Trace<Self, SharedClassifier<GrpcErrorsAsFailures>>where
Self: Sized,
High level tracing that classifies responses using gRPC headers. Read more