Skip to content

Conversation

@vitaly-krugl
Copy link

@vitaly-krugl vitaly-krugl commented Oct 31, 2025

Description

WORK IN PROGRESS - requesting acceptance feasibility feedback from maintainers before proceeding with additional unit tests.

Fixes # 4793
opentelemetry-propagator-b3 doesn't allow the receiver to make sampling decision when X-B3-Sampled header is absent.

This issue is somewhat unique to Zipkin/B3 because it treats sampling state in HTTP headers as optional. Hence, the solution is specific to B3. By contrast, the sampling state is required in W3C Trace Context, and no such solution is necessary for W3C support.

The Zipkin/B3 protocol - https://github.com/openzipkin/b3-propagation - leaves the sampling decision up to the receiver whenever it doesn't receive an explicit sampling state from remote in the carrier:

An accept sampling decision is encoded as X-B3-Sampled: 1 and a deny as X-B3-Sampled: 0. Absent means defer the decision to the receiver of this header.

However, opentelemetry-propagator-b3 incorrectly hard-codes absent sampling state to OFF, not giving the application an opportunity to make this decision. The class B3MultiFormat does not provide the means for an application to specify its preference for the default behavior when sampling state is not received from remote

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • This change requires a documentation update

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration

  • Not tested yet - work in progress to get feedback

Does This PR Require a Contrib Repo Change?

  • No.

Checklist:

  • Followed the style guidelines of this project

@vitaly-krugl vitaly-krugl requested a review from a team as a code owner October 31, 2025 04:19
@linux-foundation-easycla
Copy link

linux-foundation-easycla bot commented Oct 31, 2025

CLA Signed

The committers listed above are authorized under a signed CLA.

  • ✅ login: vitaly-krugl / name: Vitaly Kruglikov (a2faf10)

@vitaly-krugl vitaly-krugl changed the title Addressing issue #4793 - allow app to control b3-propagator sampling decision when no sampling state in carrier Addressing issue #4793 - allow app to control b3-propagator sampling decision when no sampling state in carrier from remote Oct 31, 2025
@vitaly-krugl vitaly-krugl changed the title Addressing issue #4793 - allow app to control b3-propagator sampling decision when no sampling state in carrier from remote NEED FEEDBACK FROM MAINTAINERS Addressing issue #4793 - allow app to control b3-propagator sampling decision when no sampling state in carrier from remote Oct 31, 2025
if single_header:
# The b3 spec calls for the sampling state to be
# "deferred", which is unspecified. This concept does not
# translate to SpanContext, so we set it as recorded.
Copy link
Author

@vitaly-krugl vitaly-krugl Oct 31, 2025

Choose a reason for hiding this comment

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

The b3 spec calls for the sampling state to be deferred "to the receiver" whenever remote doesn't supply it. This pull request facilitates allowing the receiver to make the decision in this scenario.

See https://github.com/openzipkin/b3-propagation

@vitaly-krugl vitaly-krugl force-pushed the fix/4793-allow-br-propagator-sampling-decision-when-no-remote-sampling-state branch 2 times, most recently from adfe67f to a2faf10 Compare October 31, 2025 05:31
…n't allow the receiver to make sampling decision when X-B3-Sampled header is absent. No unit test update yet.
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.

1 participant