pub struct TelemetryHandles {
pub tracer_provider: SdkTracerProvider,
pub meter_provider: Option<SdkMeterProvider>,
pub logger_provider: Option<SdkLoggerProvider>,
/* private fields */
}Expand description
Handles returned by init_telemetry or TelemetryBuilder::init.
Keep alive for the duration of the process. Call shutdown
before exiting to flush pending spans, metrics, and logs.
When dropped, shutdown is attempted with a bounded timeout (default: 5 s). If the timeout expires a warning is logged but the process continues normally.
§Example
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let handles = otel_bootstrap::init_telemetry("my-service")?;
// run your application here …
handles.shutdown()?;
Ok(())
}Fields§
§tracer_provider: SdkTracerProvider§meter_provider: Option<SdkMeterProvider>§logger_provider: Option<SdkLoggerProvider>Implementations§
Source§impl TelemetryHandles
impl TelemetryHandles
Sourcepub fn shutdown(&self) -> Result<(), Box<dyn Error>>
pub fn shutdown(&self) -> Result<(), Box<dyn Error>>
Flush pending data and shut down all providers.
Must be called before the tokio runtime shuts down so the batch exporter can send remaining spans over gRPC. Safe to call multiple times — subsequent calls are no-ops.
§Example
let handles = otel_bootstrap::init_telemetry("my-service").unwrap();
// … application logic …
handles.shutdown().expect("telemetry shutdown failed");Trait Implementations§
Auto Trait Implementations§
impl Freeze for TelemetryHandles
impl !RefUnwindSafe for TelemetryHandles
impl Send for TelemetryHandles
impl Sync for TelemetryHandles
impl Unpin for TelemetryHandles
impl UnsafeUnpin for TelemetryHandles
impl !UnwindSafe for TelemetryHandles
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> 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