Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

zipkin-context-cls

Package Overview
Dependencies
Maintainers
1
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

zipkin-context-cls

A Context API implementation that uses continuation-local-storage under the hood

  • 0.18.5
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
4.4K
decreased by-46.58%
Maintainers
1
Weekly downloads
 
Created
Source

zipkin-context-cls

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.

Usage:

const CLSContext = require('zipkin-context-cls');
const tracer = new Tracer({
  ctxImpl: new CLSContext('zipkin'),
  recorder, // typically Kafka or Scribe
  localServiceName: 'service-a' // name of this application
});

A note on CLS context vs. explicit context

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.

A note on CLS context and Promises

This package is not suitable if your code inside the context uses promises. The context is then not properly propagated. There is work underway called async_hooks, but is at the time of this writing (node v10) in Experimental state.

A note on the workings of CLS context

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.

Troubleshooting

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

Package last updated on 12 Jul 2019

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc