-
Notifications
You must be signed in to change notification settings - Fork 835
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
fix(plugin-express): fix double span end #908 #910
fix(plugin-express): fix double span end #908 #910
Conversation
Codecov Report
@@ Coverage Diff @@
## master #910 +/- ##
=======================================
Coverage 94.75% 94.75%
=======================================
Files 248 248
Lines 11288 11288
Branches 1079 1081 +2
=======================================
Hits 10696 10696
Misses 592 592
|
7c8ba66
to
c66756f
Compare
I don't have a super strong opinion on this fix, going to leave it to @open-telemetry/javascript-approvers to chime in. |
Does express expose a different async behavior than the standard http module? AFAIK the span should be ended before the followup callback is called anyways. Or |
Yes, because the express is implemented as a stack of function, each of them requiring to call the next with the
The issue is when the user code doesnt callback when it send the http response. |
2967c35
to
bd7bbdd
Compare
bd7bbdd
to
161afe2
Compare
@open-telemetry/javascript-approvers This one require some reviews please :) |
d8261b8
to
8fcbe22
Compare
@@ -45,6 +45,10 @@ const provider = new NodeTracerProvider(); | |||
|
|||
See [examples/express](/~https://github.com/open-telemetry/opentelemetry-js/tree/master/examples/express) for a short example. | |||
|
|||
### Caveats | |||
|
|||
Because of the way express works, it's hard to correctly compute the time took that each span took to complete. For this reason the time you'll see reported for each span will **not** represent the time it really took. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only for asynchronous spans
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't why but at some point i though that it wasn't possible for sync callback too so i'd removed the acurate reporting for all spans, but you are right. I've repushed the previous implementation that report accurate duration for sync middlewares
b8f94e0
to
cafbde7
Compare
a21d6db
to
aeb2ccd
Compare
aeb2ccd
to
cda4138
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
The "fix" is quite simple but i've added a big comments to explain what's happening inside express.
I've stated that it's would be quite memory consuming to listen for
end
event because we would keep the context alive for each middleware while waiting for the response to be sent. In this case we are only keep it for one tick which should be fine in terms of impact.What do you guys think ?