-
Notifications
You must be signed in to change notification settings - Fork 847
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
fix: Use ROOT_CONTEXT instead active context as default in extract #1714
fix: Use ROOT_CONTEXT instead active context as default in extract #1714
Conversation
Avoid leaking current context into extracted context on default by using ROOT_CONTEXT as default for extract. If someone wants to extract something it's usually not wanted to leak existing information into the extracted result. e.g. consider an incoming HTTP instrumentation extracing a W3C tag. if active context is used it may get the current active span instead that once extracted from W3C tag or undefined.
Codecov Report
@@ Coverage Diff @@
## master #1714 +/- ##
==========================================
+ Coverage 91.35% 91.53% +0.17%
==========================================
Files 165 71 -94
Lines 5138 1913 -3225
Branches 1056 400 -656
==========================================
- Hits 4694 1751 -2943
+ Misses 444 162 -282
|
Build fail seems to be unrelated: |
Retriggered the build |
Or reorder the arguments. If we want to do something like that now is the time. After GA it will be impossible. |
I'm fine with changing the order. But for consistency I would also change |
Has anyone else an opinion regarding this? I would like to avoid changing a lot without a chance that it gets merged. |
I'm fine if we can do the same order as the Propagator's |
I am also ok with the ordering change. @obecny ? |
context is now optional (as last argument) if we move it to 1st place you will always have to provide it. |
That's the whole intention of the change. The issue is if you do this: context = propagation.extract(headers);
span = getParentSpan(context);
// is span extracted from headers, or did it already exist in the active context? You can solve this by using |
Using the active context in But in general I think that requesting the users to be more explicit is better here. I will create a competing PR with |
it sounds reasonable go for it :) |
close in favor of #1734 |
Which problem is this PR solving?
Avoid leaking current context into extracted context on default by using
ROOT_CONTEXT
as default for extract.Short description of the changes
If someone wants to extract something it's usually not wanted to leak existing information into the extracted result.
e.g. consider an incoming HTTP instrumentation extracting a W3C tag. if active context is used it may get the current active span instead that once extracted from W3C tag or undefined.
In general I would prefer to have no default at all for
context
but this would require to remove also the default argument forgetter
which is fine as it is.