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

[OpenTracing Shim] Support TraceFlags-only propagation without parent span #5380

Closed
wants to merge 1 commit into from

Conversation

ChenX1993
Copy link

@ChenX1993 ChenX1993 commented Apr 13, 2023

Resolves #5339

Support propagating the TraceFlags without parent spans, e.g. the usecase of jaeger-debug-id.

@ChenX1993 ChenX1993 requested a review from a team April 13, 2023 08:17
@linux-foundation-easycla
Copy link

linux-foundation-easycla bot commented Apr 13, 2023

CLA Signed

The committers listed above are authorized under a signed CLA.

  • ✅ login: ChenX1993 / name: Chen Xu (e912fe9)

@codecov
Copy link

codecov bot commented Apr 13, 2023

Codecov Report

Patch coverage: 35.71% and project coverage change: -0.11 ⚠️

Comparison is base (0a2dd9e) 91.38% compared to head (e912fe9) 91.27%.

Additional details and impacted files
@@             Coverage Diff              @@
##               main    #5380      +/-   ##
============================================
- Coverage     91.38%   91.27%   -0.11%     
- Complexity     4959     4964       +5     
============================================
  Files           549      550       +1     
  Lines         14563    14589      +26     
  Branches       1356     1358       +2     
============================================
+ Hits          13308    13316       +8     
- Misses          868      886      +18     
  Partials        387      387              
Impacted Files Coverage Δ
...y/opentracingshim/PropagatedOpenTelemetrySpan.java 25.00% <25.00%> (ø)
.../io/opentelemetry/opentracingshim/Propagation.java 88.88% <100.00%> (+0.65%) ⬆️
...opentelemetry/opentracingshim/SpanBuilderShim.java 94.82% <100.00%> (ø)

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@jkwatson
Copy link
Contributor

@carlosalberto Can you take a look? This doesn't seem out-of-line to me, but I really don't know much about OT.

@jack-berg
Copy link
Member

@carlosalberto bump. Does this impact stabilizing the shim in #5371?

@carlosalberto
Copy link
Contributor

carlosalberto commented May 4, 2023

I'd say NO - the reason is that is not covered in the Compatibility spec right now (which is stable already). I will prepare a PR to the Spec to update this condition. My impression is that this shouldn't be impacting the expected behavior (as Jaeger already supported this, and it's a corner case for them).

cc @yurishkuro

@carlosalberto
Copy link
Contributor

(In case I wasn't clear, while I prepare the Spec PR for this, I suggest we don't include this in the upcoming release)

Attributes attributes,
List<LinkData> parentLinks) {
SpanContext parentSpanContext = Span.fromContext(parentContext).getSpanContext();
if (parentSpanContext.isSampled()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the purpose of this check? Shouldn't the presence of DEBUG_ID_TAG be enough to cause sampling?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because the my current implementation inPropagation.java (shim) is to check span.getSpanContext().isSampled() in order to return a non-null SpanContextShim for jaeger-debug-id case.

So I just added parentSpanContext.isSampled() for one more check here in the test sampler.

Context context =
Context.root().with(PropagatedOpenTelemetrySpan.create(invalidSpanContextWithFlags));
CustomTextMapPropagator textMapPropagator = new CustomTextMapPropagator();
textMapPropagator.setExtractReturnContext(context);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can never be done in a real propagator, which should be stateless. I would recommend changing CustomTextMapPropagator to look for debug header in the carrier and then constructing invalidSpanContextWithFlags in response. That would constitute a realistic test.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the suggestion! I will make the change.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this done @ChenX1993 ?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@carlosalberto Updated. This is done.

@@ -197,7 +197,7 @@ public Span start() {
builder.setNoParent();
baggage = Baggage.empty();
} else if (mainParent != null) {
builder.setParent(Context.root().with(io.opentelemetry.api.trace.Span.wrap(mainParent)));
builder.setParent(Context.root().with(PropagatedOpenTelemetrySpan.create(mainParent)));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

parents in OT are expressed via SpanContexts, not full spans, so why do we need PropagatedOpenTelemetrySpan?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, but the builder here is a OTel span builder, and the parent required here is a OTel context object with parent OTel span.

The original io.opentelemetry.api.trace.Span.wrap will return a new invalid span if the spanContext is invalid instead of wrapping the spanContext provided, so I added the PropagatedOpenTelemetrySpan to address this.

static Span wrap(SpanContext spanContext) {
    if (spanContext == null) {
      ApiUsageLogger.log("context is null");
      return getInvalid();
    }
    if (!spanContext.isValid()) {
      return getInvalid();
    }
    return PropagatedSpan.create(spanContext);
  }

@carlosalberto
Copy link
Contributor

Ping @ChenX1993

@ChenX1993
Copy link
Author

Sorry for the late reply. @yurishkuro
Thanks for the remind @carlosalberto

… span

Signed-off-by: Chen Xu <chen.x@uber.com>
@carlosalberto
Copy link
Contributor

Ping @yurishkuro

1 similar comment
@carlosalberto
Copy link
Contributor

Ping @yurishkuro

@jack-berg
Copy link
Member

Closing this PR as stale. Please re-open if interested in continuing the effort.

@jack-berg jack-berg closed this Apr 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
5 participants