-
Notifications
You must be signed in to change notification settings - Fork 279
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
[Instrumentation.AspNet] Fix activity being closed before processing completes #1388
Conversation
@qhris, please sign CLA, it is hard requirement to proceed with PR. Please let us know if you have any issue with the procedure. |
@Kielek I had missed the CLA requirement as I submitted the PR. I have no idea how that works so I'll look it over tomorrow since I wasn't prepared having to sign something with my physical address... In regards to the changes: Something that struck me is that this will be a breaking change as it changes the order of the processor's |
Did some additional testing this morning comparing the flow to a .NET 7 application. I used In the .NET 7 application we have the following flow:
The .NET Framework application (pre-patch) has the following behavior:
This PR would bring the implementations in line between .NET and .NET Framework by swapping items 6 and 7 for .NET Framework. |
67cdb50
to
488d2ac
Compare
The ASP.NET Core behavior is correct and this fix for asp.net is correct! Thanks. |
src/OpenTelemetry.Instrumentation.AspNet.TelemetryHttpModule/ActivityHelper.cs
Show resolved
Hide resolved
Codecov Report
@@ Coverage Diff @@
## main #1388 +/- ##
==========================================
+ Coverage 73.91% 80.06% +6.15%
==========================================
Files 267 160 -107
Lines 9615 4450 -5165
==========================================
- Hits 7107 3563 -3544
+ Misses 2508 887 -1621
Flags with carried forward coverage won't be shown. Click here to find out more.
|
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 with a changelog entry!
Thanks for your contribution!
src/OpenTelemetry.Instrumentation.AspNet.TelemetryHttpModule/CHANGELOG.md
Outdated
Show resolved
Hide resolved
src/OpenTelemetry.Instrumentation.AspNet.TelemetryHttpModule/CHANGELOG.md
Outdated
Show resolved
Hide resolved
@@ -2,6 +2,11 @@ | |||
|
|||
## Unreleased | |||
|
|||
* Release together with `OpenTelemetry.Instrumentation.AspNet.TelemetryHttpModule`. |
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.
You can remove this line. These two packages are always released together.
@qhris Thanks for fixing the issue. You can use the |
@qhris This change has a side effect of broken metrics instrumentation. Now that the activity is stopped after the onStopCallBack is fired, the activity.Duration would always result in
|
@vishweshbankwar thanks for letting me know, I'll take a look to reproduce and I'll submit a fix for it. |
Fixes #1138.
Findings
This PR implements the fix suggested by @jdaigle.
I have tested this on an a .NET Framework 4.8 ASP MVC application I've been maintaining.
I ran into this issue trying to modify the span name to be prefixed by the http method as recommended by the spec. The problem I ran into was the
HttpInListener
overriding whatever changes the processor made to the span name.It also seems odd to me that the activity is closed and then updated (through
HttpInListener.OnStopActivity
). I think there is a race condition with exporters here. I was able to trigger this by setting a breakpoint beforeonRequestStoppedCallback
is called; sometimes the exported span would have the pre-callback display name and sometimes it would have the post-callback display name. This is due to the exporters being processors, and processors are triggered on stopping the activity (?). This of course depends on you're using the simple exporter or a batched one.This is how I think it works (pre-patch):
aspNetActivity.Stop()
is called.HttpInListener.OnStopActivity
is called (throughonRequestStoppedCallback
.I'm still pretty new to OTEL in dotnet, so I might be missing something here, but this seems like a problem to me.
Questions
content.Items[ContextKey] = null
be moved as well, as the context is cleared out now beforeasnNetActivity.Stop()
is called?Changes
This changes the point at which the activity is stopped to after the
onRequestStoppedCallback
function is called.For significant contributions please make sure you have completed the following items:
CHANGELOG.md
updated for non-trivial changes