envelop
envelop copied to clipboard
OpenTelemetry support propagation of trace
Description
I would like to have the ability to propagate a trace to another service. I am unable to find a way to propogate the trace as the opentelemetry context is not set
Ideally I would use something simple like opentelemetry.propagation.inject(api.context.active(), extensions);
but because the context is not set anywhere this will not work.
I have looked at implementing this as part of the plugin but cant see an obvious way as normally you would call something like:
opentelemetry.context.with(ctx, () => {
// wrapped function
})
But I don't think you can wrap another plugin as they are called one after another and seems its not achievable in envelope unless I am missing something.
An alternative approach
We could set the active context for opentelemetry into the graphql context and allow it to be accessed that way. e.g. adding a field
context[activeContext] = opentelemetry.trace.setSpan(opentelemetry.context.active(), context[tracingSpanSymbol]);
Then provide a getter from the opentelemetry package.