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

Support Bagagge-only propagation in the OpenTracing Shim. #2326

Merged

Conversation

carlosalberto
Copy link
Contributor

@carlosalberto carlosalberto commented Feb 8, 2022

Resolves an item from #2147

Although many OpenTracing tracers do not support baggage propagation amidst missing/invalid SpanContext, this is something (at least) Jaeger clients expect.

Overall, the changes to properly support this are:

  1. Extract and inject MUST handle the case of valid Baggage, even amidst missing/invalid SpanContext, in order to support the vanilla OT propagation case:
// extractedSpanContext is invalid, but it contains non-empty Baggage
SpanContext extractedSpanContext = tracer.extract(carrier, Format.TEXT_MAP, textMapAdapter);
Span span1 = tracer.buildSpan("child").asChildOf(extractedSpanContext).start();
  1. activeSpan() MUST include Baggage handling, in order to support OTel/OT explicit propagation:
// OTel extracts and activates Baggage, SpanContext is missing.
try (io.opentelemetry.context.Scope scope = extractedContext.current()) {
  ...
  // OT **explicitly** tries to fetch any current Span as the parent.
  // span1's Baggage MUST consume the Baggage in the extracted Context.
  Span span1 = tracer.buildSpan("child").asChildOf(tracer.activeSpan()).start();
}
  1. startSpan() MUST consume any active Baggage, in order to support OTel/OT implicit propagation:
// OTel extracts and activates Baggage, SpanContext is missing.
try (io.opentelemetry.context.Scope scope = extractedContext.current()) {
  ...
  // OT **implicitly** tries to fetch any current Span as the parent.
  // span1's Baggage MUST consume the Baggage in the extracted Context.
  Span span1 = tracer.buildSpan("child").start();
}

See the prototype for Java: https://github.com/carlosalberto/opentelemetry-java/compare/otshim-spanshim-lock...carlosalberto:otshim-baggage-only-support?expand=1

@carlosalberto carlosalberto requested review from a team February 8, 2022 22:21
@carlosalberto carlosalberto changed the title Support Bagagge-only propagation in the OT Shim. Support Bagagge-only propagation in the OpenTracing Shim. Feb 8, 2022
Copy link
Contributor

@jmacd jmacd left a comment

Choose a reason for hiding this comment

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

Thanks for the detailed PR description 😀

@yurishkuro yurishkuro merged commit 6f52c98 into open-telemetry:main Feb 10, 2022
carlosalberto added a commit to carlosalberto/opentelemetry-specification that referenced this pull request Oct 31, 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
Development

Successfully merging this pull request may close these issues.

5 participants