fix(appinsights): propagate trace into try iframe telemetry - #393
Merged
Conversation
BenjaminMichaelis
temporarily deployed
to
BuildAndUploadImage
August 7, 2026 09:11 — with
GitHub Actions
Inactive
There was a problem hiding this comment.
Pull request overview
This PR propagates Application Insights tracing context into the Try iframe/editor so iframe telemetry (page view and /commands dependencies) can correlate with the host trace.
Changes:
- Pass
APPLICATIONINSIGHTS_CONNECTION_STRINGthrough the editor bootstrap configuration so the iframe can initialize App Insights. - Initialize the App Insights browser SDK inside the iframe when correlation context is present, and emit an iframe page view.
- Instrument
/commandsrequests from the iframe to emit dependency telemetry under the propagated trace.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| src/Microsoft.TryDotNet/ContentGenerator.cs | Adds applicationInsightsConnectionString to the serialized editor configuration. |
| src/microsoft-trydotnet-editor/src/index.ts | Loads/initializes App Insights in the iframe, sets trace context, and tracks page/dependency telemetry. |
| src/microsoft-trydotnet-editor/src/factory.ts | Extends IConfiguration to include the optional App Insights connection string. |
Suppressed comments (1)
src/microsoft-trydotnet-editor/src/index.ts:27
- Indentation on this line uses spaces while the surrounding block uses tabs; this can cause noisy diffs or formatting/lint failures. Match the existing indentation style in this file.
configureLogging({ enableLogging: configuration.enableLogging });
void initializeAppInsights(configuration);
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+98
to
+103
| await ensureAppInsightsSdkLoaded(); | ||
|
|
||
| const ApplicationInsights = getApplicationInsightsConstructor(); | ||
| if (!ApplicationInsights) { | ||
| return; | ||
| } |
| import { configureLogging } from './log'; | ||
|
|
||
| if (window) { | ||
| const sdkUrl = "https://js.monitor.azure.com/scripts/b/ai.3.gbl.min.js"; |
Comment on lines
+115
to
+116
| appInsights.addTelemetryInitializer((item) => { | ||
| item.tags = item.tags || []; |
| correlationContext = correlationContextQueryValue.FirstOrDefault(); | ||
| } | ||
|
|
||
| string? applicationInsightsConnectionString = Environment.GetEnvironmentVariable("APPLICATIONINSIGHTS_CONNECTION_STRING"); |
Connection strings contain ingest credentials and must never be exposed to untrusted clients. Removed connection string from iframe bootstrap config to prevent data pollution and cost overruns. Correlation still works via W3C traceparent headers: browser sends the traceparent header in API requests, backend receives it and instruments its own traces under the same operation ID. No credentials needed in browser.
BenjaminMichaelis
temporarily deployed
to
BuildAndUploadImage
August 9, 2026 06:33 — with
GitHub Actions
Inactive
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.
Summary
Testing