fix: correlate browser and server app insights - #1263
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates the browser-side Application Insights setup and key fetch calls so browser-initiated activity (chat + TryDotNet + listing source fetches) can correlate with the ASP.NET Core backend using W3C traceparent headers, enabling end-to-end traces in Application Insights.
Changes:
- Re-enabled browser dependency tracking and configured Application Insights JS for W3C distributed tracing + CORS correlation.
- Added
traceparentpropagation to chat streaming and listing source fetch requests. - Expanded correlation configuration to include the configured TryDotNet host.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| EssentialCSharp.Web/wwwroot/js/trydotnet-module.js | Adds traceparent header propagation for listing source requests and TryDotNet service health-check requests. |
| EssentialCSharp.Web/wwwroot/js/chat-module.js | Adds traceparent header propagation on the chat streaming request. |
| EssentialCSharp.Web/wwwroot/js/appinsights-manager.js | Re-enables fetch/XHR dependency tracking and configures W3C distributed tracing + correlation header domains (site + TryDotNet). |
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.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.
Why
Application Insights was splitting browser-initiated flows from the ASP.NET Core backend, which made it difficult to inspect a single end-to-end trace for chat and TryDotNet interactions. This change aligns the browser and server telemetry on the same W3C trace id so Application Insights can show one correlated request flow.
What changed
traceparentpropagation on the chat stream request and listing source fetchescorrelationContextbridge so TryDotNet session creation can continue to join the browser trace during the transitionNotes for reviewers
The main tradeoff here is intentional: this restores browser-side dependency telemetry that had previously been disabled to reduce noise. That follows the Microsoft Learn guidance more closely and is what enables the end-to-end trace view. The TryDotNet support includes a small project-specific compatibility layer in addition to the standard App Insights/OpenTelemetry propagation path.