-
Hey guys, I have the following code, and I'm unsure why the active span is not returned. import { trace, context } from "@opentelemetry/api"
const tracer = trace.getTracer(name, version);
// Using this method to wrap.
function wrapper(name: string, fn: (...args) => any) : (...args) => any {
return async (...args) => {
const span = tracer.startSpan(name)
const ctx = trace.setSpan(context.active(), span);
const ret = await context.with(ctx, fn, undefined, ...args);
span.end();
return ret
};
}
app.on('message', wrapper('on_message', async (msg) => {
console.log(tracer.getSpan(context.active()) // HERE: prints undefined
})); Q. Even though I set the span on the root context, when I try retrieving it in the wrapped method, it returns an undefined span. Is it because the callback is async? I've tried with non-async callback as well and have received the same output. |
Beta Was this translation helpful? Give feedback.
Answered by
Flarna
Sep 14, 2021
Replies: 1 comment 1 reply
-
There is no SDK installed and as a result no real |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
altairmn
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
There is no SDK installed and as a result no real
ContextManager
. TheContextManager
included in the API is a Noop.see also open-telemetry/opentelemetry-js-api#23