Skip to content

Fix memory pool metrics unit to follow standard #62766

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 19, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions src/Servers/Kestrel/Core/test/PinnedBlockMemoryPoolTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ public async Task EvictionsAreScheduled()
public void CurrentMemoryMetricTracksPooledMemory()
{
var testMeterFactory = new TestMeterFactory();
using var currentMemoryMetric = new MetricCollector<long>(testMeterFactory, "Microsoft.AspNetCore.MemoryPool", "aspnetcore.memorypool.current_memory");
using var currentMemoryMetric = new MetricCollector<long>(testMeterFactory, "Microsoft.AspNetCore.MemoryPool", "aspnetcore.memory_pool.current_memory");

var pool = new PinnedBlockMemoryPool(testMeterFactory);

Expand Down Expand Up @@ -267,7 +267,7 @@ public void CurrentMemoryMetricTracksPooledMemory()
public void TotalAllocatedMetricTracksAllocatedMemory()
{
var testMeterFactory = new TestMeterFactory();
using var totalMemoryMetric = new MetricCollector<long>(testMeterFactory, "Microsoft.AspNetCore.MemoryPool", "aspnetcore.memorypool.total_allocated");
using var totalMemoryMetric = new MetricCollector<long>(testMeterFactory, "Microsoft.AspNetCore.MemoryPool", "aspnetcore.memory_pool.total_allocated");

var pool = new PinnedBlockMemoryPool(testMeterFactory);

Expand All @@ -290,7 +290,7 @@ public void TotalAllocatedMetricTracksAllocatedMemory()
public void TotalRentedMetricTracksRentOperations()
{
var testMeterFactory = new TestMeterFactory();
using var rentMetric = new MetricCollector<long>(testMeterFactory, "Microsoft.AspNetCore.MemoryPool", "aspnetcore.memorypool.total_rented");
using var rentMetric = new MetricCollector<long>(testMeterFactory, "Microsoft.AspNetCore.MemoryPool", "aspnetcore.memory_pool.total_rented");

var pool = new PinnedBlockMemoryPool(testMeterFactory);

Expand All @@ -315,7 +315,7 @@ public void TotalRentedMetricTracksRentOperations()
public void EvictedMemoryMetricTracksEvictedMemory()
{
var testMeterFactory = new TestMeterFactory();
using var evictMetric = new MetricCollector<long>(testMeterFactory, "Microsoft.AspNetCore.MemoryPool", "aspnetcore.memorypool.evicted_memory");
using var evictMetric = new MetricCollector<long>(testMeterFactory, "Microsoft.AspNetCore.MemoryPool", "aspnetcore.memory_pool.evicted_memory");

var pool = new PinnedBlockMemoryPool(testMeterFactory);

Expand Down Expand Up @@ -352,7 +352,7 @@ public void EvictedMemoryMetricTracksEvictedMemory()
public void MetricsAreAggregatedAcrossPoolsWithSameMeterFactory()
{
var testMeterFactory = new TestMeterFactory();
using var rentMetric = new MetricCollector<long>(testMeterFactory, "Microsoft.AspNetCore.MemoryPool", "aspnetcore.memorypool.total_rented");
using var rentMetric = new MetricCollector<long>(testMeterFactory, "Microsoft.AspNetCore.MemoryPool", "aspnetcore.memory_pool.total_rented");

var pool1 = new PinnedBlockMemoryPool(testMeterFactory);
var pool2 = new PinnedBlockMemoryPool(testMeterFactory);
Expand Down
16 changes: 8 additions & 8 deletions src/Shared/Buffers.MemoryPool/PinnedBlockMemoryPoolMetrics.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,23 +22,23 @@ public PinnedBlockMemoryPoolMetrics(IMeterFactory meterFactory)
_meter = meterFactory.Create(MeterName);

_currentMemory = _meter.CreateUpDownCounter<long>(
"aspnetcore.memorypool.current_memory",
unit: "{bytes}",
"aspnetcore.memory_pool.current_memory",
unit: "By",
description: "Number of bytes that are currently pooled by the pool.");

_totalAllocatedMemory = _meter.CreateCounter<long>(
"aspnetcore.memorypool.total_allocated",
unit: "{bytes}",
"aspnetcore.memory_pool.total_allocated",
unit: "By",
description: "Total number of allocations made by the pool.");

_evictedMemory = _meter.CreateCounter<long>(
"aspnetcore.memorypool.evicted_memory",
unit: "{bytes}",
"aspnetcore.memory_pool.evicted_memory",
unit: "By",
description: "Total number of bytes that have been evicted.");

_totalRented = _meter.CreateCounter<long>(
"aspnetcore.memorypool.total_rented",
unit: "{bytes}",
"aspnetcore.memory_pool.total_rented",
unit: "By",
description: "Total number of rented bytes from the pool.");
}

Expand Down
Loading