pub struct TelemetryHandle {
logger_provider: Option<SdkLoggerProvider>,
log_filter: String,
jwt: String,
endpoint: String,
metrics_interval: Duration,
metrics_push: Option<MetricsPushHandle>,
metrics_enabled: bool,
metrics_external_labels: Vec<Label>,
rate_limit_warned: Arc<AtomicBool>,
telemetry_log_filter: Arc<String>,
}Expand description
Owns the OTel logger provider and, optionally, the metrics push task, so
both flush on graceful shutdown. Stashes the JWT and endpoint so the push
task can be spawned later via TelemetryHandle::attach_metrics_push once
the API setup has built the Registry.
Fields§
§logger_provider: Option<SdkLoggerProvider>None when only metrics are enabled (logs pipeline disabled).
log_filter: String§jwt: String§endpoint: String§metrics_interval: Duration§metrics_push: Option<MetricsPushHandle>§metrics_enabled: boolWhen false, attach_metrics_push is a no-op.
metrics_external_labels: Vec<Label>Labels stamped onto every pushed TimeSeries (e.g. service, instance),
mirroring the OTel resource attributes so the aggregator partitions logs
and metrics consistently.
rate_limit_warned: Arc<AtomicBool>Latch flipped on the first HTTP 429 from the metrics push, so the
operator-facing ERROR is logged once per process across push ticks. The
logs pipeline retries 429s via opentelemetry-otlp’s built-in
experimental-http-retry and does not surface them here.
telemetry_log_filter: Arc<String>log_filter embedded verbatim in the rate-limit ERROR so operators see
their active filter.
Implementations§
Source§impl TelemetryHandle
impl TelemetryHandle
Sourcepub fn tracing_layer<S>(&self) -> Option<impl Layer<S> + Send + Sync + 'static>where
S: Subscriber + for<'a> LookupSpan<'a>,
pub fn tracing_layer<S>(&self) -> Option<impl Layer<S> + Send + Sync + 'static>where
S: Subscriber + for<'a> LookupSpan<'a>,
Layer bridging tracing events into the OTLP exporter, filtered by
log_filter. None when the logs pipeline is disabled.
Sourcepub fn attach_metrics_push(&mut self, registry: Arc<Registry>)
pub fn attach_metrics_push(&mut self, registry: Arc<Registry>)
Wrapper over [attach_metrics_push_buffered] that emits setup warnings
directly, for callers that already have a subscriber installed.
Sourcefn attach_metrics_push_buffered(
&mut self,
registry: Arc<Registry>,
deferred: &mut Vec<String>,
)
fn attach_metrics_push_buffered( &mut self, registry: Arc<Registry>, deferred: &mut Vec<String>, )
Spawn the periodic metrics push on its own thread. Idempotent: no-op if
already attached or if metrics are disabled. Setup warnings buffer into
deferred so init can replay them after a subscriber is installed.
Sourcepub fn shutdown(self)
pub fn shutdown(self)
Flush the push thread, then shut down the OTel logger provider.
Best-effort; failures are logged, never bubbled. Both joins run through
join_bounded (the provider shutdown can deadlock on a current-thread
runtime).
Trait Implementations§
Auto Trait Implementations§
impl Freeze for TelemetryHandle
impl !RefUnwindSafe for TelemetryHandle
impl Send for TelemetryHandle
impl Sync for TelemetryHandle
impl Unpin for TelemetryHandle
impl UnsafeUnpin for TelemetryHandle
impl !UnwindSafe for TelemetryHandle
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more