From 5922205d07e10db56cbb4731eebbcbea14500b51 Mon Sep 17 00:00:00 2001 From: Dirkjan Ochtman Date: Mon, 15 Jul 2024 18:13:45 +0200 Subject: [PATCH] sdk: expose Tracer::id_generator() (#1934) --- opentelemetry-sdk/src/trace/tracer.rs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/opentelemetry-sdk/src/trace/tracer.rs b/opentelemetry-sdk/src/trace/tracer.rs index ea56725d15..0639515adc 100644 --- a/opentelemetry-sdk/src/trace/tracer.rs +++ b/opentelemetry-sdk/src/trace/tracer.rs @@ -11,7 +11,7 @@ use crate::{ trace::{ provider::TracerProvider, span::{Span, SpanData}, - SpanLimits, SpanLinks, + IdGenerator, SpanEvents, SpanLimits, SpanLinks, }, InstrumentationLibrary, }; @@ -22,8 +22,6 @@ use opentelemetry::{ use std::fmt; use std::sync::Arc; -use super::SpanEvents; - /// `Tracer` implementation to create and manage spans #[derive(Clone)] pub struct Tracer { @@ -160,6 +158,14 @@ impl Tracer { span_limits, ) } + + /// The [`IdGenerator`] associated with this tracer. + /// + // Note: this is necessary for tracing-opentelemetry's `PreSampledTracer`. + #[doc(hidden)] + pub fn id_generator(&self) -> &dyn IdGenerator { + &*self.provider.config().id_generator + } } impl opentelemetry::trace::Tracer for Tracer {