-
Notifications
You must be signed in to change notification settings - Fork 147
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix Active scope synchronization in AspNetScopeManager (#612)
Issue: When using the AspNetScopeManager, the closing of a span generated by automatic instrumentation doesn't get propagated correctly to the original ASP.NET synchronization context, causing later spans to have the wrong parent. This occurs because we use ConfigureAwait(false) on all of our async continuations. When we create the new span we register it to the HttpContext.Current of the ASP.NET synchronization context, but when we close the span during the continuation we have lost the original ASP.NET synchronization context so the HttpContext.Current remains unchanged. Then, later spans generated in the ASP.NET synchronization context treat that span as being active and will always be a child of that one. Solution: When obtaining the Active scope, check the AsyncLocalCompat value first and then check HttpContext.Current as a fallback. This allows any changes to the Active scope that were made in our continuations without the ASP.NET synchronization context to be visible by later code run inside the ASP.NET synchronization context. Additional fix: Fix the System.Net.WebRequest.GetResponseAsync integration which had the wrong assembly name. In .NET Framework it is always in the System assembly. This was noticed while testing the modified sample. I am also adding the .NET Core integration because the change is so small.
- Loading branch information
1 parent
d969429
commit a9efb8a
Showing
5 changed files
with
95 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters