Add Azure Monitor OpenTelemetry Profiler for container deployments#1107
Merged
Conversation
- Add Azure.Monitor.OpenTelemetry.Profiler 1.0.0-beta9 to CPM and web project - Wire up AddAzureMonitorProfiler() chained on UseAzureMonitor() in Program.cs - Profiler only activates when APPLICATIONINSIGHTS_CONNECTION_STRING is set - Add profiler debug logging to appsettings.Development.json for local diagnostics - Uses EventPipe (in-process) — compatible with chiseled container base image - Enables Code Optimizations (AI-based perf insights) in Azure portal Tested locally: profiler agent loads and initializes correctly on both dotnet run and Docker (noble-chiseled-extra base image).
Contributor
There was a problem hiding this comment.
Pull request overview
Adds Azure Monitor OpenTelemetry Profiler support to the web app’s existing Azure Monitor OpenTelemetry path so production container deployments can collect profiling data for Application Insights Code Optimizations.
Changes:
- Adds
Azure.Monitor.OpenTelemetry.Profilerto central package management and the web project. - Chains
AddAzureMonitorProfiler()onto the existingUseAzureMonitor()registration. - Enables development debug logging for profiler-related categories.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
Directory.Packages.props |
Adds the profiler package version under central package management. |
EssentialCSharp.Web/EssentialCSharp.Web.csproj |
References the profiler package from the web project. |
EssentialCSharp.Web/Program.cs |
Registers the profiler only on the Azure Monitor telemetry path. |
EssentialCSharp.Web/appsettings.Development.json |
Adds profiler debug log levels for development diagnostics. |
Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@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.
Summary
Adds the Azure Monitor OpenTelemetry Profiler (
Azure.Monitor.OpenTelemetry.Profiler) to enable Application Insights profiling and Code Optimizations in production.Why this package (not
Microsoft.ApplicationInsights.Profiler.AspNetCore)The app already uses
Azure.Monitor.OpenTelemetry.AspNetCore(OTel distro). Microsoft's docs list two profiler paths:Microsoft.ApplicationInsights.Profiler.AspNetCore+AddServiceProfiler()— uses a native uploader binary, incompatible with chiseled containersAzure.Monitor.OpenTelemetry.Profiler+AddAzureMonitorProfiler()← this PR — uses EventPipe (pure in-process), compatible with chiseled imagesChanges
Directory.Packages.props: AddAzure.Monitor.OpenTelemetry.Profiler 1.0.0-beta9to Central Package Management (prerelease-only; TODO comment added to update at GA)EssentialCSharp.Web.csproj: Reference the new packageProgram.cs: Chain.AddAzureMonitorProfiler()ontoUseAzureMonitor()— profiler only activates whenAPPLICATIONINSIGHTS_CONNECTION_STRINGis set (production only, never local/OTLP)appsettings.Development.json: AddDebuglog level for profiler namespaces for local diagnosticsTesting
dotnet runwith fake connection stringnoble-chiseled-extra) with fake keyWhat this enables in production
Once
APPLICATIONINSIGHTS_CONNECTION_STRINGis set in the ACA deployment config:Notes