-
Notifications
You must be signed in to change notification settings - Fork 789
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
getCurrentSpan() returns undefined when a span is started #1228
Comments
I guess you didn't register a ContextManager, how did you configure the tracer exactly ? Could you show the full code used ? See this example |
Hi @vmarchaud, thanks for the quick response, it's very appreciated! I do call
If I pass
But it does not happen via the context. I suspect, but it's just a guess, that the child spans not linking to the parent (via the context) and Unless I am doing something completely wrong in the script. |
const parentSpan = tracer.startSpan('main');
tracer.withSpan(parentSpan, () => {
console.log(tracer.getCurrentSpan());
}); |
Ok, thanks guys! I'm going to close this. |
Does |
Co-authored-by: Rauno Viskus <Rauno56@users.noreply.github.com>
Please answer these questions before submitting a bug report.
What version of OpenTelemetry are you using?
What version of Node are you using?
v10.18.1
What did you do?
If possible, provide a recipe for reproducing the error.
getCurrentSpan()
returnsundefined
, even though the main span started on the previous line.What did you expect to see?
tracer.getCurrentSpan()
not returning undefined.What did you see instead?
undefined
Additional context
I've got quite a large codebase that I want to instrument with opentelemetry.
I'd like to avoid passing parent spans down the call stack explicitly because that would require me to change all function signatures.
I expected
const span = tracer.startSpan('name')
to inject the parent if not provided.Instead it seems like the only way for a span to be linked to its parent is
const span = tracer.startSpan('name', { parent })
.I tried
getCurrentSpan()
, but it's alwaysundefined
.Would be great if you could advise on how to proceed.
Thank you
The text was updated successfully, but these errors were encountered: