Fix missing metrics due to incorrect handling of "Telemetry sampled out" responses #50256
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.
Issue
Users experience missing metrics in Azure.Monitor.OpenTelemetry.AspNetCore when Application Insights sampling is enabled. The exporter logs errors like:
This error occurs because the Azure Monitor OpenTelemetry exporter treats 206 Partial Success responses as failures when they include "Telemetry sampled out" messages, which are actually normal responses when sampling is enabled.
Changes
This PR makes three key changes to correctly handle sampled out telemetry:
IsSamplingError()
to identify when an error is due to normal sampling behaviorIsSuccess()
method to consider 206 (PartialSuccess) responses as successfulTest Results
When used with an application that has ingestion sampling enabled (like the 12.5% mentioned in the issue), metrics should now appear consistently in Application Insights without interruption due to sampling.
Customer Impact
This issue affects customers using metrics with Azure.Monitor.OpenTelemetry.AspNetCore when sampling is enabled in their Application Insights instance, causing inconsistent metrics data in dashboards and alerts.
Fixes #48141.
Warning
Firewall rules blocked me from connecting to one or more addresses
I tried to connect to the following addresses, but was blocked by firewall rules:
4myvsblobprodcus32.vsblob.vsassets.io
dotnet build sdk/monitor/Azure.Monitor.OpenTelemetry.Exporter/src
(dns block)51yvsblobprodcus36.vsblob.vsassets.io
dotnet build sdk/monitor/Azure.Monitor.OpenTelemetry.Exporter/src
(dns block)5rqvsblobprodcus385.vsblob.vsassets.io
dotnet build sdk/monitor/Azure.Monitor.OpenTelemetry.Exporter/src
(dns block)gbsvsblobprodcus365.vsblob.vsassets.io
dotnet build sdk/monitor/Azure.Monitor.OpenTelemetry.Exporter/src
(dns block)nn8vsblobprodcus340.vsblob.vsassets.io
dotnet build sdk/monitor/Azure.Monitor.OpenTelemetry.Exporter/src
(dns block)pe3vsblobprodcus354.vsblob.vsassets.io
dotnet build sdk/monitor/Azure.Monitor.OpenTelemetry.Exporter/src
(dns block)If you need me to access, download, or install something from one of these locations, you can either:
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.