Skip to content

fix: correlate browser and server app insights - #1263

Merged
BenjaminMichaelis merged 2 commits into
mainfrom
bmichaelis-app-insights-trace-plan
Aug 7, 2026
Merged

fix: correlate browser and server app insights#1263
BenjaminMichaelis merged 2 commits into
mainfrom
bmichaelis-app-insights-trace-plan

Conversation

@BenjaminMichaelis

Copy link
Copy Markdown
Member

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

  • re-enabled browser dependency tracking in the App Insights JS setup and configured it for W3C distributed tracing
  • allowed correlation headers for the site host and the configured TryDotNet host so same-origin and TryDotNet requests can stay on the same trace
  • added traceparent propagation on the chat stream request and listing source fetches
  • kept the existing TryDotNet correlationContext bridge so TryDotNet session creation can continue to join the browser trace during the transition

Notes 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.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 traceparent propagation 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).

Comment thread EssentialCSharp.Web/wwwroot/js/trydotnet-module.js
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@BenjaminMichaelis
BenjaminMichaelis merged commit 77c809f into main Aug 7, 2026
6 checks passed
@BenjaminMichaelis
BenjaminMichaelis deleted the bmichaelis-app-insights-trace-plan branch August 7, 2026 08:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants