Skip to main content

Telemetry

Struct Telemetry 

Source
pub struct Telemetry { /* private fields */ }
Expand description

The installed stack handed to callers: an installed global subscriber is a process-wide singleton, so the handle carries only what callers need afterwards.

Telemetry is Send + Sync; clone-free sharing is by design — hand the Telemetry::metrics registry Arc to workers instead.

Implementations§

Source§

impl Telemetry

Source

pub fn init(config: TelemetryConfig) -> Result<Self, TelemetryError>

Bootstrap the estate telemetry stack and install it as the global tracing subscriber.

Installs, in one call:

  1. a tracing_subscriber EnvFilter — built from the configured log_level, with RUST_LOG winning when set and non-empty — and a fmt layer (LogFormat::Json via the json feature, LogFormat::Pretty otherwise);
  2. a metrics-kit Registry under the metrics feature, sized by metrics_budget and handed to the caller through Telemetry::metrics;
  3. with the otlp feature and an endpoint configured: an opentelemetry-otlp span exporter (HTTP/protobuf, batch) wired as a tracing-opentelemetry layer, with service.name and service.version resource attributes and the configured sample rate.
§Errors
  • TelemetryError::AlreadyInitialized — the global subscriber is already installed (this crate init’ed twice, or another crate owns the global). The process-wide subscriber can only be set once; this is a typed error, never a panic.
  • TelemetryError::InitFailed — the env-filter directive does not parse, LogFormat::Json was requested without the json feature, or the OTLP exporter could not be built.
Source

pub fn metrics(&self) -> Arc<Registry> ⓘ

The metrics registry for hot-path handle registration.

Handles register through this Arc; every clone of the returned Arc renders identically. Under no-default-features (no metrics feature) this method does not exist.

Source

pub fn shutdown(&self) -> Result<(), TelemetryError>

Explicitly flush and tear down the export pipeline.

Idempotent: the first call flushes and shuts down the OTLP tracer provider (when one was built); every later call returns Ok(()) without touching anything. After shutdown, spans are no longer exported; the log subscriber keeps working for the process lifetime.

§Errors

TelemetryError::InitFailed if the first call’s provider shutdown fails; later calls never fail.

Trait Implementations§

Source§

impl Debug for Telemetry

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Drop for Telemetry

Source§

fn drop(&mut self)

Best-effort flush of in-flight spans. This is a safety net, not a contract: batch export races process teardown, so call Telemetry::shutdown explicitly on the way down.

Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more