Skip to content

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

Closed
ChenX1993 wants to merge 1 commit into
open-telemetry:mainfrom
ChenX1993:dev/shim
Closed

[OpenTracing Shim] Support TraceFlags-only propagation without parent span#5380
ChenX1993 wants to merge 1 commit into
open-telemetry:mainfrom
ChenX1993:dev/shim

Conversation

@ChenX1993

@ChenX1993 ChenX1993 commented Apr 13, 2023

Copy link
Copy Markdown

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

linux-foundation-easycla Bot commented Apr 13, 2023

Copy link
Copy Markdown

CLA Signed

The committers listed above are authorized under a signed CLA.

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

@codecov

codecov Bot commented Apr 13, 2023

Copy link
Copy Markdown

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
Copy Markdown
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
Copy Markdown
Member

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

@carlosalberto

carlosalberto commented May 4, 2023

Copy link
Copy Markdown
Contributor

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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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.

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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Contributor

Ping @ChenX1993

@ChenX1993

Copy link
Copy Markdown
Author

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

@carlosalberto

Copy link
Copy Markdown
Contributor

Ping @yurishkuro

1 similar comment
@carlosalberto

Copy link
Copy Markdown
Contributor

Ping @yurishkuro

@jack-berg

Copy link
Copy Markdown
Member

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

5 participants