pub struct Observability { /* private fields */ }observability only.Expand description
The configured telemetry providers. Cheap to clone; every clone refers to the same providers.
Dropping the last clone without calling shutdown
lets the SDK flush on drop, which may block; call shutdown explicitly
(Kerniq’s App does so after draining connections).
Implementations§
Source§impl Observability
impl Observability
Sourcepub fn builder() -> ObservabilityBuilder
pub fn builder() -> ObservabilityBuilder
Starts configuring observability.
Sourcepub fn disabled() -> Observability
pub fn disabled() -> Observability
A handle with every signal disabled.
Sourcepub fn service(&self) -> &ServiceInfo
pub fn service(&self) -> &ServiceInfo
The service identity.
Sourcepub fn resource(&self) -> &Resource
Available on crate features logs or metrics or tracing only.
pub fn resource(&self) -> &Resource
logs or metrics or tracing only.The OpenTelemetry resource attached to every signal.
Sourcepub fn meter(&self, name: &'static str) -> Meter
Available on crate feature metrics only.
pub fn meter(&self, name: &'static str) -> Meter
metrics only.A meter for application instruments. Create instruments once and reuse them; recording is lock-free in the common case. Returns a no-op meter when metrics are disabled, so instrumentation code never needs to check.
Sourcepub fn meter_provider(&self) -> Option<&SdkMeterProvider>
Available on crate feature metrics only.
pub fn meter_provider(&self) -> Option<&SdkMeterProvider>
metrics only.The SDK meter provider, when metrics are enabled.
Sourcepub fn tracer(&self, name: &'static str) -> SdkTracer
Available on crate feature tracing only.
pub fn tracer(&self, name: &'static str) -> SdkTracer
tracing only.A tracer for manual spans through the OpenTelemetry API. Most code
should use tracing spans instead, which are exported through the
same provider.
Sourcepub fn tracer_provider(&self) -> Option<&SdkTracerProvider>
Available on crate feature tracing only.
pub fn tracer_provider(&self) -> Option<&SdkTracerProvider>
tracing only.The SDK tracer provider, when tracing is enabled.
Sourcepub fn propagator(&self) -> Arc<dyn TextMapPropagator + Send + Sync> ⓘ
Available on crate feature tracing only.
pub fn propagator(&self) -> Arc<dyn TextMapPropagator + Send + Sync> ⓘ
tracing only.The W3C TraceContext + Baggage propagator, for outbound calls
(see kerniq_observability_axum::propagation).
Sourcepub fn logger_provider(&self) -> Option<&SdkLoggerProvider>
Available on crate feature logs only.
pub fn logger_provider(&self) -> Option<&SdkLoggerProvider>
logs only.The SDK logger provider, when log export is enabled.
Sourcepub fn prometheus(&self) -> Option<&PrometheusExporter>
Available on crate feature prometheus only.
pub fn prometheus(&self) -> Option<&PrometheusExporter>
prometheus only.The Prometheus endpoint, when configured.
Sourcepub fn http_instrumentation(&self) -> HttpInstrumentation
pub fn http_instrumentation(&self) -> HttpInstrumentation
HTTP instrumentation configured from this handle: metrics when metrics are enabled, spans and W3C propagation when tracing is enabled, and the configured exclusions (the Prometheus path is always excluded).
Sourcepub fn stats(&self) -> TelemetryStats
pub fn stats(&self) -> TelemetryStats
Export-pipeline counters (see TelemetryStats). Also published as
the kerniq.telemetry.items and kerniq.telemetry.exports metrics.
Sourcepub fn force_flush(&self) -> Vec<String>
pub fn force_flush(&self) -> Vec<String>
Exports everything buffered now. Blocks the calling thread until the
exporters return; use from spawn_blocking in async code.
Sourcepub async fn shutdown(&self) -> ShutdownReport
pub async fn shutdown(&self) -> ShutdownReport
Flushes and shuts down every provider, in at most the configured shutdown timeout. Idempotent; later calls return immediately.
Call it after the server has stopped accepting requests and drained
(Kerniq’s App does this automatically). Providers are shut down on
Tokio’s blocking pool, so the async runtime stays responsive even if
a Collector is unreachable; the caller waits at most the timeout.
Sourcepub fn install_global_providers(&self)
pub fn install_global_providers(&self)
Sets this handle’s providers and propagator as the OpenTelemetry
globals (opentelemetry::global), for libraries that instrument
through the global API. Never done implicitly.
Sourcepub fn tracing_layer<S>(&self) -> Box<dyn Layer<S> + Send + Sync>
Available on crate features logs or tracing only.
pub fn tracing_layer<S>(&self) -> Box<dyn Layer<S> + Send + Sync>
logs or tracing only.The tracing layers for this configuration (console output, span
export, log export), each with its own filter, for composing into an
application-owned subscriber (with
install_subscriber(false)).
use tracing_subscriber::layer::SubscriberExt;
use kerniq_observability::prelude::*;
let observability = Observability::builder()
.logs(LogsConfig::json())
.install_subscriber(false)
.build()
.await?;
let subscriber = tracing_subscriber::registry()
.with(observability.tracing_layer())
// .with(your_other_layer)
;
tracing::subscriber::set_global_default(subscriber).unwrap();Trait Implementations§
Source§impl Clone for Observability
impl Clone for Observability
Source§fn clone(&self) -> Observability
fn clone(&self) -> Observability
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl !RefUnwindSafe for Observability
impl !UnwindSafe for Observability
impl Forget for Observability
impl Freeze for Observability
impl Send for Observability
impl Sync for Observability
impl Unpin for Observability
impl UnsafeUnpin for Observability
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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
Source§fn with_current_context(self) -> WithContext<Self> ⓘ
fn with_current_context(self) -> WithContext<Self> ⓘ
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::RequestSource§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<T> ServiceExt for T
impl<T> ServiceExt for T
Source§fn compression(self) -> Compression<Self>where
Self: Sized,
fn compression(self) -> Compression<Self>where
Self: Sized,
compression-br or compression-deflate or compression-gzip or compression-zstd only.Source§fn trace_for_http(self) -> Trace<Self, SharedClassifier<ServerErrorsAsFailures>>where
Self: Sized,
fn trace_for_http(self) -> Trace<Self, SharedClassifier<ServerErrorsAsFailures>>where
Self: Sized,
trace only.Source§fn trace_for_grpc(self) -> Trace<Self, SharedClassifier<GrpcErrorsAsFailures>>where
Self: Sized,
fn trace_for_grpc(self) -> Trace<Self, SharedClassifier<GrpcErrorsAsFailures>>where
Self: Sized,
trace only.Source§fn set_request_id<M>(
self,
header_name: HeaderName,
make_request_id: M,
) -> SetRequestId<Self, M>where
Self: Sized,
M: MakeRequestId,
fn set_request_id<M>(
self,
header_name: HeaderName,
make_request_id: M,
) -> SetRequestId<Self, M>where
Self: Sized,
M: MakeRequestId,
request-id only.Source§fn set_x_request_id<M>(self, make_request_id: M) -> SetRequestId<Self, M>where
Self: Sized,
M: MakeRequestId,
fn set_x_request_id<M>(self, make_request_id: M) -> SetRequestId<Self, M>where
Self: Sized,
M: MakeRequestId,
request-id only.x-request-id as the header name. Read moreSource§fn propagate_request_id(
self,
header_name: HeaderName,
) -> PropagateRequestId<Self>where
Self: Sized,
fn propagate_request_id(
self,
header_name: HeaderName,
) -> PropagateRequestId<Self>where
Self: Sized,
request-id only.Source§fn propagate_x_request_id(self) -> PropagateRequestId<Self>where
Self: Sized,
fn propagate_x_request_id(self) -> PropagateRequestId<Self>where
Self: Sized,
request-id only.x-request-id as the header name. Read more