Skip to content
This repository has been archived by the owner on May 5, 2022. It is now read-only.

propagate tracer for async code #44

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

neeraj-laad
Copy link

There is an underlying issue with using zipkin-context-cls. There are open PRs that claim to resolve this but they are not merged and pulling the change locally did not work for me.

  • Added a namespace to store tracer
  • Used async_hooks to propagate tracer for async blocks
  • storing tracer in incoming request and fetching it later in the process for outbound requests

resolves #43
resolves #40

Tests pass locally on Mac.

lib/namespace.js Outdated
@@ -0,0 +1,31 @@
'use strict';

const asyncHooks = require('async_hooks');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

async_hooks was only added to core in Node 8 and above. This is going to cause issues on Node 6

@neeraj-laad
Copy link
Author

@gdams I have added conditionals to use async_hooks only for node 8 and above.. So the problem will be resolved for node 8 and above... but will still exist for node 6.

The tests pass on node 6, 8, current(10).

I guess this is not a breaking change now, but only fixes it on certain versions

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
2 participants