New design for TelemetryHttpModule using ActivitySource + OpenTelemetry.API part 3 - #2256
Merged
CodeBlanch merged 5 commits intoAug 16, 2021
Conversation
reyang
reviewed
Aug 13, 2021
CodeBlanch
commented
Aug 13, 2021
| else | ||
| { | ||
| return uri.ToString(); | ||
| activity.SetStatus(Status.Error); |
Member
Author
There was a problem hiding this comment.
@cijothomas @alanwest Check this out. In the case of exception thrown when !activity.IsAllDataRequested I thought we should still at least mark the status as Error. What you guys think about that?
I'll do the same for AspNetCore if we all agree this is desired:
Member
Author
There was a problem hiding this comment.
I ended up removing this. Turns out anything with !activity.IsAllDataRequested isn't fed to the processor(s) so it seemed kind of pointless to do.
CodeBlanch
merged commit Aug 16, 2021
8b1fd83
into
open-telemetry:aspnet-telemetrycorrelation-otelintegration
CodeBlanch
deleted the
aspnet-telemetrycorrelation-otelintegration-part3
branch
August 16, 2021 16:44
CodeBlanch
added a commit
that referenced
this pull request
Aug 25, 2021
…e + OpenTelemetry.API (#2270) * New design for TelemetryHttpModule using ActivitySource + OpenTelemetry.API. (#2249) * New design for TelemetryHttpModule using ActivitySource + OpenTelemetry.API part 2 (#2254) * Use a single context.Items key for state management to make things more efficient. * Added a comment for clarity. * Code review. * New design for TelemetryHttpModule using ActivitySource + OpenTelemetry.API part 3 (#2256) * Update ASP.NET instrumentation to use the new TelemetryHttpModule. * Fixed TelemetryHttpModule not starting its Activity objects. Added an example of request suppression. * Tweaks an logging improvements. * Sealed AspNetInstrumentationEventSource. * Code review. * New design for TelemetryHttpModule using ActivitySource + OpenTelemetry.API part 4 (#2258) * Fixed up TelemetryHttpModule unit tests. * Added tests for the new HasStarted helper and added checks for StartedButNotSampledObj when not sampled. * Code review. * New design for TelemetryHttpModule using ActivitySource + OpenTelemetry.API part 5 (#2261) * Updated ASP.NET instrumentation tests for new TelemetryHttpModule. * Added a test for the new RecordException option. * Code review. * New design for TelemetryHttpModule using ActivitySource + OpenTelemetry.API part 6 (#2264) * CHANGELOG & README updates. * Apply suggestions from code review Co-authored-by: Reiley Yang <reyang@microsoft.com> Co-authored-by: Reiley Yang <reyang@microsoft.com> * Lint + sanity checks. * Lint attempt 2. * Restored CHANGELOG changes lost in merge. Co-authored-by: Reiley Yang <reyang@microsoft.com>
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Relates to #2249
Changes
Notes & interesting lessons learned
Turns out there is no single instance of HttpApplication and HttpModules aren't singletons. Check it out:
https://github.com/microsoft/referencesource/blob/5697c29004a34d80acdaf5742d7e699022c64ecd/System.Web/HttpApplicationFactory.cs#L67-L71
There are two different bags of HttpApplications. The "special" ones are for application-level events (ex Application_Start). The "free" ones are created/re-used for each request and are sent request-level events (ex Begin_Request). This makes it much more difficult than I anticipated to find the TelemetryHttpModule and attach callbacks for instrumentation. I ended up just adding a static for the options. Not the most elegant solution but probably the least code. We could try to hook into HttpApplicationFactory with reflection and monkey patch in some code to call us anytime an HttpApplication is created/re-used.