-
Notifications
You must be signed in to change notification settings - Fork 309
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
aws-sdk sqs does not extract trace info when using promises #1680
Comments
This is a known issue that is unfortunately a limitation of Node support for promises. Without going into too much details, it binds the context of This is something we do plan to support, and this work has already started with nodejs/node#39283, but it will still require a few more changes to Node itself, and then we'll have to implement the changes in our scope manager before it can finally land in the |
When using `.promise()` there is no callback for `dd-trace-js` to wrap. Before this change, that meant we never called tracer.extract on any incoming requests. This changes the functionality by creating a "fake" callback for us to wrap and then immediately calling it. Fixes DataDog#1680
@rochdev Hmm, I don't know if we're on the same page. I just opened up #1682 . I first added a failing test, then I was able to get it to pass. I think this is less to do with V8 and more to do with the fact that certain code paths are currently not being called. That said, I could still be completely misunderstanding. |
The test case focuses on a very specific usage of the library and doesn't address other patterns (for example However, I took a quick look at Please let me know if this is something you want to try to implement and I can help if needed. |
I just realized that the tests in #1682 don't verify if the context was propagated properly, so I should probably provide more background as to why this doesn't work. Basically, on the consumer side, the instrumentation needs to be able to link with the following other spans to provide distributed tracing:
With the callback approach this is easy since all that is needed is to wrap the callback to make sure the message span is on the current scope, which will then be automatically propagated by dd-trace to child spans. However, for promises, every promise created using Supporting promises will be a lot of work and will require several changes to Node itself and to dd-trace, so it's definitely not a small task. However, since for your case all that is needed is a |
I get it now. Thank you so much for the explanation! Relatedly, I think we may have been bit by something similar when I tried contributing to the opentelemetry-js-contrib package. I'll open a new PR to try to patch the sqs-consumer package using |
@uptownhr Not a sample per se, but from a quick look at the library it looks like |
@leoncider Been wanting to work on this for a while but haven't had the time. We're going to try to land support for aws-sdk v3 soon, I'll try to see if I can add support for this as well at the same time. |
@rochdev Has there been any progress on this (or #1682)? Currently we receive no traces for any endpoint that calls a Is there anyway we can temporarily fork the aws-sdk plugin locally, add the fix from @ekosz and get Alternatively, is there some way we can skip generating spans involving aws-sdk and |
@ixalon If you are not using async/await it should be possible to instrument the call manually. If you are using async/await you might not be able to bind the asynchronous context properly unless the span is created in a wrapper. Unfortunately this is not something we can solve in the auto-instrumentation without changes to Node and to our data model.
Custom plugins are not supported right now, but it should be possible to manually instrument individual calls or use a wrapper to handle the tracing. |
Thanks for the quick response @rochdev. Unfortunately the library we rely heavily on uses |
@rochdev I had a good attempt at working around this issue within the traced application itself - I could get no combination of I'm not sure if there genuinely is an issue with |
Hi @rochdev, unfortunately sticking with Do you think #2099 may fix the issue we're seeing above? If so, when can we expect a release? 🙏 Edit: I can confirm #2099 fixes the issue we were having with traces involving AWS calls going missing. Many thanks @rochdev! |
any update on this? We also use sqs-consumer and would love to have our traces working with it :) |
+1 to this. I would love to know whether this feature is being prioritized and whether there are any workarounds we can use in the meantime. All our services communicate using SQS queues and |
Any update on this? We are facing a similar issue. We use promises as well for |
At Lattice, we've been having issues with DD distributed traces and AWS SQS. Even though we see all of the
aws.request
spans created, none of them are connected to parent spans or the trace that created them in the first place. Finally after some digging / tracing I think I may know what it is.We use
sqs-consumer
for managing our SQS queues. Looking the SQS dd-trace-js code, the extraction of the trace info happens atresponseExtract
. And that is ever called fromwrapCb
. And that is only called when there is a callback to wrap. Butsqs-consumer
uses the.promise()
style of making requests to AWS. Which, as far as I can tell, makes it so thecb
isundefined
and makes it so we never callresponseExtract
.Do you think I got that right? And if so do you know of another library that has this pattern that I could try and copy from to open a PR to fix?
Cheers!
Eric
The text was updated successfully, but these errors were encountered: