Security News
UK Officials Consider Banning Ransomware Payments from Public Entities
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.
zipkin-context-cls
Advanced tools
A Context API implementation that uses continuation-local-storage under the hood
This module implements a context API on top of CLS/continuation-local-storage.
The primary objective of CLS is to implement a transparent context API, that is, you don't need to pass around a ctx
variable everywhere in your application code.
const CLSContext = require('zipkin-context-cls');
const tracer = new Tracer({
ctxImpl: new CLSContext('zipkin'),
recorder, // typically HTTP or Kafka
localServiceName: 'service-a' // name of this application
});
There are known issues and limitations with CLS, so some people might prefer to use ExplicitContext
instead;
the drawback then is that you have to pass around a context object manually.
By default, this package is not suitable if your code inside the context uses promises, however you can enable an experimental feature for async/await support by using cls_hooked library which underneath uses async_hooks.
const CLSContext = require('zipkin-context-cls');
const tracer = new Tracer({
ctxImpl: new CLSContext('zipkin', true),
recorder,
localServiceName: 'service-a'
});
At the time of this writing, async_hooks
have some performance implications whose effect may vary depending on the node version.
The underneath implementation for async_hooks may change, that is why we hide that with the opt-in parameter.
The package will create a namespace called 'zipkin' by default, if it does not exist yet. In this namespace the code sets the context with the key 'zipkin'. This does not mean that the context is overwritten at every request. The namespace is tied to the call-chain. Data stored within that namespace is unique to that request and namespace. For reference see: here.
If you are using the Express
framework with CLSContext
, the body-parser
middleware may interfere and lose the context. To prevent that, make sure that the body-parser
middleware is registered before zipkin
in the middleware chain. If you are not explicitly registering body-parser
, please do so by adding app.use(bodyParser.json());
above the Zipkin middleware registration line.
FAQs
A Context API implementation that uses continuation-local-storage under the hood
The npm package zipkin-context-cls receives a total of 6,757 weekly downloads. As such, zipkin-context-cls popularity was classified as popular.
We found that zipkin-context-cls demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.
Security News
Snyk's use of malicious npm packages for research raises ethical concerns, highlighting risks in public deployment, data exfiltration, and unauthorized testing.
Research
Security News
Socket researchers found several malicious npm packages typosquatting Chalk and Chokidar, targeting Node.js developers with kill switches and data theft.