Repository navigation
[sdk] Fix suppression state isolation across async flows - #7803
Conversation
Pull request dashboard statusMerged · refreshed 2026-09-24 21:16 UTC Status above doesn't look right?
|
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
A core SDK behavioural bug fix requires an entry in src/OpenTelemetry/CHANGELOG.md under ## Unreleased, which is currently missing.
Get a fresh assessment by requesting another Copilot review.
Review effort: Lite
Findings: 1
Open (1)
What changed in this PR
Fixes a correctness issue in the SDK’s suppression mechanism where a mutable suppression state stored in runtime context could be shared by reference across inherited ExecutionContext/async flows, causing suppression depth mutations in one flow to affect others.
Changes:
- Reworks
SuppressInstrumentationScopeto store immutable suppression state objects in the runtime context slot, with a bounded cache for common reference counts. - Adds regression tests to validate isolation across overlapping parent/child async flows and correct nested-scope restoration semantics.
- Extends test coverage for deep reference-count nesting beyond the cached boundary.
| File | Description |
|---|---|
| src/OpenTelemetry/SuppressInstrumentationScope.cs | Switches suppression tracking to immutable, cached state tokens to prevent cross-async-flow leakage while retaining performance benefits. |
| test/OpenTelemetry.Tests/SuppressInstrumentationTests.cs | Adds regression tests covering overlapping async flow isolation, explicit-scope restoration, and deep reference count behavior. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #7803 +/- ##
=======================================
Coverage 91.90% 91.91%
=======================================
Files 341 341
Lines 18615 18610 -5
=======================================
- Hits 17109 17106 -3
+ Misses 1506 1504 -2
Flags with carried forward coverage won't be shown. Click here to find out more.
|
martincostello
left a comment
There was a problem hiding this comment.
Just some comments on the tests.
Updated [OpenTelemetry.Exporter.OpenTelemetryProtocol](https://github.com/open-telemetry/opentelemetry-dotnet) from 1.19.1 to 1.20.0. <details> <summary>Release notes</summary> _Sourced from [OpenTelemetry.Exporter.OpenTelemetryProtocol's releases](https://github.com/open-telemetry/opentelemetry-dotnet/releases)._ ## 1.20.0 For highlights and announcements pertaining to this release see: [Release Notes > 1.20.0](https://github.com/open-telemetry/opentelemetry-dotnet/blob/main/RELEASENOTES.md#1200). The following changes are from the previous release [1.19.1](https://github.com/open-telemetry/opentelemetry-dotnet/releases/tag/core-1.19.1). * NuGet: [OpenTelemetry v1.20.0](https://www.nuget.org/packages/OpenTelemetry/1.20.0) * Fixed `SuppressInstrumentationScope` reference counts leaking between inherited asynchronous execution contexts. ([#7803](open-telemetry/opentelemetry-dotnet#7803)) * Self-diagnostic features are explicitly disabled on browser-based platforms (e.g. Blazor) and are now non-functional. Previously, attempting to enable self-diagnostics on such platforms would result in an exception at runtime. ([#7799](open-telemetry/opentelemetry-dotnet#7799)) * Added `TracerProviderBuilder.ConfigureSampler` which receives the resolved `Sampler` whether set programmatically, via `OTEL_TRACES_SAMPLER`, or by default, and returns a replacement. Intended for library authors who need to influence sampling without overriding a sampler the application has configured. ([#7780](open-telemetry/opentelemetry-dotnet#7780)) * Fixed `ResourceBuilder.CreateDefault` ignoring `OTEL_RESOURCE_ATTRIBUTES` and `OTEL_SERVICE_NAME` environment variables when the host `IConfiguration` does not contain those settings. ([#7855](open-telemetry/opentelemetry-dotnet#7855)) * Added improved self-diagnostics logging to improve the support experience. The new `SelfDiagnosticsOptions` class configures a rolling file sink and a console sink through the standard options pipeline. Sinks are off by default. ([#7588](open-telemetry/opentelemetry-dotnet#7588)) * Fixed a race that could incorrectly route a concurrent metric measurement to the overflow point when its tag set was published as the cardinality limit was reached. ([#7804](open-telemetry/opentelemetry-dotnet#7804)) * Added `OpenTelemetryLoggerOptions.Version` and `OpenTelemetryLoggerOptions.SchemaUrl` options to set an instrumentation library version and schema URL applied to logs emitted via the `Microsoft.Extensions.Logging` `ILogger` integration. ([#7727](open-telemetry/opentelemetry-dotnet#7727)) * Fixed `LogRecord.CategoryName` resetting the current `Logger`'s `Version` to `null` when set to a new value. ([#7727](open-telemetry/opentelemetry-dotnet#7727)) * Bounded the internal cache of `Logger` scopes keyed by instrumentation to avoid unbounded growth. ([#7727](open-telemetry/opentelemetry-dotnet#7727)) * Fixed the `MeterProvider` and its `IServiceProvider` being kept alive after the host is disposed when using `Microsoft.Extensions.Diagnostics` versions prior to 9.0, which never dispose their `MetricsSubscriptionManager` (and its underlying `MeterListener`). ([#7924](open-telemetry/opentelemetry-dotnet#7924)) * Fixed a race condition between recording a measurement and collecting a histogram with delta temporality that could cause an empty data point (with a count of zero) to be exported in the next collection cycle. ([#7923](open-telemetry/opentelemetry-dotnet#7923)) * Improved metric collection performance after metric streams are removed by compacting metric storage during collection. ([#7945](open-telemetry/opentelemetry-dotnet#7945)) See [CHANGELOG](https://github.com/open-telemetry/opentelemetry-dotnet/blob/core-1.20.0/src/OpenTelemetry/CHANGELOG.md) for details. * NuGet: [OpenTelemetry.Api v1.20.0](https://www.nuget.org/packages/OpenTelemetry.Api/1.20.0) * Added `Logger.SchemaUrl` and a `LoggerProvider.GetLogger` overload accepting a schema URL parameter using the new `LoggerOptions` type. ([#7727](open-telemetry/opentelemetry-dotnet#7727)) * **Breaking change** (pre-release only versions): `LoggerProvider`'s protected `TryCreateLogger(string? name, out Logger? logger)` extensibility method has been replaced by `TryCreateLogger(LoggerOptions options, out Logger? logger)`. Custom `LoggerProvider` subclasses that override the previous overload must update to override the new one; the old overload is no longer called. ... (truncated) ## 1.20.0-rc.1 The following changes are from the previous release [1.19.1](https://github.com/open-telemetry/opentelemetry-dotnet/releases/tag/core-1.19.1). * NuGet: [OpenTelemetry v1.20.0-rc.1](https://www.nuget.org/packages/OpenTelemetry/1.20.0-rc.1) * Fixed `SuppressInstrumentationScope` reference counts leaking between inherited asynchronous execution contexts. ([#7803](open-telemetry/opentelemetry-dotnet#7803)) * Self-diagnostic features are explicitly disabled on browser-based platforms (e.g. Blazor) and are now non-functional. Previously, attempting to enable self-diagnostics on such platforms would result in an exception at runtime. ([#7799](open-telemetry/opentelemetry-dotnet#7799)) * Added `TracerProviderBuilder.ConfigureSampler` which receives the resolved `Sampler` whether set programmatically, via `OTEL_TRACES_SAMPLER`, or by default, and returns a replacement. Intended for library authors who need to influence sampling without overriding a sampler the application has configured. ([#7780](open-telemetry/opentelemetry-dotnet#7780)) * Fixed `ResourceBuilder.CreateDefault` ignoring `OTEL_RESOURCE_ATTRIBUTES` and `OTEL_SERVICE_NAME` environment variables when the host `IConfiguration` does not contain those settings. ([#7855](open-telemetry/opentelemetry-dotnet#7855)) * Added improved self-diagnostics logging to improve the support experience. The new `SelfDiagnosticsOptions` class configures a rolling file sink and a console sink through the standard options pipeline. Sinks are off by default. ([#7588](open-telemetry/opentelemetry-dotnet#7588)) * Fixed a race that could incorrectly route a concurrent metric measurement to the overflow point when its tag set was published as the cardinality limit was reached. ([#7804](open-telemetry/opentelemetry-dotnet#7804)) * Added `OpenTelemetryLoggerOptions.Version` and `OpenTelemetryLoggerOptions.SchemaUrl` options to set an instrumentation library version and schema URL applied to logs emitted via the `Microsoft.Extensions.Logging` `ILogger` integration. ([#7727](open-telemetry/opentelemetry-dotnet#7727)) * Fixed `LogRecord.CategoryName` resetting the current `Logger`'s `Version` to `null` when set to a new value. ([#7727](open-telemetry/opentelemetry-dotnet#7727)) * Bounded the internal cache of `Logger` scopes keyed by instrumentation to avoid unbounded growth. ([#7727](open-telemetry/opentelemetry-dotnet#7727)) * Fixed the `MeterProvider` and its `IServiceProvider` being kept alive after the host is disposed when using `Microsoft.Extensions.Diagnostics` versions prior to 9.0, which never dispose their `MetricsSubscriptionManager` (and its underlying `MeterListener`). ([#7924](open-telemetry/opentelemetry-dotnet#7924)) * Fixed a race condition between recording a measurement and collecting a histogram with delta temporality that could cause an empty data point (with a count of zero) to be exported in the next collection cycle. ([#7923](open-telemetry/opentelemetry-dotnet#7923)) * Improved metric collection performance after metric streams are removed by compacting metric storage during collection. ([#7945](open-telemetry/opentelemetry-dotnet#7945)) See [CHANGELOG](https://github.com/open-telemetry/opentelemetry-dotnet/blob/core-1.20.0-rc.1/src/OpenTelemetry/CHANGELOG.md) for details. * NuGet: [OpenTelemetry.Api v1.20.0-rc.1](https://www.nuget.org/packages/OpenTelemetry.Api/1.20.0-rc.1) * Added `Logger.SchemaUrl` and a `LoggerProvider.GetLogger` overload accepting a schema URL parameter using the new `LoggerOptions` type. ([#7727](open-telemetry/opentelemetry-dotnet#7727)) * **Breaking change** (pre-release only versions): `LoggerProvider`'s protected `TryCreateLogger(string? name, out Logger? logger)` extensibility method has been replaced by `TryCreateLogger(LoggerOptions options, out Logger? logger)`. Custom `LoggerProvider` subclasses that override the previous overload must update to override the new one; the old overload is no longer called. ([#7727](open-telemetry/opentelemetry-dotnet#7727)) ... (truncated) ## 1.20.0-beta.1 The following changes are from the previous release [1.19.1-beta.1](https://github.com/open-telemetry/opentelemetry-dotnet/releases/tag/coreunstable-1.19.1-beta.1). * NuGet: [OpenTelemetry.Exporter.Prometheus.AspNetCore v1.20.0-beta.1](https://www.nuget.org/packages/OpenTelemetry.Exporter.Prometheus.AspNetCore/1.20.0-beta.1) * A scrape request whose connection is aborted, or whose `X-Prometheus-Scrape-Timeout-Seconds` deadline elapses, now stops waiting for an in-progress metrics collection instead of continuing to wait for it to finish. The collection itself is not cancelled and continues running in the background. ([#7856](open-telemetry/opentelemetry-dotnet#7856)) * Updated OpenTelemetry core component version(s) to `1.20.0`. ([#7950](open-telemetry/opentelemetry-dotnet#7950)) See [CHANGELOG](https://github.com/open-telemetry/opentelemetry-dotnet/blob/coreunstable-1.20.0-beta.1/src/OpenTelemetry.Exporter.Prometheus.AspNetCore/CHANGELOG.md) for details. * NuGet: [OpenTelemetry.Exporter.Prometheus.HttpListener v1.20.0-beta.1](https://www.nuget.org/packages/OpenTelemetry.Exporter.Prometheus.HttpListener/1.20.0-beta.1) * Updated OpenTelemetry core component version(s) to `1.20.0`. ([#7950](open-telemetry/opentelemetry-dotnet#7950)) See [CHANGELOG](https://github.com/open-telemetry/opentelemetry-dotnet/blob/coreunstable-1.20.0-beta.1/src/OpenTelemetry.Exporter.Prometheus.HttpListener/CHANGELOG.md) for details. * NuGet: [OpenTelemetry.Shims.OpenTracing v1.20.0-beta.1](https://www.nuget.org/packages/OpenTelemetry.Shims.OpenTracing/1.20.0-beta.1) * Updated OpenTelemetry core component version(s) to `1.20.0`. ([#7950](open-telemetry/opentelemetry-dotnet#7950)) See [CHANGELOG](https://github.com/open-telemetry/opentelemetry-dotnet/blob/coreunstable-1.20.0-beta.1/src/OpenTelemetry.Shims.OpenTracing/CHANGELOG.md) for details. Commits viewable in [compare view](open-telemetry/opentelemetry-dotnet@core-1.19.1...core-1.20.0). </details> Updated [OpenTelemetry.Extensions.Hosting](https://github.com/open-telemetry/opentelemetry-dotnet) from 1.19.1 to 1.20.0. <details> <summary>Release notes</summary> _Sourced from [OpenTelemetry.Extensions.Hosting's releases](https://github.com/open-telemetry/opentelemetry-dotnet/releases)._ ## 1.20.0 For highlights and announcements pertaining to this release see: [Release Notes > 1.20.0](https://github.com/open-telemetry/opentelemetry-dotnet/blob/main/RELEASENOTES.md#1200). The following changes are from the previous release [1.19.1](https://github.com/open-telemetry/opentelemetry-dotnet/releases/tag/core-1.19.1). * NuGet: [OpenTelemetry v1.20.0](https://www.nuget.org/packages/OpenTelemetry/1.20.0) * Fixed `SuppressInstrumentationScope` reference counts leaking between inherited asynchronous execution contexts. ([#7803](open-telemetry/opentelemetry-dotnet#7803)) * Self-diagnostic features are explicitly disabled on browser-based platforms (e.g. Blazor) and are now non-functional. Previously, attempting to enable self-diagnostics on such platforms would result in an exception at runtime. ([#7799](open-telemetry/opentelemetry-dotnet#7799)) * Added `TracerProviderBuilder.ConfigureSampler` which receives the resolved `Sampler` whether set programmatically, via `OTEL_TRACES_SAMPLER`, or by default, and returns a replacement. Intended for library authors who need to influence sampling without overriding a sampler the application has configured. ([#7780](open-telemetry/opentelemetry-dotnet#7780)) * Fixed `ResourceBuilder.CreateDefault` ignoring `OTEL_RESOURCE_ATTRIBUTES` and `OTEL_SERVICE_NAME` environment variables when the host `IConfiguration` does not contain those settings. ([#7855](open-telemetry/opentelemetry-dotnet#7855)) * Added improved self-diagnostics logging to improve the support experience. The new `SelfDiagnosticsOptions` class configures a rolling file sink and a console sink through the standard options pipeline. Sinks are off by default. ([#7588](open-telemetry/opentelemetry-dotnet#7588)) * Fixed a race that could incorrectly route a concurrent metric measurement to the overflow point when its tag set was published as the cardinality limit was reached. ([#7804](open-telemetry/opentelemetry-dotnet#7804)) * Added `OpenTelemetryLoggerOptions.Version` and `OpenTelemetryLoggerOptions.SchemaUrl` options to set an instrumentation library version and schema URL applied to logs emitted via the `Microsoft.Extensions.Logging` `ILogger` integration. ([#7727](open-telemetry/opentelemetry-dotnet#7727)) * Fixed `LogRecord.CategoryName` resetting the current `Logger`'s `Version` to `null` when set to a new value. ([#7727](open-telemetry/opentelemetry-dotnet#7727)) * Bounded the internal cache of `Logger` scopes keyed by instrumentation to avoid unbounded growth. ([#7727](open-telemetry/opentelemetry-dotnet#7727)) * Fixed the `MeterProvider` and its `IServiceProvider` being kept alive after the host is disposed when using `Microsoft.Extensions.Diagnostics` versions prior to 9.0, which never dispose their `MetricsSubscriptionManager` (and its underlying `MeterListener`). ([#7924](open-telemetry/opentelemetry-dotnet#7924)) * Fixed a race condition between recording a measurement and collecting a histogram with delta temporality that could cause an empty data point (with a count of zero) to be exported in the next collection cycle. ([#7923](open-telemetry/opentelemetry-dotnet#7923)) * Improved metric collection performance after metric streams are removed by compacting metric storage during collection. ([#7945](open-telemetry/opentelemetry-dotnet#7945)) See [CHANGELOG](https://github.com/open-telemetry/opentelemetry-dotnet/blob/core-1.20.0/src/OpenTelemetry/CHANGELOG.md) for details. * NuGet: [OpenTelemetry.Api v1.20.0](https://www.nuget.org/packages/OpenTelemetry.Api/1.20.0) * Added `Logger.SchemaUrl` and a `LoggerProvider.GetLogger` overload accepting a schema URL parameter using the new `LoggerOptions` type. ([#7727](open-telemetry/opentelemetry-dotnet#7727)) * **Breaking change** (pre-release only versions): `LoggerProvider`'s protected `TryCreateLogger(string? name, out Logger? logger)` extensibility method has been replaced by `TryCreateLogger(LoggerOptions options, out Logger? logger)`. Custom `LoggerProvider` subclasses that override the previous overload must update to override the new one; the old overload is no longer called. ... (truncated) ## 1.20.0-rc.1 The following changes are from the previous release [1.19.1](https://github.com/open-telemetry/opentelemetry-dotnet/releases/tag/core-1.19.1). * NuGet: [OpenTelemetry v1.20.0-rc.1](https://www.nuget.org/packages/OpenTelemetry/1.20.0-rc.1) * Fixed `SuppressInstrumentationScope` reference counts leaking between inherited asynchronous execution contexts. ([#7803](open-telemetry/opentelemetry-dotnet#7803)) * Self-diagnostic features are explicitly disabled on browser-based platforms (e.g. Blazor) and are now non-functional. Previously, attempting to enable self-diagnostics on such platforms would result in an exception at runtime. ([#7799](open-telemetry/opentelemetry-dotnet#7799)) * Added `TracerProviderBuilder.ConfigureSampler` which receives the resolved `Sampler` whether set programmatically, via `OTEL_TRACES_SAMPLER`, or by default, and returns a replacement. Intended for library authors who need to influence sampling without overriding a sampler the application has configured. ([#7780](open-telemetry/opentelemetry-dotnet#7780)) * Fixed `ResourceBuilder.CreateDefault` ignoring `OTEL_RESOURCE_ATTRIBUTES` and `OTEL_SERVICE_NAME` environment variables when the host `IConfiguration` does not contain those settings. ([#7855](open-telemetry/opentelemetry-dotnet#7855)) * Added improved self-diagnostics logging to improve the support experience. The new `SelfDiagnosticsOptions` class configures a rolling file sink and a console sink through the standard options pipeline. Sinks are off by default. ([#7588](open-telemetry/opentelemetry-dotnet#7588)) * Fixed a race that could incorrectly route a concurrent metric measurement to the overflow point when its tag set was published as the cardinality limit was reached. ([#7804](open-telemetry/opentelemetry-dotnet#7804)) * Added `OpenTelemetryLoggerOptions.Version` and `OpenTelemetryLoggerOptions.SchemaUrl` options to set an instrumentation library version and schema URL applied to logs emitted via the `Microsoft.Extensions.Logging` `ILogger` integration. ([#7727](open-telemetry/opentelemetry-dotnet#7727)) * Fixed `LogRecord.CategoryName` resetting the current `Logger`'s `Version` to `null` when set to a new value. ([#7727](open-telemetry/opentelemetry-dotnet#7727)) * Bounded the internal cache of `Logger` scopes keyed by instrumentation to avoid unbounded growth. ([#7727](open-telemetry/opentelemetry-dotnet#7727)) * Fixed the `MeterProvider` and its `IServiceProvider` being kept alive after the host is disposed when using `Microsoft.Extensions.Diagnostics` versions prior to 9.0, which never dispose their `MetricsSubscriptionManager` (and its underlying `MeterListener`). ([#7924](open-telemetry/opentelemetry-dotnet#7924)) * Fixed a race condition between recording a measurement and collecting a histogram with delta temporality that could cause an empty data point (with a count of zero) to be exported in the next collection cycle. ([#7923](open-telemetry/opentelemetry-dotnet#7923)) * Improved metric collection performance after metric streams are removed by compacting metric storage during collection. ([#7945](open-telemetry/opentelemetry-dotnet#7945)) See [CHANGELOG](https://github.com/open-telemetry/opentelemetry-dotnet/blob/core-1.20.0-rc.1/src/OpenTelemetry/CHANGELOG.md) for details. * NuGet: [OpenTelemetry.Api v1.20.0-rc.1](https://www.nuget.org/packages/OpenTelemetry.Api/1.20.0-rc.1) * Added `Logger.SchemaUrl` and a `LoggerProvider.GetLogger` overload accepting a schema URL parameter using the new `LoggerOptions` type. ([#7727](open-telemetry/opentelemetry-dotnet#7727)) * **Breaking change** (pre-release only versions): `LoggerProvider`'s protected `TryCreateLogger(string? name, out Logger? logger)` extensibility method has been replaced by `TryCreateLogger(LoggerOptions options, out Logger? logger)`. Custom `LoggerProvider` subclasses that override the previous overload must update to override the new one; the old overload is no longer called. ([#7727](open-telemetry/opentelemetry-dotnet#7727)) ... (truncated) ## 1.20.0-beta.1 The following changes are from the previous release [1.19.1-beta.1](https://github.com/open-telemetry/opentelemetry-dotnet/releases/tag/coreunstable-1.19.1-beta.1). * NuGet: [OpenTelemetry.Exporter.Prometheus.AspNetCore v1.20.0-beta.1](https://www.nuget.org/packages/OpenTelemetry.Exporter.Prometheus.AspNetCore/1.20.0-beta.1) * A scrape request whose connection is aborted, or whose `X-Prometheus-Scrape-Timeout-Seconds` deadline elapses, now stops waiting for an in-progress metrics collection instead of continuing to wait for it to finish. The collection itself is not cancelled and continues running in the background. ([#7856](open-telemetry/opentelemetry-dotnet#7856)) * Updated OpenTelemetry core component version(s) to `1.20.0`. ([#7950](open-telemetry/opentelemetry-dotnet#7950)) See [CHANGELOG](https://github.com/open-telemetry/opentelemetry-dotnet/blob/coreunstable-1.20.0-beta.1/src/OpenTelemetry.Exporter.Prometheus.AspNetCore/CHANGELOG.md) for details. * NuGet: [OpenTelemetry.Exporter.Prometheus.HttpListener v1.20.0-beta.1](https://www.nuget.org/packages/OpenTelemetry.Exporter.Prometheus.HttpListener/1.20.0-beta.1) * Updated OpenTelemetry core component version(s) to `1.20.0`. ([#7950](open-telemetry/opentelemetry-dotnet#7950)) See [CHANGELOG](https://github.com/open-telemetry/opentelemetry-dotnet/blob/coreunstable-1.20.0-beta.1/src/OpenTelemetry.Exporter.Prometheus.HttpListener/CHANGELOG.md) for details. * NuGet: [OpenTelemetry.Shims.OpenTracing v1.20.0-beta.1](https://www.nuget.org/packages/OpenTelemetry.Shims.OpenTracing/1.20.0-beta.1) * Updated OpenTelemetry core component version(s) to `1.20.0`. ([#7950](open-telemetry/opentelemetry-dotnet#7950)) See [CHANGELOG](https://github.com/open-telemetry/opentelemetry-dotnet/blob/coreunstable-1.20.0-beta.1/src/OpenTelemetry.Shims.OpenTracing/CHANGELOG.md) for details. Commits viewable in [compare view](open-telemetry/opentelemetry-dotnet@core-1.19.1...core-1.20.0). </details> Updated [OpenTelemetry.Instrumentation.AspNetCore](https://github.com/open-telemetry/opentelemetry-dotnet-contrib) from 1.19.0 to 1.20.0. <details> <summary>Release notes</summary> _Sourced from [OpenTelemetry.Instrumentation.AspNetCore's releases](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/releases)._ ## 1.20.0 * NuGet: [OpenTelemetry.Exporter.Geneva v1.20.0](https://www.nuget.org/packages/OpenTelemetry.Exporter.Geneva/1.20.0) * Updated OpenTelemetry core component version(s) to `1.20.0`. ([#5541](open-telemetry/opentelemetry-dotnet-contrib#5541)) See [CHANGELOG](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/blob/Exporter.Geneva-1.20.0/src/OpenTelemetry.Exporter.Geneva/CHANGELOG.md) for details. ## 1.20.0-rc.1 * NuGet: [OpenTelemetry.Instrumentation.Process v1.20.0-rc.1](https://www.nuget.org/packages/OpenTelemetry.Instrumentation.Process/1.20.0-rc.1) * Updated OpenTelemetry core component version(s) to `1.20.0`. ([#5541](open-telemetry/opentelemetry-dotnet-contrib#5541)) See [CHANGELOG](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/blob/Instrumentation.Process-1.20.0-rc.1/src/OpenTelemetry.Instrumentation.Process/CHANGELOG.md) for details. ## 1.20.0-beta.2 * NuGet: [OpenTelemetry.Instrumentation.ServiceFabricRemoting v1.20.0-beta.2](https://www.nuget.org/packages/OpenTelemetry.Instrumentation.ServiceFabricRemoting/1.20.0-beta.2) * Fixed `TraceContextEnrichedActorRemotingProviderAttribute` ignoring the `TransportSettings` configuration section. Actor remoting clients now load their settings from `TransportSettings`, and actor remoting listeners fall back to `TransportSettings` when no actor-specific section is configured, matching the behaviour of Service Fabric's `FabricTransportActorRemotingProviderAttribute`. ([#5450](open-telemetry/opentelemetry-dotnet-contrib#5450)) See [CHANGELOG](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/blob/Instrumentation.ServiceFabricRemoting-1.20.0-beta.2/src/OpenTelemetry.Instrumentation.ServiceFabricRemoting/CHANGELOG.md) for details. ## 1.20.0-beta.1 * NuGet: [OpenTelemetry.Extensions.Enrichment v1.20.0-beta.1](https://www.nuget.org/packages/OpenTelemetry.Extensions.Enrichment/1.20.0-beta.1) * Updated OpenTelemetry core component version(s) to `1.20.0`. ([#5541](open-telemetry/opentelemetry-dotnet-contrib#5541)) See [CHANGELOG](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/blob/Extensions.Enrichment-1.20.0-beta.1/src/OpenTelemetry.Extensions.Enrichment/CHANGELOG.md) for details. ## 1.20.0-alpha.2 * NuGet: [OpenTelemetry.Instrumentation.EventCounters v1.20.0-alpha.2](https://www.nuget.org/packages/OpenTelemetry.Instrumentation.EventCounters/1.20.0-alpha.2) * Fixed a deadlock when an `EventSource` is created on another thread while the meter provider is being built or disposed. ([#5639](open-telemetry/opentelemetry-dotnet-contrib#5639)) See [CHANGELOG](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/blob/Instrumentation.EventCounters-1.20.0-alpha.2/src/OpenTelemetry.Instrumentation.EventCounters/CHANGELOG.md) for details. ## 1.20.0-alpha.1 * NuGet: [OpenTelemetry.Instrumentation.EventCounters v1.20.0-alpha.1](https://www.nuget.org/packages/OpenTelemetry.Instrumentation.EventCounters/1.20.0-alpha.1) * Added dependency injection support for EventCounters instrumentation. ([#5475](open-telemetry/opentelemetry-dotnet-contrib#5475)) * Updated OpenTelemetry core component version(s) to `1.20.0`. ([#5541](open-telemetry/opentelemetry-dotnet-contrib#5541)) See [CHANGELOG](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/blob/Instrumentation.EventCounters-1.20.0-alpha.1/src/OpenTelemetry.Instrumentation.EventCounters/CHANGELOG.md) for details. ## 1.19.1 * NuGet: [OpenTelemetry.Exporter.OneCollector v1.19.1](https://www.nuget.org/packages/OpenTelemetry.Exporter.OneCollector/1.19.1) * Updated OpenTelemetry core component version(s) to `1.19.1`. ([#5329](open-telemetry/opentelemetry-dotnet-contrib#5329)) See [CHANGELOG](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/blob/Exporter.OneCollector-1.19.1/src/OpenTelemetry.Exporter.OneCollector/CHANGELOG.md) for details. ## 1.19.1-rc.1 * NuGet: [OpenTelemetry.Resources.Process v1.19.1-rc.1](https://www.nuget.org/packages/OpenTelemetry.Resources.Process/1.19.1-rc.1) * Updated OpenTelemetry core component version(s) to `1.19.1`. ([#5329](open-telemetry/opentelemetry-dotnet-contrib#5329)) See [CHANGELOG](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/blob/Resources.Process-1.19.1-rc.1/src/OpenTelemetry.Resources.Process/CHANGELOG.md) for details. ## 1.19.1-beta.2 * NuGet: [OpenTelemetry.Resources.Azure v1.19.1-beta.2](https://www.nuget.org/packages/OpenTelemetry.Resources.Azure/1.19.1-beta.2) * Add `cloud.account.id` and `azure.resource_group.name` attributes to the Azure VM resource detector. ([#5195](open-telemetry/opentelemetry-dotnet-contrib#5195)) See [CHANGELOG](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/blob/Resources.Azure-1.19.1-beta.2/src/OpenTelemetry.Resources.Azure/CHANGELOG.md) for details. ## 1.19.1-beta.1 * NuGet: [OpenTelemetry.Exporter.Geneva v1.19.1-beta.1](https://www.nuget.org/packages/OpenTelemetry.Exporter.Geneva/1.19.1-beta.1) * Updated OpenTelemetry core component version(s) to `1.19.1`. ([#5329](open-telemetry/opentelemetry-dotnet-contrib#5329)) See [CHANGELOG](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/blob/Exporter.Geneva-1.19.1-beta.1/src/OpenTelemetry.Exporter.Geneva/CHANGELOG.md) for details. Commits viewable in [compare view](open-telemetry/opentelemetry-dotnet-contrib@Exporter.OneCollector-1.19.0...Exporter.Geneva-1.20.0). </details> Updated [OpenTelemetry.Instrumentation.Http](https://github.com/open-telemetry/opentelemetry-dotnet-contrib) from 1.19.0 to 1.20.0. <details> <summary>Release notes</summary> _Sourced from [OpenTelemetry.Instrumentation.Http's releases](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/releases)._ ## 1.20.0 * NuGet: [OpenTelemetry.Exporter.Geneva v1.20.0](https://www.nuget.org/packages/OpenTelemetry.Exporter.Geneva/1.20.0) * Updated OpenTelemetry core component version(s) to `1.20.0`. ([#5541](open-telemetry/opentelemetry-dotnet-contrib#5541)) See [CHANGELOG](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/blob/Exporter.Geneva-1.20.0/src/OpenTelemetry.Exporter.Geneva/CHANGELOG.md) for details. ## 1.20.0-rc.1 * NuGet: [OpenTelemetry.Instrumentation.Process v1.20.0-rc.1](https://www.nuget.org/packages/OpenTelemetry.Instrumentation.Process/1.20.0-rc.1) * Updated OpenTelemetry core component version(s) to `1.20.0`. ([#5541](open-telemetry/opentelemetry-dotnet-contrib#5541)) See [CHANGELOG](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/blob/Instrumentation.Process-1.20.0-rc.1/src/OpenTelemetry.Instrumentation.Process/CHANGELOG.md) for details. ## 1.20.0-beta.2 * NuGet: [OpenTelemetry.Instrumentation.ServiceFabricRemoting v1.20.0-beta.2](https://www.nuget.org/packages/OpenTelemetry.Instrumentation.ServiceFabricRemoting/1.20.0-beta.2) * Fixed `TraceContextEnrichedActorRemotingProviderAttribute` ignoring the `TransportSettings` configuration section. Actor remoting clients now load their settings from `TransportSettings`, and actor remoting listeners fall back to `TransportSettings` when no actor-specific section is configured, matching the behaviour of Service Fabric's `FabricTransportActorRemotingProviderAttribute`. ([#5450](open-telemetry/opentelemetry-dotnet-contrib#5450)) See [CHANGELOG](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/blob/Instrumentation.ServiceFabricRemoting-1.20.0-beta.2/src/OpenTelemetry.Instrumentation.ServiceFabricRemoting/CHANGELOG.md) for details. ## 1.20.0-beta.1 * NuGet: [OpenTelemetry.Extensions.Enrichment v1.20.0-beta.1](https://www.nuget.org/packages/OpenTelemetry.Extensions.Enrichment/1.20.0-beta.1) * Updated OpenTelemetry core component version(s) to `1.20.0`. ([#5541](open-telemetry/opentelemetry-dotnet-contrib#5541)) See [CHANGELOG](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/blob/Extensions.Enrichment-1.20.0-beta.1/src/OpenTelemetry.Extensions.Enrichment/CHANGELOG.md) for details. ## 1.20.0-alpha.2 * NuGet: [OpenTelemetry.Instrumentation.EventCounters v1.20.0-alpha.2](https://www.nuget.org/packages/OpenTelemetry.Instrumentation.EventCounters/1.20.0-alpha.2) * Fixed a deadlock when an `EventSource` is created on another thread while the meter provider is being built or disposed. ([#5639](open-telemetry/opentelemetry-dotnet-contrib#5639)) See [CHANGELOG](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/blob/Instrumentation.EventCounters-1.20.0-alpha.2/src/OpenTelemetry.Instrumentation.EventCounters/CHANGELOG.md) for details. ## 1.20.0-alpha.1 * NuGet: [OpenTelemetry.Instrumentation.EventCounters v1.20.0-alpha.1](https://www.nuget.org/packages/OpenTelemetry.Instrumentation.EventCounters/1.20.0-alpha.1) * Added dependency injection support for EventCounters instrumentation. ([#5475](open-telemetry/opentelemetry-dotnet-contrib#5475)) * Updated OpenTelemetry core component version(s) to `1.20.0`. ([#5541](open-telemetry/opentelemetry-dotnet-contrib#5541)) See [CHANGELOG](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/blob/Instrumentation.EventCounters-1.20.0-alpha.1/src/OpenTelemetry.Instrumentation.EventCounters/CHANGELOG.md) for details. ## 1.19.1 * NuGet: [OpenTelemetry.Exporter.OneCollector v1.19.1](https://www.nuget.org/packages/OpenTelemetry.Exporter.OneCollector/1.19.1) * Updated OpenTelemetry core component version(s) to `1.19.1`. ([#5329](open-telemetry/opentelemetry-dotnet-contrib#5329)) See [CHANGELOG](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/blob/Exporter.OneCollector-1.19.1/src/OpenTelemetry.Exporter.OneCollector/CHANGELOG.md) for details. ## 1.19.1-rc.1 * NuGet: [OpenTelemetry.Resources.Process v1.19.1-rc.1](https://www.nuget.org/packages/OpenTelemetry.Resources.Process/1.19.1-rc.1) * Updated OpenTelemetry core component version(s) to `1.19.1`. ([#5329](open-telemetry/opentelemetry-dotnet-contrib#5329)) See [CHANGELOG](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/blob/Resources.Process-1.19.1-rc.1/src/OpenTelemetry.Resources.Process/CHANGELOG.md) for details. ## 1.19.1-beta.2 * NuGet: [OpenTelemetry.Resources.Azure v1.19.1-beta.2](https://www.nuget.org/packages/OpenTelemetry.Resources.Azure/1.19.1-beta.2) * Add `cloud.account.id` and `azure.resource_group.name` attributes to the Azure VM resource detector. ([#5195](open-telemetry/opentelemetry-dotnet-contrib#5195)) See [CHANGELOG](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/blob/Resources.Azure-1.19.1-beta.2/src/OpenTelemetry.Resources.Azure/CHANGELOG.md) for details. ## 1.19.1-beta.1 * NuGet: [OpenTelemetry.Exporter.Geneva v1.19.1-beta.1](https://www.nuget.org/packages/OpenTelemetry.Exporter.Geneva/1.19.1-beta.1) * Updated OpenTelemetry core component version(s) to `1.19.1`. ([#5329](open-telemetry/opentelemetry-dotnet-contrib#5329)) See [CHANGELOG](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/blob/Exporter.Geneva-1.19.1-beta.1/src/OpenTelemetry.Exporter.Geneva/CHANGELOG.md) for details. Commits viewable in [compare view](open-telemetry/opentelemetry-dotnet-contrib@Exporter.OneCollector-1.19.0...Exporter.Geneva-1.20.0). </details> Updated [OpenTelemetry.Instrumentation.Runtime](https://github.com/open-telemetry/opentelemetry-dotnet-contrib) from 1.19.0 to 1.20.0. <details> <summary>Release notes</summary> _Sourced from [OpenTelemetry.Instrumentation.Runtime's releases](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/releases)._ ## 1.20.0 * NuGet: [OpenTelemetry.Exporter.Geneva v1.20.0](https://www.nuget.org/packages/OpenTelemetry.Exporter.Geneva/1.20.0) * Updated OpenTelemetry core component version(s) to `1.20.0`. ([#5541](open-telemetry/opentelemetry-dotnet-contrib#5541)) See [CHANGELOG](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/blob/Exporter.Geneva-1.20.0/src/OpenTelemetry.Exporter.Geneva/CHANGELOG.md) for details. ## 1.20.0-rc.1 * NuGet: [OpenTelemetry.Instrumentation.Process v1.20.0-rc.1](https://www.nuget.org/packages/OpenTelemetry.Instrumentation.Process/1.20.0-rc.1) * Updated OpenTelemetry core component version(s) to `1.20.0`. ([#5541](open-telemetry/opentelemetry-dotnet-contrib#5541)) See [CHANGELOG](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/blob/Instrumentation.Process-1.20.0-rc.1/src/OpenTelemetry.Instrumentation.Process/CHANGELOG.md) for details. ## 1.20.0-beta.2 * NuGet: [OpenTelemetry.Instrumentation.ServiceFabricRemoting v1.20.0-beta.2](https://www.nuget.org/packages/OpenTelemetry.Instrumentation.ServiceFabricRemoting/1.20.0-beta.2) * Fixed `TraceContextEnrichedActorRemotingProviderAttribute` ignoring the `TransportSettings` configuration section. Actor remoting clients now load their settings from `TransportSettings`, and actor remoting listeners fall back to `TransportSettings` when no actor-specific section is configured, matching the behaviour of Service Fabric's `FabricTransportActorRemotingProviderAttribute`. ([#5450](open-telemetry/opentelemetry-dotnet-contrib#5450)) See [CHANGELOG](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/blob/Instrumentation.ServiceFabricRemoting-1.20.0-beta.2/src/OpenTelemetry.Instrumentation.ServiceFabricRemoting/CHANGELOG.md) for details. ## 1.20.0-beta.1 * NuGet: [OpenTelemetry.Extensions.Enrichment v1.20.0-beta.1](https://www.nuget.org/packages/OpenTelemetry.Extensions.Enrichment/1.20.0-beta.1) * Updated OpenTelemetry core component version(s) to `1.20.0`. ([#5541](open-telemetry/opentelemetry-dotnet-contrib#5541)) See [CHANGELOG](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/blob/Extensions.Enrichment-1.20.0-beta.1/src/OpenTelemetry.Extensions.Enrichment/CHANGELOG.md) for details. ## 1.20.0-alpha.2 * NuGet: [OpenTelemetry.Instrumentation.EventCounters v1.20.0-alpha.2](https://www.nuget.org/packages/OpenTelemetry.Instrumentation.EventCounters/1.20.0-alpha.2) * Fixed a deadlock when an `EventSource` is created on another thread while the meter provider is being built or disposed. ([#5639](open-telemetry/opentelemetry-dotnet-contrib#5639)) See [CHANGELOG](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/blob/Instrumentation.EventCounters-1.20.0-alpha.2/src/OpenTelemetry.Instrumentation.EventCounters/CHANGELOG.md) for details. ## 1.20.0-alpha.1 * NuGet: [OpenTelemetry.Instrumentation.EventCounters v1.20.0-alpha.1](https://www.nuget.org/packages/OpenTelemetry.Instrumentation.EventCounters/1.20.0-alpha.1) * Added dependency injection support for EventCounters instrumentation. ([#5475](open-telemetry/opentelemetry-dotnet-contrib#5475)) * Updated OpenTelemetry core component version(s) to `1.20.0`. ([#5541](open-telemetry/opentelemetry-dotnet-contrib#5541)) See [CHANGELOG](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/blob/Instrumentation.EventCounters-1.20.0-alpha.1/src/OpenTelemetry.Instrumentation.EventCounters/CHANGELOG.md) for details. ## 1.19.1 * NuGet: [OpenTelemetry.Exporter.OneCollector v1.19.1](https://www.nuget.org/packages/OpenTelemetry.Exporter.OneCollector/1.19.1) * Updated OpenTelemetry core component version(s) to `1.19.1`. ([#5329](open-telemetry/opentelemetry-dotnet-contrib#5329)) See [CHANGELOG](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/blob/Exporter.OneCollector-1.19.1/src/OpenTelemetry.Exporter.OneCollector/CHANGELOG.md) for details. ## 1.19.1-rc.1 * NuGet: [OpenTelemetry.Resources.Process v1.19.1-rc.1](https://www.nuget.org/packages/OpenTelemetry.Resources.Process/1.19.1-rc.1) * Updated OpenTelemetry core component version(s) to `1.19.1`. ([#5329](open-telemetry/opentelemetry-dotnet-contrib#5329)) See [CHANGELOG](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/blob/Resources.Process-1.19.1-rc.1/src/OpenTelemetry.Resources.Process/CHANGELOG.md) for details. ## 1.19.1-beta.2 * NuGet: [OpenTelemetry.Resources.Azure v1.19.1-beta.2](https://www.nuget.org/packages/OpenTelemetry.Resources.Azure/1.19.1-beta.2) * Add `cloud.account.id` and `azure.resource_group.name` attributes to the Azure VM resource detector. ([#5195](open-telemetry/opentelemetry-dotnet-contrib#5195)) See [CHANGELOG](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/blob/Resources.Azure-1.19.1-beta.2/src/OpenTelemetry.Resources.Azure/CHANGELOG.md) for details. ## 1.19.1-beta.1 * NuGet: [OpenTelemetry.Exporter.Geneva v1.19.1-beta.1](https://www.nuget.org/packages/OpenTelemetry.Exporter.Geneva/1.19.1-beta.1) * Updated OpenTelemetry core component version(s) to `1.19.1`. ([#5329](open-telemetry/opentelemetry-dotnet-contrib#5329)) See [CHANGELOG](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/blob/Exporter.Geneva-1.19.1-beta.1/src/OpenTelemetry.Exporter.Geneva/CHANGELOG.md) for details. Commits viewable in [compare view](open-telemetry/opentelemetry-dotnet-contrib@Exporter.OneCollector-1.19.0...Exporter.Geneva-1.20.0). </details> Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`. [//]: # (dependabot-automerge-start) [//]: # (dependabot-automerge-end) --- <details> <summary>Dependabot commands and options</summary> <br /> You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot show <dependency name> ignore conditions` will show all of the ignore conditions of the specified dependency - `@dependabot ignore <dependency name> major version` will close this group update PR and stop Dependabot creating any more for the specific dependency's major version (unless you unignore this specific dependency's major version or upgrade to it yourself) - `@dependabot ignore <dependency name> minor version` will close this group update PR and stop Dependabot creating any more for the specific dependency's minor version (unless you unignore this specific dependency's minor version or upgrade to it yourself) - `@dependabot ignore <dependency name>` will close this group update PR and stop Dependabot creating any more for the specific dependency (unless you unignore this specific dependency or upgrade to it yourself) - `@dependabot unignore <dependency name>` will remove all of the ignore conditions of the specified dependency - `@dependabot unignore <dependency name> <ignore condition>` will remove the ignore condition of the specified dependency and ignore conditions </details>

Both PR and description AI assisted. I have reviewed both carefully.
Changes
Fix
SuppressInstrumentationScopereference-count state leaking between inheritedExecutionContext/async flows.The fix stores immutable suppression states in the runtime context slot. Common
reference counts are cached, preserving most of the allocation benefit of the
current implementation without sharing mutable state between async flows.
This change also adds regression coverage for:
Enter,IncrementIfTriggered, andDecrementIfTriggeredisolation whileparent and child async flows overlap.
Why this is needed
#4304
changed the slot from an
intto a mutableSuppressInstrumentationScopeinstance as a performance optimization. This avoided boxing an integer and
updating
AsyncLocal/ExecutionContextstate for every reference-count change.However, an
AsyncLocalreference value flows into a child execution context asthe same object reference. Mutating
Depthin place therefore mutates the valueobserved by the parent and sibling flows as well. Suppression may consequently
end too early or remain active too long, causing telemetry to be incorrectly
recorded or suppressed.
A test that lets the child increment and then decrement before checking the
parent does not expose the bug: the shared counter has already returned to its
starting value. The new tests coordinate the flows so the parent observes its
own state while the child's mutation is still active. These tests fail against
the mutable implementation.
The mutable implementation also changes nested-scope semantics. When a
reference count reaches zero inside
Begin(false), it restores the precedingscope immediately instead of waiting for the explicit scope to be disposed.
The immutable-state implementation retains the original value-slot behavior.
Implementation
slot.
state for normal nesting depths.
Slot.Setwhenever the reference count changes so each execution contextreceives its own value.
Performance
The original #4304 results show the cost that a direct return to
AsyncLocal<int>would reintroduce:
int)BeginscopesEnterreference-count cycleNew comparison benchmarks were run with BenchmarkDotNet 0.15.8 on .NET
10.0.12, Windows 11, and an Intel Core i9-13950HX. Runs were pinned to one
performance core, with 5 warmup and 15 measurement iterations.
intvalueEnter+ increment + two decrementsBeginscopesFor the active reference-count cycle, the immutable implementation costs about
25.1 ns and 104 B more than the unsafe mutable holder. A direct integer fix
would cost about 48.5 ns and 272 B more. The immutable cache therefore recovers
roughly half the time penalty and most of the additional allocation.
On .NET 10, nested scopes are faster than both alternatives because they reuse
the same immutable always-suppressed token. Redundant
AsyncLocalwrites becomeno-ops and the JIT can eliminate the short-lived scope allocations.
These are focused microbenchmarks. Normal non-triggered suppression checks do
not update the runtime context, and exporter work will usually dominate the
absolute scope-management cost.
Testing
CI
Merge requirement checklist
CHANGELOG.mdfiles updated for non-trivial changes (requires the new PR number)