Skip to content

Commit

Permalink
[Instrumentation.Runtime] Reintroduce current heap size metric (#683)
Browse files Browse the repository at this point in the history
  • Loading branch information
lachmatt authored Nov 16, 2022
1 parent b3a921a commit 679d871
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/OpenTelemetry.Instrumentation.Runtime/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@

This does not affect applications targeting .NET Framework.

* Add "process.runtime.dotnet.gc.objects.size" metric
([#683](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/pull/683))

## 1.0.0

Released 2022-Aug-03
Expand Down
6 changes: 6 additions & 0 deletions src/OpenTelemetry.Instrumentation.Runtime/RuntimeMetrics.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,12 @@ static RuntimeMetrics()
() => GetGarbageCollectionCounts(),
description: "Number of garbage collections that have occurred since process start.");

MeterInstance.CreateObservableUpDownCounter(
"process.runtime.dotnet.gc.objects.size",
() => GC.GetTotalMemory(false),
unit: "bytes",
description: "Count of bytes currently in use by objects in the GC heap that haven't been collected yet. Fragmentation and other GC committed memory pools are excluded.");

#if NET6_0_OR_GREATER
MeterInstance.CreateObservableCounter(
"process.runtime.dotnet.gc.allocations.size",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@ public void GcMetricsTest()
var gcCountMetric = exportedItems.FirstOrDefault(i => i.Name == "process.runtime.dotnet.gc.collections.count");
Assert.NotNull(gcCountMetric);

var totalObjectsSize = exportedItems.FirstOrDefault(i => i.Name == "process.runtime.dotnet.gc.objects.size");
Assert.NotNull(totalObjectsSize);

#if NET6_0_OR_GREATER

var gcAllocationSizeMetric = exportedItems.FirstOrDefault(i => i.Name == "process.runtime.dotnet.gc.allocations.size");
Expand Down

0 comments on commit 679d871

Please sign in to comment.