pub struct ComponentMetrics { /* private fields */ }Expand description
Facade over a MetricsCollector for uniform component-operation
emission. Construct via RuntimeObservability::component_metrics(component)
or directly in tests.
Cheap to clone: the collector sits behind an Arc, so one facade can
be shared across objects built from the same connection (e.g. a
repository and its payload store).
Implementations§
Source§impl ComponentMetrics
impl ComponentMetrics
Sourcepub fn new(
collector: Arc<dyn MetricsCollector>,
component: impl Into<Arc<str>>,
enabled: bool,
) -> Self
pub fn new( collector: Arc<dyn MetricsCollector>, component: impl Into<Arc<str>>, enabled: bool, ) -> Self
Builds a facade over collector with the component identity fixed
to component; enabled is the effective per-component switch
(ComponentMetricsLevers::enabled_for) snapshot taken at
construction time.
Sourcepub fn observe(&self, operation: &str, failed: bool)
pub fn observe(&self, operation: &str, failed: bool)
Observes one component operation for the fixed identity. failed
selects the closed-set outcome label (“failure”/“success”) and,
when true, unconditionally forwards to the error family with the
e:{component}:{operation} label — error-family emission is never
lever-gated.