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

Fixed B3 Propagator #1750

Merged
merged 1 commit into from
Apr 6, 2021
Merged

Fixed B3 Propagator #1750

merged 1 commit into from
Apr 6, 2021

Conversation

owais
Copy link
Contributor

@owais owais commented Apr 6, 2021

Description

B3 propagator was returning None instead of invalid context after last
change. This resulted in many apps crashing when B3 failed to extract a
valid context from carrier. This PR patches it to not make apps crash
and return an invalid context when one cannot be extracted from the
carrier.

Fixes # (issue)

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)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • 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

  • Added test case

Does This PR Require a Contrib Repo Change?

  • Yes.
  • No.

Checklist:

  • Followed the style guidelines of this project
  • Changelogs have been updated
  • Unit tests have been added
  • Documentation has been updated

@owais owais requested review from a team, codeboten and srikanthccv and removed request for a team April 6, 2021 08:41
@owais owais force-pushed the fix-b3-propagator branch 6 times, most recently from ed76e66 to fba4e61 Compare April 6, 2021 11:06
@@ -97,6 +97,8 @@ def extract(
or self._trace_id_regex.fullmatch(trace_id) is None
or self._span_id_regex.fullmatch(span_id) is None
):
if context is None:
return trace.set_span_in_context(trace.INVALID_SPAN, context)
return 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 should also fix the composite propagator issue. While you are at it, could you also fix another issue with B3 when there is a valid propagation header. context should be passed in this set_span_in_context call.

return trace.set_span_in_context(
trace.NonRecordingSpan(
trace.SpanContext(
# trace an span ids are encoded in hex, so must be converted
trace_id=trace_id,
span_id=span_id,
is_remote=True,
trace_flags=trace.TraceFlags(options),
trace_state=trace.TraceState(),
)
)
)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done. Also added tests to ensure the returned context is always derived from the provided one.

@owais owais force-pushed the fix-b3-propagator branch from fba4e61 to bf92d75 Compare April 6, 2021 15:45
@owais owais force-pushed the fix-b3-propagator branch from bf92d75 to 157f7ab Compare April 6, 2021 15:59
B3 propagator was returning `None` instead of invalid context after last
change. This resulted in many apps crashing when B3 failed to extract a
valid context from carrier. This PR patches it to not make apps crash
and return an invalid context when one cannot be extracted from the
carrier.
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.

3 participants