Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[OpentracingShim] Support returning non-null SpanContextShim in Propagation.extractTextMap when traceId and SpanId are not present in OTel SpanContext #5339

Open
ChenX1993 opened this issue Mar 31, 2023 · 5 comments
Labels
Feature Request Suggest an idea for this project

Comments

@ChenX1993
Copy link

ChenX1993 commented Mar 31, 2023

Is your feature request related to a problem? Please describe.
Hi,
The request is to make Propagation.extractTextMap method able to conditionally return non-null SpanContextShim when traceId and SpanId are not present OTel SpanContext.
Currently it returns null when OTel SpanContext is invalid - no valid traceId and SpanId:

Span span = Span.fromContext(context);
Baggage baggage = Baggage.fromContext(context);
if (!span.getSpanContext().isValid() && baggage.isEmpty()) {
return null;
}

The reason is to support jaeger-debug-id use case in OTel when we are migrating from deprecated jaeger-client-go.
To quickly explain what jaeger-debug-id does: it allows users to send a inbound request with such jaeger-debug-id header present to enforce sampling without a parent span.

I can implement a custom propagator to extract the header in maybe TraceState in OTel SpanContext, and implement a custom sampler to detect if it is present in the TraceState to sample the span and to set the attribute.
The only blocker right now is in OpentracingShim: it only returns a non-null bridge SpanContextShim when there OTel SpanContext is valid - traceId and SpanId are valid or baggage is not empty, so there is no way to pass the jaeger-debug-id info into the OTel when creating the span.

Describe the solution you'd like
Since the jaeger-debug-id is very specific to jaeger, and not general to OpenTracing. I am thinking about more generic way to solve it.

One approach I can think of is to make such change:

if (!span.getSpanContext().isValid() && !span.getSpanContext().isSampled && baggage.isEmpty()) {
      return null;
}

Then in my custom propagator, I can set the traceFlags to sampled when extracting jaeger-debug-id header.

or

if (!span.getSpanContext().isValid() && span.getSpanContext().getTraceState.get("force.passthrough") == null && baggage.isEmpty()) {
      return null;
}

Hope this request make sense. Thanks!

@ChenX1993 ChenX1993 added the Feature Request Suggest an idea for this project label Mar 31, 2023
@jkwatson
Copy link
Contributor

paging @carlosalberto

@ChenX1993
Copy link
Author

If you are ok with the request, then you can assign to me.
I can contribute to that.

@carlosalberto
Copy link
Contributor

I think this makes sense, as I remember seeing this in Jaeger and was curious whether we would ever need this.

@yurishkuro any opinion on this, or are we ok supporting this?

@carlosalberto
Copy link
Contributor

Ping @yurishkuro

@yurishkuro
Copy link
Member

+1

carlosalberto added a commit to open-telemetry/opentelemetry-specification that referenced this issue Aug 10, 2023
…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
carlosalberto added a commit to carlosalberto/opentelemetry-specification that referenced this issue Oct 31, 2024
…d. (open-telemetry#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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature Request Suggest an idea for this project
Projects
None yet
4 participants