pub trait Observer:
Send
+ Sync
+ 'static {
// Required method
fn emit_envelope(&self, env: ObsEnvelope);
// Provided methods
fn enabled(&self, callsite: &ObsCallsite) -> bool { ... }
fn generation(&self) -> u32 { ... }
fn reload_filter(&self) { ... }
fn flush(&self) -> SinkFut<'_> { ... }
fn shutdown(&self) -> SinkFut<'_> { ... }
fn shutdown_blocking(&self, timeout: Duration) { ... }
fn callsites(&self) -> Option<Arc<ObsCallsiteRegistry>> { ... }
fn schema_registry(&self) -> Option<Arc<SchemaRegistry>> { ... }
fn resource_attrs(&self) -> Arc<ResourceAttrs> ⓘ { ... }
}Expand description
The global observer trait. Sealed in spirit (downstream crates
implement it freely, but the SDK ships NoopObserver,
InMemoryObserver, StandardObserver covering 99% of cases).
&self everywhere so the same observer reference is reused across
every emit; no locks taken on the hot path.
Required Methods§
Sourcefn emit_envelope(&self, env: ObsEnvelope)
fn emit_envelope(&self, env: ObsEnvelope)
Hot-path emit. Never blocks. Never panics. Spec 11 § 3.
Provided Methods§
Sourcefn enabled(&self, callsite: &ObsCallsite) -> bool
fn enabled(&self, callsite: &ObsCallsite) -> bool
Cheap callsite filter check; called only when the cached
Interest is Sometimes. Default impl returns true
(allows every callsite that survived enabled_static).
Sourcefn generation(&self) -> u32
fn generation(&self) -> u32
Monotonic generation counter; bumped on every filter / config change so callsite caches re-validate. Spec 11 § 3.2.
Sourcefn reload_filter(&self)
fn reload_filter(&self)
Force every callsite’s interest cache back to Unknown.
Default impl is a no-op for observers that don’t filter.
Sourcefn shutdown_blocking(&self, timeout: Duration)
fn shutdown_blocking(&self, timeout: Duration)
Synchronous shutdown for use in panic hooks and Drop impls
where awaiting is not possible. Best-effort within timeout.
Spec 11 § 3, § 6.1.
Sourcefn callsites(&self) -> Option<Arc<ObsCallsiteRegistry>>
fn callsites(&self) -> Option<Arc<ObsCallsiteRegistry>>
Access this observer’s per-process callsite registry, when it
has one. The bridge (Direction A) writes the registry on first
sight; ObsToTracingSink reads it to reconstitute
tracing::Metadata for interned envelopes. Spec 31 § 3.2.
Sourcefn schema_registry(&self) -> Option<Arc<SchemaRegistry>>
fn schema_registry(&self) -> Option<Arc<SchemaRegistry>>
Access this observer’s schema registry, when it has one. Sinks
hold their own Arc<SchemaRegistry> from construction; this
hook lets the bridge fall back to the global observer’s
registry without depending on StandardObserver.
Sourcefn resource_attrs(&self) -> Arc<ResourceAttrs> ⓘ
fn resource_attrs(&self) -> Arc<ResourceAttrs> ⓘ
Snapshot of the workspace-shared ResourceAttrs (OTel
semantic-convention keys). Sinks call this at flush time so a
single config-watcher reload re-projects every sink. Default
returns the empty / observer-less attribute set; concrete
observers (StandardObserver) override. Spec 20 § 2.1 / spec
94 § 2.7 / P1-E.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".