kelvin-context-async-hooks
v0.12.2
Published
OpenTelemetry AsyncHooks-based Context Manager
Downloads
2
Maintainers
Readme
OpenTelemetry AsyncHooks-based Context Manager
This package provides async-hooks based context manager which is used internally by OpenTelemetry plugins to propagate specific context between function calls and async operations. It only targets NodeJS since async-hooks is only available there.
What is a ContextManager
The definition and why they exist is available on the readme of the context-base package.
Implementation in NodeJS
NodeJS has a specific API to track async context: async-hooks, it allows to track creation of new async operation and their respective parent. This package only handle storing a specific object for a given async hooks context.
Limitations
Even if the API is native to NodeJS, it doesn't cover all possible cases of context propagation but there is a big effort from the NodeJS team to fix those. That's why we generally advise to be on the latest LTS to benefit from performance and bug fixes.
There are known modules that break context propagation (some of them are listed there), so it's possible that the context manager doesn't work with them.
Prior arts
Context propagation is a big subject when talking about tracing in NodeJS, if you want more information about that here are some resources:
- https://www.npmjs.com/package/continuation-local-storage (which was the old way of doing context propagation)
- Datadog's own implementation for their Javascript tracer: here
- OpenTracing implementation: here
- Discussion about context propagation by the NodeJS diagnostics working group: here
Useful links
- For more information on OpenTelemetry, visit: https://opentelemetry.io/
- For more about OpenTelemetry JavaScript: https://github.com/open-telemetry/opentelemetry-js
- For help or feedback on this project, join us on gitter
License
Apache 2.0 - See LICENSE for more information.