diff --git a/src/OpenTelemetry.Instrumentation.Runtime/CHANGELOG.md b/src/OpenTelemetry.Instrumentation.Runtime/CHANGELOG.md index b4ebd994c6..3aad6068f5 100644 --- a/src/OpenTelemetry.Instrumentation.Runtime/CHANGELOG.md +++ b/src/OpenTelemetry.Instrumentation.Runtime/CHANGELOG.md @@ -4,6 +4,8 @@ * Change API for GC Heap Size for .NET 6 where the API has a bug ([#495](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/pull/495)) +* Remove gc.heap.fragmentation.size metrics due to buggy API on .NET 6 + ([#509](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/pull/509)) ## 1.0.0-rc.1 diff --git a/src/OpenTelemetry.Instrumentation.Runtime/README.md b/src/OpenTelemetry.Instrumentation.Runtime/README.md index 8ecb0aa67f..c56c41df6b 100644 --- a/src/OpenTelemetry.Instrumentation.Runtime/README.md +++ b/src/OpenTelemetry.Instrumentation.Runtime/README.md @@ -103,6 +103,9 @@ Note: `ObservableGauge` should be changed to `ObservableUpDownCounter` once avai as `ObservableUpDownCounter` is the best fit of instrument type. The same applies to all the `ObservableGauge` below. +Note: `gc.heap.fragmentation.size` metrics is removed for .NET 6 because of a +[bug](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/issues/496). + The APIs used to retrieve the values are: * [GCMemoryInfo.TotalCommittedBytes](https://docs.microsoft.com/dotnet/api/system.gcmemoryinfo.totalcommittedbytes): diff --git a/src/OpenTelemetry.Instrumentation.Runtime/RuntimeMetrics.cs b/src/OpenTelemetry.Instrumentation.Runtime/RuntimeMetrics.cs index a43d572d6d..552e2b1b87 100644 --- a/src/OpenTelemetry.Instrumentation.Runtime/RuntimeMetrics.cs +++ b/src/OpenTelemetry.Instrumentation.Runtime/RuntimeMetrics.cs @@ -121,7 +121,10 @@ static RuntimeMetrics() unit: "bytes", description: "The heap size (including fragmentation), as observed during the latest garbage collection. The value will be unavailable until at least one garbage collection has occurred."); } +#endif +#if NET7_0_OR_GREATER + // TODO: Not valid until .NET 7 where the bug is fixed. See context in https://github.com/open-telemetry/opentelemetry-dotnet-contrib/issues/496 // TODO: change to ObservableUpDownCounter MeterInstance.CreateObservableGauge( $"{metricPrefix}gc.heap.fragmentation.size",