pub struct ObservabilityHandle { /* private fields */ }Expand description
Handle for managing the observability system lifecycle.
This handle provides graceful shutdown for all initialized observability components. It holds references to the tracing handle and metrics server, allowing coordinated shutdown of all components.
§Example
let config = ObservabilityConfig::default();
let handle = init_observability(config).await?;
// ... application runs ...
// Graceful shutdown
handle.shutdown().await?;Implementations§
Source§impl ObservabilityHandle
impl ObservabilityHandle
Sourcepub async fn shutdown(self) -> Result<(), ObservabilityError>
pub async fn shutdown(self) -> Result<(), ObservabilityError>
Shutdown all observability components gracefully.
This method:
- Shuts down the tracing system (flushes pending spans)
- Shuts down the metrics server (stops HTTP server)
After calling this method, no more telemetry will be exported.
§Errors
Returns an error if any component fails to shut down gracefully.
§Example
let handle = init_observability(config).await?;
// Graceful shutdown
handle.shutdown().await?;Sourcepub fn metrics_registry(&self) -> &MetricsRegistry
pub fn metrics_registry(&self) -> &MetricsRegistry
Returns a reference to the metrics registry.
The metrics registry is always available, even if the metrics server was not started. This allows applications to collect metrics without exposing them via HTTP.
§Example
let handle = init_observability(config).await?;
// Access metrics registry
let counter = handle.metrics_registry().register_counter("my_counter", vec![]);
counter.inc();Sourcepub fn is_metrics_server_running(&self) -> bool
pub fn is_metrics_server_running(&self) -> bool
Returns true if the metrics server is running.
Auto Trait Implementations§
impl Freeze for ObservabilityHandle
impl !RefUnwindSafe for ObservabilityHandle
impl Send for ObservabilityHandle
impl Sync for ObservabilityHandle
impl Unpin for ObservabilityHandle
impl UnsafeUnpin for ObservabilityHandle
impl !UnwindSafe for ObservabilityHandle
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
Mutably borrows from an owned value. Read more
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> 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>
Converts
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>
Converts
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 moreSource§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>
Wrap the input message
T in a tonic::Request