Skip to main content

Observer

Trait Observer 

Source
pub trait Observer: Tracing + Metrics { }
Expand description

Interface for both Tracing and Metrics.

A context carries multiple pieces of observability state. They compose freely, but they do not all feed into the same sinks:

  • label (set by Supervisor::child): prefix applied to metrics registered with Metrics::register. It also populates the name field of runtime-internal task metrics (runtime_tasks_spawned, runtime_tasks_running).
  • attributes (set by Supervisor::with_attribute): Prometheus label dimensions on metrics registered with Metrics::register. They are also emitted as OpenTelemetry attributes on the per-task tracing span when Tracing::with_span is enabled. Runtime task metrics ignore attributes to keep their cardinality bounded.
  • span (set by Tracing::with_span): wraps the next spawned task in a tracing span populated from the current label and attributes. It never touches metrics.
BuilderRegistered metric nameRegistered metric labelsRuntime task metricsTracing span
childprefix-namename field when with_span is set
with_attribute-label dimension-OTel attribute when with_span is set
with_span---enables span creation

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§