Skip to content

Commit 241bf2e

Browse files
committed
extract parent span
1 parent eaf22d3 commit 241bf2e

File tree

1 file changed

+6
-2
lines changed
  • opentelemetry-instrumentation-tower/src

1 file changed

+6
-2
lines changed

opentelemetry-instrumentation-tower/src/lib.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -450,7 +450,11 @@ where
450450
// Extract custom request attributes
451451
let custom_request_attributes = self.request_extractor.extract_attributes(&req);
452452

453-
// Start tracing span
453+
// Extract the context from the incoming request headers
454+
let parent_cx = global::get_text_map_propagator(|propagator| {
455+
propagator.extract(&HeaderExtractor(req.headers()))
456+
});
457+
454458
let mut span_attributes = vec![
455459
KeyValue::new(semconv::trace::HTTP_REQUEST_METHOD, method.clone()),
456460
url_scheme_kv.clone(),
@@ -484,7 +488,7 @@ where
484488
.span_builder(span_name)
485489
.with_kind(SpanKind::Server)
486490
.with_attributes(span_attributes)
487-
.start(&tracer);
491+
.start_with_context(&tracer, &parent_cx);
488492

489493
let cx = OtelContext::current_with_span(span);
490494

0 commit comments

Comments
 (0)