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

Make propagators conform to spec #488

Merged
merged 5 commits into from
May 31, 2021

Conversation

mariojonke
Copy link
Contributor

@mariojonke mariojonke commented May 4, 2021

Description

Propagators use the root context as default value for the extract operation. Additionally avoid modifying the context in case there is nothing to extract or the carrier does not hold valid data.

Fixes open-telemetry/opentelemetry-python#1765

Fixes also an issue in the ot-trace propagator where trace/span id validity was comparing str with int values.

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)

How Has This Been Tested?

unit tests have been added/adapted

Does This PR Require a Core Repo Change?

  • No.

Checklist:

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

* do not modify / set an invalid span in the passed context in case
  a propagator did not manage to extract
* in case no context is passed to propagator.extract assume the root
  context as default so that a new trace is started instead of continung
  the current active trace in case extraction fails
* fix also ot-trace propagator which compared int with str trace/span ids
  when checking for validity in extract
@mariojonke mariojonke requested a review from a team as a code owner May 4, 2021 15:09
@mariojonke mariojonke requested review from codeboten and hectorhdzg and removed request for a team May 4, 2021 15:09
Copy link
Member

@srikanthccv srikanthccv left a comment

Choose a reason for hiding this comment

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

LGTM. Probably it's better we log warning when there is some error extracting span id or trace id or anything.

@@ -42,6 +42,9 @@ def extract(
context: typing.Optional[Context] = None,
getter: Getter = default_getter,
) -> Context:
if context is None:
context = Context()
Copy link
Contributor

Choose a reason for hiding this comment

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

In this PR description you mention this, @mariojonke:

Propagators should return the passed in context (or the current one if none was given) if nothing could be extracted.

Should we use the current context instead of instantiating a new one?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We decided in the SIG meeting to use the root context as default because the current context would continue a possible active trace instead of starting a new one if extracting from the carrier fails (see also open-telemetry/opentelemetry-python#1765 (comment))

See also PR in the core repo: open-telemetry/opentelemetry-python#1811

Copy link
Contributor

Choose a reason for hiding this comment

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

Ok, good 👍

Copy link
Contributor

@codeboten codeboten left a comment

Choose a reason for hiding this comment

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

👍

@codeboten codeboten merged commit 3a7eb53 into open-telemetry:main May 31, 2021
@mariojonke mariojonke deleted the propagator-extract-ctx branch October 8, 2021 08:32
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.

Propagators must not return an invalid span if nothing could be extracted from the carrier
4 participants