-
Notifications
You must be signed in to change notification settings - Fork 807
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
Trace Ids and span parent Ids are getting messed up on concurrent request of around 20 (rest based services) #1646
Comments
I'm not familiar with app insights. I assume tenant id and correlation id are app insights concepts? The code here looks correct at first pass. Are you sure this is not a problem with app insights? The response header use is not standardized. Can you link to the documentation for it? |
@dyladan please ignore the code around tenant id and correlation id, its in house concepts we have. What I am reporting here is, for all spans corresponding to 2nd HTTP request and till 20th HTTP request, the parent id is linked to the first HTTP request trace id. This is evident from ConsoleSpanExporter where I can see parent ids and span ids etc. So its not problem from azure app insights exporter. The reason I shared the middleware code is to show how I am grabbing the trace id for each HTTP request I am making. I am spitting it as response header. |
So, if you make multiple concurrent requests they all have the same root span? If you wait for those requests to finish then make a new request, does the root span change to the new request? |
@dyladan yes, all spans of 2nd to 20th HTTP request doesn't have corresponding parent ids to their own trace id. Instead parent id is referred to trace id of first HTTP request. If I do not make concurrent request and do separate HTTP request then all things are good. Correct trace id as parent id for span |
hmm this sounds like a context leak to me. @vmarchaud do you have any ideas? |
Yeah it sounds like a leak, could you share the list of dependencies that you use @sureshballa ? Also that would help you if you'd have a mininal code example that reproduce the issue. |
Minimal reproduction would be a big help. Maybe also disable all plugins except http/https and see if the issue persists. Then enable 1 by 1 until you find the plugin which causes the issue. |
No response in 2 years. I'm going to close this. Please reopen if you can provide more information. |
* chore(deps): update dependency semver to v7.5.4 * chore(deps): align semver versions across repo * chore(deps): pin semver version v7.5.4
This issue still persists, @dyladan. The dependencies that I'm using are listed below: "@opentelemetry/api": "^1.9.0",
const { OTLPTraceExporter } = require('@opentelemetry/exporter-trace-otlp-http'); const provider = new NodeTracerProvider(); provider.register({ registerInstrumentations({ |
Can you reopen this issue and push a fix for it? When multiple api calls from UI reach our server at almost similar time, this issue is occurring. We are running a react application which make call to this node express server. |
We still need a reproducer for this |
Hi @dyladan, Thanks for the quick response. Actually, the issue is not with the trace provider library. It was with the incorrect configuration of logging library (logging-winston). Old code: registerInstrumentations({ Corrected code: registerInstrumentations({ |
In the below log added, the trace id added by instrumentation in metadata is different from the actual trace id. Old log entry: |
Does that mean this is resolved? |
Yes, this is resolved. Thanks a lot !! |
Please answer these questions before submitting a bug report.
What version of OpenTelemetry are you using?
"@opentelemetry/api": "^0.11.0",
"@opentelemetry/exporter-prometheus": "^0.11.0",
"@opentelemetry/metrics": "^0.11.0",
"@opentelemetry/node": "^0.11.0",
"@opentelemetry/plugin-express": "^0.10.0",
"@opentelemetry/plugin-http": "^0.11.0",
"@opentelemetry/plugin-mongodb": "^0.10.0",
"@opentelemetry/semantic-conventions": "^0.11.0",
"@opentelemetry/tracing": "^0.11.0",
What version of Node are you using?
10.21.0
Please provide the code you used to setup the OpenTelemetry SDK
What did you do?
Our microservices are exposed with REST protocol. We are emitting the trace id as response header for each API request (though trace id is not available as typed property, but I am using this code to get the value - spanContext.traceId.
Based on this response header, I am looking in backend app insights portal to look for all things happening for this specific trace id. This all works good if I send a single http request, and search the app insights with trace id. But if I send concurrent requests of say 20, then things are getting messed up. All the actions related to 2nd request till 20th request are getting related to 1st request trace id. So from app insights it looks like 1st request is handling
To confirm this is not issue with azure app insights exporter, I have enabled ConsoleSpanProcessor and I can see parent id are wrongly linked to other trace id. To be precise, all the span ids for 2nd request to 20th request, the parent ids are set to trace id of the very first request.
Below is the express middleware I am using to send back the trace id so that I can use to trace all things:
The text was updated successfully, but these errors were encountered: