diff --git a/opentelemetry-api/src/trace/tracer.rs b/opentelemetry-api/src/trace/tracer.rs index e36d32c5c5..c219d2d8ea 100644 --- a/opentelemetry-api/src/trace/tracer.rs +++ b/opentelemetry-api/src/trace/tracer.rs @@ -271,9 +271,6 @@ pub struct SpanBuilder { /// Span status pub status: Status, - - /// Sampling result - pub sampling_result: Option, } /// SpanBuilder methods @@ -373,14 +370,6 @@ impl SpanBuilder { SpanBuilder { status, ..self } } - /// Assign sampling result - pub fn with_sampling_result(self, sampling_result: SamplingResult) -> Self { - SpanBuilder { - sampling_result: Some(sampling_result), - ..self - } - } - /// Builds a span with the given tracer from this configuration. pub fn start(self, tracer: &T) -> T::Span { tracer.build_with_context(self, &Context::current()) diff --git a/opentelemetry-sdk/src/trace/tracer.rs b/opentelemetry-sdk/src/trace/tracer.rs index 2852d621d7..9d2282f45a 100644 --- a/opentelemetry-sdk/src/trace/tracer.rs +++ b/opentelemetry-sdk/src/trace/tracer.rs @@ -152,10 +152,7 @@ impl opentelemetry_api::trace::Tracer for Tracer { let span_kind = builder.span_kind.take().unwrap_or(SpanKind::Internal); let mut attribute_options = builder.attributes.take().unwrap_or_default(); let mut link_options = builder.links.take(); - let mut no_parent = true; - let mut remote_parent = false; let mut parent_span_id = SpanId::INVALID; - let mut parent_trace_flags = TraceFlags::default(); let trace_id; let parent_span = if parent_cx.has_active_span() { @@ -166,10 +163,7 @@ impl opentelemetry_api::trace::Tracer for Tracer { // Build context for sampling decision if let Some(sc) = parent_span.as_ref().map(|parent| parent.span_context()) { - no_parent = false; - remote_parent = sc.is_remote(); parent_span_id = sc.span_id(); - parent_trace_flags = sc.trace_flags(); trace_id = sc.trace_id(); } else { trace_id = builder @@ -177,36 +171,16 @@ impl opentelemetry_api::trace::Tracer for Tracer { .unwrap_or_else(|| config.id_generator.new_trace_id()); }; - // There are 3 paths for sampling. - // - // * Sampling has occurred elsewhere and is already stored in the builder - // * There is no parent or a remote parent, in which case make decision now - // * There is a local parent, in which case defer to the parent's decision - let sampling_decision = if let Some(sampling_result) = builder.sampling_result.take() { - self.process_sampling_result(sampling_result, parent_cx) - } else if no_parent || remote_parent { - self.make_sampling_decision( - parent_cx, - trace_id, - &builder.name, - &span_kind, - &attribute_options, - link_options.as_deref().unwrap_or(&[]), - provider.config(), - &self.instrumentation_lib, - ) - } else { - // has parent that is local: use parent if sampled, or don't record. - parent_span - .filter(|span| span.span_context().is_sampled()) - .map(|span| { - ( - parent_trace_flags, - Vec::new(), - span.span_context().trace_state().clone(), - ) - }) - }; + let sampling_decision = self.make_sampling_decision( + parent_cx, + trace_id, + &builder.name, + &span_kind, + &attribute_options, + link_options.as_deref().unwrap_or(&[]), + provider.config(), + &self.instrumentation_lib, + ); let SpanBuilder { name,