From b9c8a02f64ba86501b995649e957bba44e6712f5 Mon Sep 17 00:00:00 2001 From: Carlos Alberto Cortez Date: Thu, 10 Aug 2023 18:10:19 +0200 Subject: [PATCH] OpenTracing Shim: Allow invalid but sampled SpanContext to be returned. (#3471) This is done to support the `jaeger-debug-id` functionality, which allows invalid SpanContext with debug information to be propagated. This came up through an issue in Java: https://github.com/open-telemetry/opentelemetry-java/issues/5339 --- CHANGELOG.md | 3 +++ specification/compatibility/opentracing.md | 18 ++++++++++++++---- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 910547a58f6..c99be2f2db0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,9 @@ release. ### Compatibility +- OpenTracing Shim: Allow invalid but sampled SpanContext to be returned. + ([#3471](https://github.com/open-telemetry/opentelemetry-specification/pull/3471)) + ### SDK Configuration ### Common diff --git a/specification/compatibility/opentracing.md b/specification/compatibility/opentracing.md index 96f011a5943..1481b0af2b7 100644 --- a/specification/compatibility/opentracing.md +++ b/specification/compatibility/opentracing.md @@ -194,12 +194,18 @@ registered or the global OpenTelemetry `Propagator`s, as configured at construct - `TextMap` and `HttpHeaders` formats MUST use their explicitly specified `TextMapPropagator`, if any, or else use the global `TextMapPropagator`. -If the extracted `SpanContext` is invalid AND the extracted `Baggage` is empty, this operation -MUST return a null value, and otherwise it MUST return a `SpanContext` Shim instance with -the extracted values. +The operation MUST return a `SpanContext` Shim instance with the extracted values if any of these conditions are met: + +* `SpanContext` is valid. +* `SpanContext` is sampled. +* `SpanContext` contains non-empty extracted `Baggage`. + +Otherwise, the operation MUST return null or empty value. ```java -if (!extractedSpanContext.isValid() && extractedBaggage.isEmpty()) { +if (!extractedSpanContext.isValid() + && !extractedSpanContext.isSampled() + && extractedBaggage.isEmpty()) { return null; } @@ -210,6 +216,10 @@ Errors MAY be raised if either the `Format` is not recognized or no value could be extracted, depending on the specific OpenTracing Language API (e.g. Go and Python do, but Java may not). +Note: Invalid but sampled `SpanContext` instances are returned as a way to support +`jaeger-debug-id` [headers](https://github.com/jaegertracing/jaeger-client-java#via-http-headers), +which are used to force propagation of debug information. + ## Close OPTIONAL operation. If this operation is implemented for a specific OpenTracing language,