Skip to content

Commit b9f43c1

Browse files
authored
Fix memory pool metrics unit to follow standard (#62766)
1 parent 57d1093 commit b9f43c1

File tree

2 files changed

+13
-13
lines changed

2 files changed

+13
-13
lines changed

src/Servers/Kestrel/Core/test/PinnedBlockMemoryPoolTests.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ public async Task EvictionsAreScheduled()
231231
public void CurrentMemoryMetricTracksPooledMemory()
232232
{
233233
var testMeterFactory = new TestMeterFactory();
234-
using var currentMemoryMetric = new MetricCollector<long>(testMeterFactory, "Microsoft.AspNetCore.MemoryPool", "aspnetcore.memorypool.current_memory");
234+
using var currentMemoryMetric = new MetricCollector<long>(testMeterFactory, "Microsoft.AspNetCore.MemoryPool", "aspnetcore.memory_pool.current_memory");
235235

236236
var pool = new PinnedBlockMemoryPool(testMeterFactory);
237237

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

272272
var pool = new PinnedBlockMemoryPool(testMeterFactory);
273273

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

295295
var pool = new PinnedBlockMemoryPool(testMeterFactory);
296296

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

320320
var pool = new PinnedBlockMemoryPool(testMeterFactory);
321321

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

357357
var pool1 = new PinnedBlockMemoryPool(testMeterFactory);
358358
var pool2 = new PinnedBlockMemoryPool(testMeterFactory);

src/Shared/Buffers.MemoryPool/PinnedBlockMemoryPoolMetrics.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,23 +22,23 @@ public PinnedBlockMemoryPoolMetrics(IMeterFactory meterFactory)
2222
_meter = meterFactory.Create(MeterName);
2323

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

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

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

3939
_totalRented = _meter.CreateCounter<long>(
40-
"aspnetcore.memorypool.total_rented",
41-
unit: "{bytes}",
40+
"aspnetcore.memory_pool.total_rented",
41+
unit: "By",
4242
description: "Total number of rented bytes from the pool.");
4343
}
4444

0 commit comments

Comments
 (0)