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 bySupervisor::child): prefix applied to metrics registered withMetrics::register. It also populates thenamefield of runtime-internal task metrics (runtime_tasks_spawned,runtime_tasks_running).attributes(set bySupervisor::with_attribute): Prometheus label dimensions on metrics registered withMetrics::register. They are also emitted as OpenTelemetry attributes on the per-task tracing span whenTracing::with_spanis enabled. Runtime task metrics ignore attributes to keep their cardinality bounded.span(set byTracing::with_span): wraps the next spawned task in atracingspan populated from the currentlabelandattributes. It never touches metrics.
| Builder | Registered metric name | Registered metric labels | Runtime task metrics | Tracing span |
|---|---|---|---|---|
child | prefix | - | name | name 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".