From d509f11377d7b195865dbd8f8f9e3f41be9033df Mon Sep 17 00:00:00 2001 From: Julian Wreford Date: Thu, 30 Jan 2025 11:01:14 +0000 Subject: [PATCH 1/3] The attribute for both `dotnet.gc.collections` and `dotnet.gc.last_collection.heap.size` should be called gc.heap.generation See DotNet repository - https://github.com/dotnet/runtime/blob/adf123c23ee42262515c36562b09fa0b19959599/src/libraries/System.Diagnostics.DiagnosticSource/src/System/Diagnostics/Metrics/RuntimeMetrics.cs#L191C110-L191C128 --- docs/core/diagnostics/built-in-metrics-runtime.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/core/diagnostics/built-in-metrics-runtime.md b/docs/core/diagnostics/built-in-metrics-runtime.md index fb68ea03895a7..19c7c790e3054 100644 --- a/docs/core/diagnostics/built-in-metrics-runtime.md +++ b/docs/core/diagnostics/built-in-metrics-runtime.md @@ -49,7 +49,7 @@ Available starting in: .NET 9.0. | Attribute | Type | Description | Examples | Presence | |---|---|---|---|---| -| `dotnet.gc.heap.generation` | string | Name of the maximum managed heap generation being collected. | `gen0`; `gen1`; `gen2` | Always | +| `gc.heap.generation` | string | Name of the maximum managed heap generation being collected. | `gen0`; `gen1`; `gen2` | Always | The .NET GC is a generational garbage collector. Each time the garbage collector runs, it uses heuristics to select a maximum generation and then collects objects in all generations up to the selected maximum. For example, a `gen1` collection collects all objects in generations 0 and 1. A `gen2` collection collects all objects in generations 0, 1, and 2. For more information about the .NET GC and generational garbage collection, see the [.NET garbage collection guide](../../standard/garbage-collection/fundamentals.md#generations). @@ -83,7 +83,7 @@ Available starting in: .NET 9.0. | Attribute | Type | Description | Examples | Presence | |---|---|---|---|---| -| `dotnet.gc.heap.generation` | string | Name of the garbage collector managed heap generation. | `gen0`; `gen1`; `gen2`;`loh`;`poh` | Always | +| `gc.heap.generation` | string | Name of the garbage collector managed heap generation. | `gen0`; `gen1`; `gen2`;`loh`;`poh` | Always | The .NET GC divides the heap into generations. In addition to the standard numbered generations, the GC also puts some objects into two special generations: From 6c1c47dc45b7c86cfe2278cac2580cb64856049c Mon Sep 17 00:00:00 2001 From: Julian Wreford Date: Thu, 30 Jan 2025 11:03:50 +0000 Subject: [PATCH 2/3] The metric `dotnet.gc.last_collection.heap.fragmentation.size` has a similar attribute of `gc.heap.generation` See https://github.com/dotnet/runtime/blob/adf123c23ee42262515c36562b09fa0b19959599/src/libraries/System.Diagnostics.DiagnosticSource/src/System/Diagnostics/Metrics/RuntimeMetrics.cs#L195-L203 --- docs/core/diagnostics/built-in-metrics-runtime.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/docs/core/diagnostics/built-in-metrics-runtime.md b/docs/core/diagnostics/built-in-metrics-runtime.md index 19c7c790e3054..d5ef76017e670 100644 --- a/docs/core/diagnostics/built-in-metrics-runtime.md +++ b/docs/core/diagnostics/built-in-metrics-runtime.md @@ -100,6 +100,10 @@ Available starting in: .NET 9.0. | -------- | --------------- | ----------- | -------------- | | `dotnet.gc.last_collection.heap.fragmentation.size` | UpDownCounter | `By` | The heap fragmentation, as observed during the latest garbage collection. | +| Attribute | Type | Description | Examples | Presence | +|---|---|---|---|---| +| `gc.heap.generation` | string | Name of the garbage collector managed heap generation. | `gen0`; `gen1`; `gen2`;`loh`;`poh` | Always | + This metric reports the same values as calling . When .NET objects are allocated, initially they tend to be laid out contiguously in memory. However, if some of those objects are later collected by the GC, this creates gaps of unused memory between the live objects that remain. These gaps represent the portion of the GC heap that's not currently being used to store objects, often called "fragmentation." The GC can reuse the fragmentation bytes in the future for new object allocations if the object size is small enough to fit in one of the gaps. The GC can also perform a special compacting garbage collection that moves remaining live objects next to each other as long as the objects haven't been pinned in place. From c10f703033f9e51fb57e650c33f49c56b66e80e8 Mon Sep 17 00:00:00 2001 From: Genevieve Warren <24882762+gewarren@users.noreply.github.com> Date: Tue, 18 Feb 2025 14:33:35 -0800 Subject: [PATCH 3/3] Apply suggestions from code review --- docs/core/diagnostics/built-in-metrics-runtime.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/core/diagnostics/built-in-metrics-runtime.md b/docs/core/diagnostics/built-in-metrics-runtime.md index d5ef76017e670..fab4da8c6e4fc 100644 --- a/docs/core/diagnostics/built-in-metrics-runtime.md +++ b/docs/core/diagnostics/built-in-metrics-runtime.md @@ -83,7 +83,7 @@ Available starting in: .NET 9.0. | Attribute | Type | Description | Examples | Presence | |---|---|---|---|---| -| `gc.heap.generation` | string | Name of the garbage collector managed heap generation. | `gen0`; `gen1`; `gen2`;`loh`;`poh` | Always | +| `gc.heap.generation` | string | Name of the garbage collector managed heap generation. | `gen0`; `gen1`; `gen2`; `loh`; `poh` | Always | The .NET GC divides the heap into generations. In addition to the standard numbered generations, the GC also puts some objects into two special generations: @@ -102,7 +102,7 @@ Available starting in: .NET 9.0. | Attribute | Type | Description | Examples | Presence | |---|---|---|---|---| -| `gc.heap.generation` | string | Name of the garbage collector managed heap generation. | `gen0`; `gen1`; `gen2`;`loh`;`poh` | Always | +| `gc.heap.generation` | string | Name of the garbage collector managed heap generation. | `gen0`; `gen1`; `gen2`; `loh`; `poh` | Always | This metric reports the same values as calling .