-
Notifications
You must be signed in to change notification settings - Fork 821
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
getExtractedSpanContext does not return correct result with multiple versions of @opentelemetry/core are installed #1379
Comments
Thanks for reporting this issue. Seems related to the issue #1370 reported earlier. I can think of a few ways to fix this:
@obecny @mayurkale22 do you have opinions on this? |
it's the same problem I reported and described here -> #1370. |
Just made a PR to release contrib, but this issue will still exist. API does not have this issue since it uses the global utils to ensure a single global API instance is used, even if multiple api instances of varying versions exist in the node_modules structure. |
I agree, option 1 is also the option with the least impact. (no api or behavior change) |
If |
@obecny the current Symbol text is 'OpenTelemetry Context Key EXTRACTED_SPAN_CONTEXT', which already contains few prefixes, and is only used as a key on the Context object. I believe runtime-wide name collisions are not relevant in this case. I prefer option 1 as it is simple, but moving the symbols to API package is also fine. Do you want to take this issue and create a PR? I can also do it myself |
There is some discussion in the spec about requiring the API package to propagate baggage/correlations by default, because end-user applications will depend on it for behavior so it cannot be no-op. Because of this, the API will need to access context properties. This leads me to think we should move the context symbols into the API package anyways, which solves this issue without introducing the runtime-wide WDYT |
There will still be export const GLOBAL_CONTEXT_MANAGER_API_KEY = Symbol.for(
'io.opentelemetry.js.api.context'
);
export const GLOBAL_METRICS_API_KEY = Symbol.for(
'io.opentelemetry.js.api.metrics'
);
export const GLOBAL_PROPAGATION_API_KEY = Symbol.for(
'io.opentelemetry.js.api.propagation'
);
export const GLOBAL_TRACE_API_KEY = Symbol.for('io.opentelemetry.js.api.trace'); |
Actually after looking into it a little more, createKey doesn't need to be moved into the API, just called by the API.
No. The spec states that context keys are generated by calling an API, and that calling the API twice never returns the same key, even if it is called with the same input. I am proposing that the |
I will open a PR to illustrate |
In trying to open this PR, it is becoming much more complex than I thought. In the spec, the wording is this:
I think we have such a language restriction that will allow us to have an exception here. By far the simplest way to solve this problem is to use Symbol.for |
What is the intention? |
The intention is to make it impossible for keys to collide. I guess some languages use context propagation mechanisms that are well-known and used by many other things. |
Not sure I fully understand, but I'm in favor of the |
Just adding to this: the fix implemented here also affects the other methods in the global context api: |
Please answer these questions before submitting a bug report.
What version of OpenTelemetry are you using?
My tracer is v0.9.0, and a plugin is using v0.8.3
What version of Node are you using?
v13.11.0
What did you do?
My project has a tracer with v0.9.0, and is using a plugin with v0.8.3.
propagation.extract(...)
, under the hood, this operation calls_getGlobalPropagator
which return the v0.9.0 propagator which then calls thesetExtractedSpanContext
v.0.9.0 function.getExtractedSpanContext
function on the Context from 1, which uses the v0.8.3 version.What did you expect to see?
I expected the
getExtractedSpanContext
function to return theextractedSpanContext
which is set on theContext
What did you see instead?
The function falsly returns
undefined
.Additional context
I think the issue is that Context.createKey is creating a regular
Symbol
, which means that every version in node_modules will have a unique symbol for that version, instead of creating it globally withSymbol.for()
, like hereThe text was updated successfully, but these errors were encountered: