-
Notifications
You must be signed in to change notification settings - Fork 32
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Child traces not associated with correct parent #9
Comments
@bryanlarsen do you have an idea why? I mean did you collect more information about this issue in the meantime? |
No, I just dismissed opentracing-auto as broken by design. The problem is trivial to reproduce with simultaneous requests to your example. It'd require some pretty cool magic for the mongo wrapper to know which http request triggered the mongo call if there is more than one http request outstanding. I'd love to get some of that magic if there is some, but it looks like your code is fairly straightforward, not magical. |
The "magic" is called continuation-local-storage and maybe there is a bug in this library but it is possible. |
That is pretty magical! Thanks for the pointer. A quick googling indicates that this isn't an uncommon occurrence, a good explanation is in the bottom section of https://datahero.com/blog/2014/05/22/node-js-preserving-data-across-async-callbacks/ The first thing I would suspect would be the mongodb connection pool -- the mongodb connection would have been created on the first request and reused for the second request, so it uses the local storage of the first request. Just a guess, though, could be something else. Something like https://github.com/tylerchr/cls-porqpine is probably needed in the example code. I'll try and setup my test environment and try and get you either a PR or a better request. Won't be able to get to it today, though. |
You are right, we cannot track absolutely everything. In the meantime, I replaced the Relased to |
@bryanlarsen any updates on #9 (comment)? |
Looks like cls-hooked doesn't really improve things. I experimented by augmenting with async-local-storage to squirrel away the root context (if one existed). I could also just verify there isn't a root-context in the stack, but that could give me the wrong root context on a busy server. The challenge is to connect a pooled connection created with an earlier context to the present one. |
I added a 5 second delay to the server1 example in jaeger-node, and then did a few simultaneous requests. All child spans showed up as children of the first request, no child spans were associated with the subsequent requests.
The text was updated successfully, but these errors were encountered: