Skip to content

Commit a681b6c

Browse files
Represent SDM Counters as Gauges In Prometheus Exposition Format (#4101)
Co-authored-by: kkeirstead <[email protected]>
1 parent 5a997db commit a681b6c

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

src/Microsoft.Diagnostics.Monitoring.WebApi/Metrics/MetricsStore.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,8 +200,8 @@ private static string GetMetricType(EventType eventType)
200200
{
201201
switch (eventType)
202202
{
203+
// In Prometheus, rates are treated as gauges due to their non-monotonic nature
203204
case EventType.Rate:
204-
return "counter";
205205
case EventType.Gauge:
206206
return "gauge";
207207
case EventType.Histogram:

src/Tests/Microsoft.Diagnostics.Monitoring.Tool.UnitTests/MetricsFormattingTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ public async Task CounterFormat_Test()
9999

100100
Assert.Equal(3, lines.Count);
101101
Assert.Equal($"# HELP {metricName}{payload.Unit} {payload.DisplayName}", lines[0]);
102-
Assert.Equal($"# TYPE {metricName} counter", lines[1]);
102+
Assert.Equal($"# TYPE {metricName} gauge", lines[1]);
103103
Assert.Equal($"{metricName} {payload.Value} {new DateTimeOffset(payload.Timestamp).ToUnixTimeMilliseconds()}", lines[2]);
104104
}
105105

0 commit comments

Comments
 (0)