Skip to content

Commit

Permalink
OpenTracing Shim: Allow invalid but sampled SpanContext to be returne…
Browse files Browse the repository at this point in the history
…d. (#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:
open-telemetry/opentelemetry-java#5339
  • Loading branch information
carlosalberto authored Aug 10, 2023
1 parent 634b6ae commit b9c8a02
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
18 changes: 14 additions & 4 deletions specification/compatibility/opentracing.md
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand All @@ -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,
Expand Down

0 comments on commit b9c8a02

Please sign in to comment.