-
I'm trying to write some instrumentation for various websocket libraries for node.js, and struggling to figure out when Thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
|
Beta Was this translation helpful? Give feedback.
context.bind
is similar tofunction.bind
, it's used to manually set the opentelemetry context (where as thefunction.bind
is used to set thethis
context) that will be used within the function that are you calling. It also handle binding to event emitters where the given context will be the one used for every.emit
.Also
context.bind
allows not to set a specific context in which case the current context will be manually set.I would say that you generally don't need to do this because with newer nodejs version there is not much context loss left (which case the case before), async hooks/async local storage now generaly handle this for you.