Skip to content

Commit 7ffeb43

Browse files
authored
Rename metrics tag exception.type to error.type (#51084)
1 parent 4d10dca commit 7ffeb43

File tree

9 files changed

+13
-13
lines changed

9 files changed

+13
-13
lines changed

src/Hosting/Hosting/src/Internal/HostingMetrics.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,10 @@ public void RequestEnd(string protocol, bool isHttps, string scheme, string meth
7171
tags.Add("http.route", route);
7272
}
7373
// This exception is only present if there is an unhandled exception.
74-
// An exception caught by ExceptionHandlerMiddleware and DeveloperExceptionMiddleware isn't thrown to here. Instead, those middleware add exception.type to custom tags.
74+
// An exception caught by ExceptionHandlerMiddleware and DeveloperExceptionMiddleware isn't thrown to here. Instead, those middleware add error.type to custom tags.
7575
if (exception != null)
7676
{
77-
tags.Add("exception.type", exception.GetType().FullName);
77+
tags.Add("error.type", exception.GetType().FullName);
7878
}
7979
if (customTags != null)
8080
{

src/Hosting/Hosting/test/HostingMetricsTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,11 +97,11 @@ static void AssertRequestDuration(CollectedMeasurement<double> measurement, stri
9797
Assert.Equal(statusCode, (int)measurement.Tags["http.response.status_code"]);
9898
if (exceptionName == null)
9999
{
100-
Assert.False(measurement.Tags.ContainsKey("exception.type"));
100+
Assert.False(measurement.Tags.ContainsKey("error.type"));
101101
}
102102
else
103103
{
104-
Assert.Equal(exceptionName, (string)measurement.Tags["exception.type"]);
104+
Assert.Equal(exceptionName, (string)measurement.Tags["error.type"]);
105105
}
106106
if (unhandledRequest ?? false)
107107
{

src/Middleware/Diagnostics/src/DiagnosticsMetrics.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public void RequestException(string exceptionName, ExceptionResult result, strin
3939
private void RequestExceptionCore(string exceptionName, ExceptionResult result, string? handler)
4040
{
4141
var tags = new TagList();
42-
tags.Add("exception.type", exceptionName);
42+
tags.Add("error.type", exceptionName);
4343
tags.Add("aspnetcore.diagnostics.exception.result", GetExceptionResult(result));
4444
if (handler != null)
4545
{

src/Middleware/Diagnostics/src/DiagnosticsTelemetry.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public static void ReportUnhandledException(ILogger logger, HttpContext context,
1515

1616
if (context.Features.Get<IHttpMetricsTagsFeature>() is { } tagsFeature)
1717
{
18-
tagsFeature.Tags.Add(new KeyValuePair<string, object?>("exception.type", ex.GetType().FullName));
18+
tagsFeature.Tags.Add(new KeyValuePair<string, object?>("error.type", ex.GetType().FullName));
1919
}
2020
}
2121
}

src/Middleware/Diagnostics/test/UnitTests/DeveloperExceptionPageMiddlewareTest.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -579,7 +579,7 @@ public async Task UnhandledError_ExceptionNameTagAdded()
579579
{
580580
Assert.True(m.Value > 0);
581581
Assert.Equal(500, (int)m.Tags["http.response.status_code"]);
582-
Assert.Equal("System.Exception", (string)m.Tags["exception.type"]);
582+
Assert.Equal("System.Exception", (string)m.Tags["error.type"]);
583583
});
584584
Assert.Collection(requestExceptionCollector.GetMeasurementSnapshot(),
585585
m => AssertRequestException(m, "System.Exception", "unhandled"));
@@ -588,7 +588,7 @@ public async Task UnhandledError_ExceptionNameTagAdded()
588588
private static void AssertRequestException(CollectedMeasurement<long> measurement, string exceptionName, string result, string handler = null)
589589
{
590590
Assert.Equal(1, measurement.Value);
591-
Assert.Equal(exceptionName, (string)measurement.Tags["exception.type"]);
591+
Assert.Equal(exceptionName, (string)measurement.Tags["error.type"]);
592592
Assert.Equal(result, measurement.Tags["aspnetcore.diagnostics.exception.result"].ToString());
593593
if (handler == null)
594594
{

src/Middleware/Diagnostics/test/UnitTests/ExceptionHandlerMiddlewareTest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,7 @@ public async Task Metrics_ExceptionThrown_Unhandled_Reported()
318318
private static void AssertRequestException(CollectedMeasurement<long> measurement, string exceptionName, string result, string handler = null)
319319
{
320320
Assert.Equal(1, measurement.Value);
321-
Assert.Equal(exceptionName, (string)measurement.Tags["exception.type"]);
321+
Assert.Equal(exceptionName, (string)measurement.Tags["error.type"]);
322322
Assert.Equal(result, measurement.Tags["aspnetcore.diagnostics.exception.result"].ToString());
323323
if (handler == null)
324324
{

src/Middleware/Diagnostics/test/UnitTests/ExceptionHandlerTest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -962,7 +962,7 @@ public async Task UnhandledError_ExceptionNameTagAdded()
962962
{
963963
Assert.True(m.Value > 0);
964964
Assert.Equal(404, (int)m.Tags["http.response.status_code"]);
965-
Assert.Equal("System.Exception", (string)m.Tags["exception.type"]);
965+
Assert.Equal("System.Exception", (string)m.Tags["error.type"]);
966966
});
967967
}
968968
}

src/Servers/Kestrel/Core/src/Internal/Infrastructure/KestrelMetrics.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ private void ConnectionStopCore(in ConnectionMetricsContext metricsContext, Exce
116116
{
117117
if (exception != null)
118118
{
119-
tags.Add("exception.type", exception.GetType().FullName);
119+
tags.Add("error.type", exception.GetType().FullName);
120120
}
121121

122122
// Add custom tags for duration.
@@ -298,7 +298,7 @@ private void TlsHandshakeStopCore(in ConnectionMetricsContext metricsContext, lo
298298
}
299299
if (exception != null)
300300
{
301-
tags.Add("exception.type", exception.GetType().FullName);
301+
tags.Add("error.type", exception.GetType().FullName);
302302
}
303303

304304
var duration = Stopwatch.GetElapsedTime(startTimestamp, currentTimestamp);

src/Servers/Kestrel/test/InMemory.FunctionalTests/KestrelMetricsTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ public async Task Http1Connection_Error()
273273
Assert.Collection(connectionDuration.GetMeasurementSnapshot(), m =>
274274
{
275275
AssertDuration(m, "127.0.0.1", localPort: 0, "tcp", "ipv4", httpVersion: null);
276-
Assert.Equal("System.InvalidOperationException", (string)m.Tags["exception.type"]);
276+
Assert.Equal("System.InvalidOperationException", (string)m.Tags["error.type"]);
277277
});
278278
Assert.Collection(activeConnections.GetMeasurementSnapshot(), m => AssertCount(m, 1, "127.0.0.1", localPort: 0, "tcp", "ipv4"), m => AssertCount(m, -1, "127.0.0.1", localPort: 0, "tcp", "ipv4"));
279279
Assert.Collection(queuedConnections.GetMeasurementSnapshot(), m => AssertCount(m, 1, "127.0.0.1", localPort: 0, "tcp", "ipv4"), m => AssertCount(m, -1, "127.0.0.1", localPort: 0, "tcp", "ipv4"));

0 commit comments

Comments
 (0)