Skip to content

Commit cd3898d

Browse files
authoredJun 16, 2022
opentelemetry-jaeger: Fix clearing span context in Propagator (#810)
When `Propagator::extract_with_context()` is run with an Extractor empty of trace metadata, it returns a null (invalid) Context, clearing TraceId, and disabling downwards propagation. As there is already an implicit TraceId (if we're in a Span), we'd like to use it, traces have to start somewhere. This just aligns the mechanics with opentelemetry-sdk: if span extraction errors out we return a clone of the existing context.
1 parent 4b122f9 commit cd3898d

File tree

1 file changed

+3
-4
lines changed
  • opentelemetry-jaeger/src

1 file changed

+3
-4
lines changed
 

‎opentelemetry-jaeger/src/lib.rs

+3-4
Original file line numberDiff line numberDiff line change
@@ -513,10 +513,9 @@ mod propagator {
513513
}
514514

515515
fn extract_with_context(&self, cx: &Context, extractor: &dyn Extractor) -> Context {
516-
cx.with_remote_span_context(
517-
self.extract_span_context(extractor)
518-
.unwrap_or_else(|_| SpanContext::empty_context()),
519-
)
516+
self.extract_span_context(extractor)
517+
.map(|sc| cx.with_remote_span_context(sc))
518+
.unwrap_or_else(|_| cx.clone())
520519
}
521520

522521
fn fields(&self) -> FieldIter<'_> {

0 commit comments

Comments
 (0)
Please sign in to comment.