You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
which support plan is this issue covered by? (e.g. Community, Core, Plus, or Enterprise): Community
is this issue currently blocking your project? (yes/no): yes
is this issue affecting a production system? (yes/no): yes
Context
node version: 12
module version: 17+
environment (e.g. node, browser, native): node
used with (e.g. hapi application, another framework, standalone, ...): hapi application
any other relevant information: this is for supporting a library
How can we help?
Currently we have an issue with hapi instrumentation when using promises. Usual instrumentation is based on middlewares and that allows us to wrap the next handlers with a scope. Hapi has a different model based on listeners.
This means that everything in next() happens scoped. In hapi case, we subscribe to events onRequest, onPreHandler, onPreResponse but we can't actually wrap within a scope what happens in the handler (or pre handler). This code won't work for example:
server.route({method: 'GET',path: '/',config: {pre: [{method: (req)=>{returntracer.scoped(function(){tracer.setId(req._trace_id)// restore the scopereturndoCall()})},assign: 'users',},
Is there any way we can wrap handler and pre-handlers without asking the user to specifically wrap the functions? If now, what is the recommended practice, should we extend Hapi server class and override the server.route method to do this wrapping?
@jcchavezs Looks like you're right, I read the comment in hapiMiddleware.js assuming it does something which it doesn't. I guess the comment isn't really valid, sent a PR to remove it to prevent confusion.
Support plan
Context
How can we help?
Currently we have an issue with hapi instrumentation when using promises. Usual instrumentation is based on middlewares and that allows us to wrap the next handlers with a scope. Hapi has a different model based on listeners.
In express for example, one might do:
This means that everything in
next()
happens scoped. In hapi case, we subscribe to eventsonRequest
,onPreHandler
,onPreResponse
but we can't actually wrap within a scope what happens in the handler (or pre handler). This code won't work for example:whereas this one will do the trick:
Is there any way we can wrap
handler
andpre-handler
s without asking the user to specifically wrap the functions? If now, what is the recommended practice, should we extend Hapi server class and override theserver.route
method to do this wrapping?For better context, this is the original issue in zipkin: openzipkin/zipkin-js#483 (comment)
The text was updated successfully, but these errors were encountered: