Skip to content

Commit 3b1c27d

Browse files
committed
align metric names to Serilog conventions
1 parent 5f1b3b2 commit 3b1c27d

1 file changed

Lines changed: 17 additions & 27 deletions

File tree

src/Roastery/Metrics/RoasteryMetrics.cs

Lines changed: 17 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,14 @@ public class Sample
2323
4. Add support in `ToLogEvents` for the new metric.
2424
*/
2525

26-
// `http.request.duration`: histogram
26+
// `HttpRequestDuration`: histogram
2727
public record struct HttpRequestDurationKey(string Path, int StatusCode);
2828
public readonly Dictionary<HttpRequestDurationKey, ExponentialHistogram> HttpRequestDuration = new();
2929

30-
// `orders.created`: counter
30+
// `OrdersCreated`: counter
3131
public ulong OrdersCreated;
3232

33-
// `orders.shipped`: counter
33+
// `OrdersShipped`: counter
3434
public ulong OrdersShipped;
3535

3636
static readonly MessageTemplate Template = new MessageTemplateParser().Parse("Metrics sampled");
@@ -45,27 +45,20 @@ public IEnumerable<LogEvent> ToLogEvents(ILogger logger, PropertyNameMapping pro
4545
timestamp,
4646
new Dictionary<string, object>
4747
{
48-
{ "http.request.duration", new { kind = "Exponential", unit = "ms", description = "The time taken to fully process a request" } }
48+
{ "HttpRequestDuration", new { kind = "Exponential", unit = "ms", description = "The time taken to fully process a request" } }
4949
},
5050
new
5151
{
52-
http = new
53-
{
54-
request = new
55-
{
56-
duration = new
57-
{
58-
buckets = metric.Buckets
59-
.Select(bucket => new { midpoint = bucket.Key, count = bucket.Value }).ToArray(),
60-
scale = metric.Scale,
61-
min = metric.Min,
62-
max = metric.Max,
63-
count = metric.Total
64-
}
65-
}
52+
HttpRequestDuration = new {
53+
buckets = metric.Buckets
54+
.Select(bucket => new { midpoint = bucket.Key, count = bucket.Value }).ToArray(),
55+
scale = metric.Scale,
56+
min = metric.Min,
57+
max = metric.Max,
58+
count = metric.Total
6659
},
67-
path = key.Path,
68-
statusCode = key.StatusCode
60+
key.Path,
61+
key.StatusCode
6962
}
7063
);
7164
}
@@ -76,16 +69,13 @@ public IEnumerable<LogEvent> ToLogEvents(ILogger logger, PropertyNameMapping pro
7669
timestamp,
7770
new Dictionary<string, object>
7871
{
79-
{ "orders.created", new { kind = "Counter", unit = "orders", description = "The total number of orders created in the system" } },
80-
{ "orders.shipped", new { kind = "Counter", unit = "orders", description = "The total number of orders shipped in the system" } }
72+
{ "OrdersCreated", new { kind = "Counter", unit = "orders", description = "The total number of orders created in the system" } },
73+
{ "OrdersShipped", new { kind = "Counter", unit = "orders", description = "The total number of orders shipped in the system" } }
8174
},
8275
new
8376
{
84-
orders = new
85-
{
86-
created = OrdersCreated,
87-
shipped = OrdersShipped
88-
}
77+
OrdersCreated,
78+
OrdersShipped
8979
}
9080
);
9181
}

0 commit comments

Comments
 (0)