Replies: 4 comments 9 replies
-
I, too, would like an alternative to Note this is precisely a non-answer. |
Beta Was this translation helpful? Give feedback.
-
Same need here, but for different reasons - neither Internally within our SDK we rely on explicit context passing in order to parent things correctly; however, that breaks down as soon as the consumer introduces any other instrumentations which are then not nested correctly. You might start a span, call setSpan to set it on a context, but there's no way to hand that context over to other instrumentation libraries which will likely use For our use-case it's not always possible to execute all the operations within a callback, thus we need some other way to set the active context for the remainder of the request. Since our ask is the same, albeit for different reasons, I thought it's better to tack onto this discussion. cc @lmolkova |
Beta Was this translation helpful? Give feedback.
-
We are considering adding |
Beta Was this translation helpful? Give feedback.
-
a quick update: we decided to use available callback-based APIs, so we don't depend on this feature. |
Beta Was this translation helpful? Give feedback.
-
Hi! I'm working with a group of folks to build out a web platform on top of Fastify.js that includes a collection of plugins to handle common functionality like logging, authentication, tracing, etc... We've adopted opentelemetry for tracing, and we have a use case where it would be nice for a plugin to be able to add additional entries to the otel baggage collection and have that extra baggage propagated on all outbound HTTP requests to other services.
The challenge we're running into is that Fastify executes its plugins in a non-nested fashion, which makes it impossible AFAICT for a plugin to do something like
api.context.with(newContextWithExtraBaggage, callback)
to push a new context on the stack such that it becomes the "active" context for the rest of the request - including both the execution of other plugins that are executed for the request and the route handler that ultimately responds to the request.I guess my first question: are we being dumb/naive in how we're attempting to go about this? I understand the desire for the context/baggage objects themselves to be immutable, but the inability to activate new contexts appears to prevent any non-nested control flows from decorating the context with additional stuff, e.g. baggage. FWIW, it seems like we may not be the first people to run into this issue:
One possible solution would be to allow apps to push/pop contexts on the stack such that they weren't required to use
context.with(..., callback)
to activate a new context. This would put a burden on the app to properly push/pop the contexts, but maybe that's not such a terrible thing given the additional flexibility?Beta Was this translation helpful? Give feedback.
All reactions