pub struct TelemetryConfig {
pub app_name: String,
pub env: String,
pub endpoint_url: Option<String>,
pub tracer_id: Option<String>,
}Expand description
Configuration for telemetry setup.
This struct provides fields to set up OpenTelemetry exporters, specify the application name, environment, endpoint URL, and an optional tracer ID.
Fields§
§app_name: StringName of the application.
env: StringSpecifies the environment (e.g., “development” or “production”).
endpoint_url: Option<String>Optional URL for the OTLP exporter.
tracer_id: Option<String>Optional tracer ID.
Implementations§
Source§impl TelemetryConfig
impl TelemetryConfig
Sourcepub fn get_trace_id(&self) -> TraceId
pub fn get_trace_id(&self) -> TraceId
Retrieves the current trace ID.
This method fetches the trace ID from the current span context.
Trait Implementations§
Source§impl Clone for TelemetryConfig
impl Clone for TelemetryConfig
Source§fn clone(&self) -> TelemetryConfig
fn clone(&self) -> TelemetryConfig
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for TelemetryConfig
impl Debug for TelemetryConfig
Source§impl Default for TelemetryConfig
impl Default for TelemetryConfig
Source§fn default() -> TelemetryConfig
fn default() -> TelemetryConfig
Returns the “default value” for a type. Read more
Source§impl TelemetryInit for TelemetryConfig
Initializes telemetry based on the provided configuration.
impl TelemetryInit for TelemetryConfig
Initializes telemetry based on the provided configuration.
This method will:
- Set the global text map propagator to
TraceContextPropagator. - Check for an OTLP endpoint and set up the OTLP exporter if present.
- Configure a logger based on the environment (
developmentor other). - Optionally, set a global tracer if
tracer_idis provided.
Auto Trait Implementations§
impl Freeze for TelemetryConfig
impl RefUnwindSafe for TelemetryConfig
impl Send for TelemetryConfig
impl Sync for TelemetryConfig
impl Unpin for TelemetryConfig
impl UnwindSafe for TelemetryConfig
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> 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>
Wrap the input message
T in a tonic::Request