-
Notifications
You must be signed in to change notification settings - Fork 336
Tracing does not work with express #302
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
Comments
Could you describe the behavior you are experiencing? What do you mean by "Distributed Tracing does not seem to work"? Do you mean it doesn't work at all? Or does it work only partially? Also, what is the language of each service? (client + server) |
Could you share a snippet of how the tracer is instantiated, as well as express and redis? |
|
Is this tracer initialization done before Also, are you getting individual |
Yeah i am initializing the tracer before redis. It appears as a seperate service also showing a span for each redis command call. |
Could anyone help us on this? What are we doing wrong here? |
I see that one of the dependencies is The reason I'm asking is because Bluebird uses an internal queue that doesn't play well with context propagation. If this is the case, I can help to work around the issue until we improve support for Bluebird. |
No the request promise module is used to just make only one call to an external api. But the tracing info is not available for any requests that comes into server. I also suspect the redis module. I saw in some other forum that redis module doesnot play well with async context propagation |
Please do also let me know the work around i will try and see if that fixes the issue. |
The workaround would basically be to reactivate the correct scope before the Redis call. For example it's possible to grab the current span at the beginning of the route handler: const span = tracer.scopeManager().active() And then reactivate it just before sending a Redis command tracer.scopeManager().activate(span) Of course this is not ideal, and you would have to propagate that span manually. What you are experiencing however should never happen, and if you can pinpoint where the context is lost, I'll take a look as to how we can prevent that. One way to find the source of the problem is to debug and put a watch on the above snippet to check that the scope is still active. When the watcher returns |
I just tried the above solution and found out that the span context is being lost during express body parser. I also tried getting the context and activating the span later but i am getting the following error Error: Expected [object Object] to be an instance of SpanContext. So I took the span out and set it to the request object as well as the response.locals object and tried access it post the json parser middleware. The span context is still an object, but when i set it back as activate it throws the above during the subsequent call to redis. Edit : const span = tracer.scopeManager().active().span(); let getContext = ( req , res , next ) => { so i added getcontext and attachcontext before and after json parser which fixed the problem now and i can see the traces. Thank you for your time. It would be really good if there is a guide on how to run the agent v6 in elasticbeanstalk. Instructions here https://www.datadoghq.com/blog/deploy-datadog-aws-elastic-beanstalk/ work only for v5. |
This was a problem in the past, but should no longer happen in newer versions since we reactivate the span in every middleware similar to what you did: dd-trace-js/src/plugins/express.js Line 97 in 27c00ff
dd-trace-js/src/plugins/util/web.js Lines 60 to 64 in 27c00ff
Can you make sure that the version actually installed is really 0.6.0? If you can confirm this is the case, then can you provide a minimal snippet to reproduce the problem? (i.e. just a small express app with a health check that logs the current span to show it's not available). Then I'll use this to reproduce on my end since for me it works with
If you are using Docker, take a look at https://docs.datadoghq.com/integrations/amazon_elasticbeanstalk/ If you are deploying directly to EC2s, take a look at https://wimdeblauwe.wordpress.com/2018/07/06/datadog-integration-with-aws-elastic-beanstalk-for-spring-boot-application/ |
I just made sure that the version installed is 0.6.0 and it still doesn't work without the fix. I will also make a sample app as you requested to demonstrate the issue. The instructions provided for agent installation has a big problem in it. Now when i pushing a guage metric to datadog. it does not sum up the values from the processes, resulting in a mismatch. For Example : I have around 1.8k websockets connected in average to each process( 7.2k connections in total ). But as the graph shows its just 3.6k in total. My guess is that it misses to aggregate the values submitted on the process level. |
Are these custom metrics or metrics from one of our integrations? In any case it would probably be best to either open an issue in our agent repo or open a ticket with support. |
Hi! I'm using superagent (https://www.npmjs.com/package/superagent) to perform a http call, and I'm having the same issue as described here. Any clues on how to fix it? |
@ignaciocavina Could you clarify which of the issues mentioned above? What is the expected behavior in your case, and what are you seeing instead? |
Yes, sure...
We are basically "loosing context".
Our express request span does not show as "connected" to our http client
span on the datadog ui, which is what we'd expect.
I turned on debug and got an error saying that a span was expected but got
null. And effectively, the http client is not getting the parent span.
I did debug the trace and could verify that there is an active span until
the very first inner parts of superagent, but then it is lost.
I could give you more pointers to where that happens, if needed.
Thanks in advance!
Ignacio
…On Mon, Aug 5, 2019, 5:37 PM Roch Devost ***@***.***> wrote:
@ignaciocavina <https://github.com/ignaciocavina> Could you clarify which
of the issues mentioned above? What is the expected behavior in your case,
and what are you seeing instead?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#302?email_source=notifications&email_token=AAWVZ6DTQWYYNZOIFJWDLELQDCFO3A5CNFSM4FY7F2ZKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD3S77WI#issuecomment-518389721>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAWVZ6DH4NT4BLILSJP7WELQDCFO3ANCNFSM4FY7F2ZA>
.
--
The information contained in this e-mail may be confidential. It has been
sent for the sole use of the intended recipient(s). If the reader of this
message is not an intended recipient, you are hereby notified that any
unauthorized review, use, disclosure, dissemination, distribution or
copying of this communication, or any of its contents, is strictly
prohibited. If you have received it by mistake please let us know by e-mail
immediately and delete it from your system. Many thanks.
La información
contenida en este mensaje puede ser confidencial. Ha sido enviada para el
uso exclusivo del destinatario(s) previsto. Si el lector de este mensaje no
fuera el destinatario previsto, por el presente queda Ud. notificado que
cualquier lectura, uso, publicación, diseminación, distribución o copiado
de esta comunicación o su contenido está estrictamente prohibido. En caso
de que Ud. hubiera recibido este mensaje por error le agradeceremos
notificarnos por e-mail inmediatamente y eliminarlo de su sistema. Muchas
gracias.
|
This error has been fixed in 0.14.0
It's possible there is some incompatibility with
If you can pinpoint exactly where the scope is lost within the library, that would be very helpful. |
On Tue, Aug 6, 2019 at 11:13 AM Roch Devost ***@***.***> wrote:
I turned on debug and got an error saying that a span was expected but got
null.
This error has been fixed in 0.14.0
I tried the 0.14.0 version but still get this:
[2019-08-06 15:08:43.806] [ERROR] Expected null to be an instance of
SpanContext
error:
name: Error
message: Expected null to be an instance of SpanContext
stack: Error: Expected null to be an instance of SpanContext
I did debug the trace and could verify that there is an active span until
the very first inner parts of superagent, but then it is lost.
It's possible there is some incompatibility with superagent. I'll have to
look into it as it may require a new plugin to be added to explicitly
support it. This has happened for several other libraries that were not
correctly propagating their internal scope using AsyncResource.
I could give you more pointers to where that happens, if needed.
If you can pinpoint exactly where the scope is lost within the library,
that would be very helpful.
Yes:
https://github.com/visionmedia/superagent/blob/master/src/node/index.js#L33
until that line scope is OK
Form there it, directly calls here by means of new:
https://github.com/visionmedia/superagent/blob/master/src/node/index.js#L151
No scope
… —
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#302?email_source=notifications&email_token=AAWVZ6A2OY7DXAD2VTCCZ4LQDGBH3A5CNFSM4FY7F2ZKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD3VIUIA#issuecomment-518687264>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAWVZ6EHXDXNDEUG36CF2KLQDGBH3ANCNFSM4FY7F2ZA>
.
--
*Ignacio Cavina* | Tech Master
*GLOBANT* | AR: +54 11 4109 1700 ext. 17511 | US: +1 877 215 5230 ext. 17511
|
[image: Facebook]
<http://globant.us4.list-manage1.com/track/click?u=5831a121b939d20e0735e21a1&id=b3661fedb8&e=b73a1bec72>
[image: Twitter]
<http://globant.us4.list-manage1.com/track/click?u=5831a121b939d20e0735e21a1&id=9a38a160e0&e=b73a1bec72>
[image: Youtube]
<http://globant.us4.list-manage2.com/track/click?u=5831a121b939d20e0735e21a1&id=2fcecb22a2&e=b73a1bec72>
[image: Linkedin]
<http://globant.us4.list-manage.com/track/click?u=5831a121b939d20e0735e21a1&id=9419b0d7e6&e=b73a1bec72>
[image: Pinterest]
<http://globant.us4.list-manage.com/track/click?u=5831a121b939d20e0735e21a1&id=4de8e506ce&e=b73a1bec72>
[image: Globant]
<http://globant.us4.list-manage2.com/track/click?u=5831a121b939d20e0735e21a1&id=d7879e1724&e=b73a1bec72>
--
The information contained in this e-mail may be confidential. It has been
sent for the sole use of the intended recipient(s). If the reader of this
message is not an intended recipient, you are hereby notified that any
unauthorized review, use, disclosure, dissemination, distribution or
copying of this communication, or any of its contents, is strictly
prohibited. If you have received it by mistake please let us know by e-mail
immediately and delete it from your system. Many thanks.
La información
contenida en este mensaje puede ser confidencial. Ha sido enviada para el
uso exclusivo del destinatario(s) previsto. Si el lector de este mensaje no
fuera el destinatario previsto, por el presente queda Ud. notificado que
cualquier lectura, uso, publicación, diseminación, distribución o copiado
de esta comunicación o su contenido está estrictamente prohibido. En caso
de que Ud. hubiera recibido este mensaje por error le agradeceremos
notificarnos por e-mail inmediatamente y eliminarlo de su sistema. Muchas
gracias.
|
Thanks for the additional information, I'll look into it. About the error, this is very odd as there is now a check on the presence of the span context, which |
That seems to be OK. I don't have an error that breaks my code, I just see
the error log... It seems correct that the http client span expects to be
within a context...
…On Wed, Aug 7, 2019 at 4:57 PM Roch Devost ***@***.***> wrote:
Thanks for the additional information, I'll look into it.
About the error, this is very odd as there is now a check on the presence
of the span context, which null and undefined won't pass. I wonder if
something is causing the span context to actually be the null string and
not actually null? See
https://github.com/DataDog/dd-trace-js/pull/639/files
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#302?email_source=notifications&email_token=AAWVZ6CGBVFKCQQGZ4KVJHDQDMSJTA5CNFSM4FY7F2ZKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD3ZRDUA#issuecomment-519246288>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAWVZ6ACFG7AG2H2MT4DU4TQDMSJTANCNFSM4FY7F2ZA>
.
--
*Ignacio Cavina* | Tech Master
*GLOBANT* | AR: +54 11 4109 1700 ext. 17511 | US: +1 877 215 5230 ext. 17511
|
[image: Facebook]
<http://globant.us4.list-manage1.com/track/click?u=5831a121b939d20e0735e21a1&id=b3661fedb8&e=b73a1bec72>
[image: Twitter]
<http://globant.us4.list-manage1.com/track/click?u=5831a121b939d20e0735e21a1&id=9a38a160e0&e=b73a1bec72>
[image: Youtube]
<http://globant.us4.list-manage2.com/track/click?u=5831a121b939d20e0735e21a1&id=2fcecb22a2&e=b73a1bec72>
[image: Linkedin]
<http://globant.us4.list-manage.com/track/click?u=5831a121b939d20e0735e21a1&id=9419b0d7e6&e=b73a1bec72>
[image: Pinterest]
<http://globant.us4.list-manage.com/track/click?u=5831a121b939d20e0735e21a1&id=4de8e506ce&e=b73a1bec72>
[image: Globant]
<http://globant.us4.list-manage2.com/track/click?u=5831a121b939d20e0735e21a1&id=d7879e1724&e=b73a1bec72>
--
The information contained in this e-mail may be confidential. It has been
sent for the sole use of the intended recipient(s). If the reader of this
message is not an intended recipient, you are hereby notified that any
unauthorized review, use, disclosure, dissemination, distribution or
copying of this communication, or any of its contents, is strictly
prohibited. If you have received it by mistake please let us know by e-mail
immediately and delete it from your system. Many thanks.
La información
contenida en este mensaje puede ser confidencial. Ha sido enviada para el
uso exclusivo del destinatario(s) previsto. Si el lector de este mensaje no
fuera el destinatario previsto, por el presente queda Ud. notificado que
cualquier lectura, uso, publicación, diseminación, distribución o copiado
de esta comunicación o su contenido está estrictamente prohibido. En caso
de que Ud. hubiera recibido este mensaje por error le agradeceremos
notificarnos por e-mail inmediatamente y eliminarlo de su sistema. Muchas
gracias.
|
@ignaciocavina I am unable to reproduce locally. Can you provide a minimal snippet that I could use to replicate the behavior? |
Hi! I've put together a repo sample:
https://github.com/ignaciocavina/atest-dd-trace-superagent
Please let me know if that works for you. Thanks!
…On Fri, Aug 9, 2019 at 12:55 PM Roch Devost ***@***.***> wrote:
@ignaciocavina <https://github.com/ignaciocavina> I am unable to
reproduce locally. Can you provide a minimal snippet that I could use to
replicate the behavior?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#302?email_source=notifications&email_token=AAWVZ6BCUA4JMP43SJE67ELQDWHPDA5CNFSM4FY7F2ZKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD37CF2Q#issuecomment-519971562>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAWVZ6HC76ANQUYX4LLUX2TQDWHPDANCNFSM4FY7F2ZA>
.
--
*Ignacio Cavina* | Tech Master
*GLOBANT* | AR: +54 11 4109 1700 ext. 17511 | US: +1 877 215 5230 ext. 17511
|
[image: Facebook]
<http://globant.us4.list-manage1.com/track/click?u=5831a121b939d20e0735e21a1&id=b3661fedb8&e=b73a1bec72>
[image: Twitter]
<http://globant.us4.list-manage1.com/track/click?u=5831a121b939d20e0735e21a1&id=9a38a160e0&e=b73a1bec72>
[image: Youtube]
<http://globant.us4.list-manage2.com/track/click?u=5831a121b939d20e0735e21a1&id=2fcecb22a2&e=b73a1bec72>
[image: Linkedin]
<http://globant.us4.list-manage.com/track/click?u=5831a121b939d20e0735e21a1&id=9419b0d7e6&e=b73a1bec72>
[image: Pinterest]
<http://globant.us4.list-manage.com/track/click?u=5831a121b939d20e0735e21a1&id=4de8e506ce&e=b73a1bec72>
[image: Globant]
<http://globant.us4.list-manage2.com/track/click?u=5831a121b939d20e0735e21a1&id=d7879e1724&e=b73a1bec72>
--
The information contained in this e-mail may be confidential. It has been
sent for the sole use of the intended recipient(s). If the reader of this
message is not an intended recipient, you are hereby notified that any
unauthorized review, use, disclosure, dissemination, distribution or
copying of this communication, or any of its contents, is strictly
prohibited. If you have received it by mistake please let us know by e-mail
immediately and delete it from your system. Many thanks.
La información
contenida en este mensaje puede ser confidencial. Ha sido enviada para el
uso exclusivo del destinatario(s) previsto. Si el lector de este mensaje no
fuera el destinatario previsto, por el presente queda Ud. notificado que
cualquier lectura, uso, publicación, diseminación, distribución o copiado
de esta comunicación o su contenido está estrictamente prohibido. En caso
de que Ud. hubiera recibido este mensaje por error le agradeceremos
notificarnos por e-mail inmediatamente y eliminarlo de su sistema. Muchas
gracias.
|
@ignaciocavina The issue is that A possible workaround is to call I'm working on an experimental workaround directly from within the tracer, but it does come with a performance cost, so there is a tradeoff to use it. I'll update the thread when it's released. |
Thanks a lot @rochdev ! |
@ignaciocavina Let's continue the discussion in #654 since it's unrelated to the original issue of this thread. |
@prashanth007 - are you still having this issue? Closing for now but please feel free to open a support ticket and we can investigate further. |
Thenables are now supported properly out of the box in Node >=12.18.3 or >=14.5.0. |
Uh oh!
There was an error while loading. Please reload this page.
Distributed Tracing does not seem to work with Express and Redis. I also use UWS for websocket support.
The following are my dependencies.
"dependencies": {
"body-parser": "^1.18.2",
"express": "^4.16.2",
"log4js": "^2.3.7",
"nodemailer": "^4.3.0",
"redis": "^2.8.0",
"request": "^2.83.0",
"request-promise": "^4.2.2",
"retry": "^0.10.1",
"uws": "^9.14.0",
"valid-url": "^1.0.9"
}
Our app runs in AWS Elastic Beanstalk
Nodejs version : 8.11.3
dd-trace-js version : 0.60.0
Instructions that i followed to install Datadog in Elasticbeanstalk
https://www.datadoghq.com/blog/deploy-datadog-aws-elastic-beanstalk/
The text was updated successfully, but these errors were encountered: