Skip to content

Commit 1ecc29c

Browse files
authored
Merge branch 'open-telemetry:main' into main
2 parents 3e6af87 + f25ff3a commit 1ecc29c

File tree

15 files changed

+308
-165
lines changed

15 files changed

+308
-165
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ extension scenarios:
9898

9999
See [CONTRIBUTING.md](CONTRIBUTING.md)
100100

101-
We meet weekly on Tuesdays, and the time of the meeting alternates between 11AM
101+
We meet weekly on Tuesdays, and the time of the meeting alternates between 9AM
102102
PT and 4PM PT. The meeting is subject to change depending on contributors'
103103
availability. Check the [OpenTelemetry community
104104
calendar](https://calendar.google.com/calendar/embed?src=google.com_b79e3e90j7bbsa2n2p5an5lf60%40group.calendar.google.com)

src/OpenTelemetry.Instrumentation.AspNetCore/CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22

33
## Unreleased
44

5+
* Removed the Activity Status Description that was being set during
6+
exceptions. Activity Status will continue to be reported as `Error`.
7+
This is a **breaking change**. `EnrichWithException` can be leveraged
8+
to restore this behavior.
9+
([#5025](https://github.com/open-telemetry/opentelemetry-dotnet/pull/5025))
10+
511
* Updated `http.request.method` to match specification guidelines.
612
* For activity, if the method does not belong to one of the [known
713
values](https://github.com/open-telemetry/semantic-conventions/blob/v1.22.0/docs/http/http-spans.md#:~:text=http.request.method%20has%20the%20following%20list%20of%20well%2Dknown%20values)

src/OpenTelemetry.Instrumentation.AspNetCore/Implementation/HttpInListener.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -435,7 +435,7 @@ public void OnException(Activity activity, object payload)
435435
activity.RecordException(exc);
436436
}
437437

438-
activity.SetStatus(ActivityStatusCode.Error, exc.Message);
438+
activity.SetStatus(ActivityStatusCode.Error);
439439

440440
try
441441
{

src/OpenTelemetry.Instrumentation.Http/CHANGELOG.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22

33
## Unreleased
44

5+
* Removed the Activity Status Description that was being set during
6+
exceptions. Activity Status will continue to be reported as `Error`.
7+
This is a **breaking change**. `EnrichWithException` can be leveraged
8+
to restore this behavior.
9+
([#5025](https://github.com/open-telemetry/opentelemetry-dotnet/pull/5025))
10+
511
* Updated `http.request.method` to match specification guidelines.
612
* For activity, if the method does not belong to one of the [known
713
values](https://github.com/open-telemetry/semantic-conventions/blob/v1.22.0/docs/http/http-spans.md#:~:text=http.request.method%20has%20the%20following%20list%20of%20well%2Dknown%20values)
@@ -18,6 +24,22 @@
1824
`http` or `http/dup`.
1925
([#5003](https://github.com/open-telemetry/opentelemetry-dotnet/pull/5003))
2026

27+
* An additional attribute `error.type` will be added to activity and
28+
`http.client.request.duration` metric in case of failed requests as per the
29+
[specification](https://github.com/open-telemetry/semantic-conventions/blob/v1.23.0/docs/http/http-spans.md#common-attributes).
30+
31+
Users moving to `net8.0` or newer frameworks from lower versions will see
32+
difference in values in case of an exception. `net8.0` or newer frameworks add
33+
the ability to further drill down the exceptions to a specific type through
34+
[HttpRequestError](https://learn.microsoft.com/dotnet/api/system.net.http.httprequesterror?view=net-8.0)
35+
enum. For lower versions, the individual types will be rolled in to a single
36+
type. This could be a **breaking change** if alerts are set based on the values.
37+
38+
The attribute will only be added when `OTEL_SEMCONV_STABILITY_OPT_IN`
39+
environment variable is set to `http` or `http/dup`.
40+
41+
([#5005](https://github.com/open-telemetry/opentelemetry-dotnet/pull/5005))
42+
2143
## 1.6.0-beta.2
2244

2345
Released 2023-Oct-26

src/OpenTelemetry.Instrumentation.Http/Implementation/HttpHandlerDiagnosticListener.cs

Lines changed: 44 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,11 @@ public void OnStopActivity(Activity activity, object payload)
271271

272272
if (TryFetchResponse(payload, out HttpResponseMessage response))
273273
{
274+
if (currentStatusCode == ActivityStatusCode.Unset)
275+
{
276+
activity.SetStatus(SpanHelper.ResolveSpanStatusForHttpStatusCode(activity.Kind, (int)response.StatusCode));
277+
}
278+
274279
if (this.emitOldAttributes)
275280
{
276281
activity.SetTag(SemanticConventions.AttributeHttpStatusCode, TelemetryHelper.GetBoxedStatusCode(response.StatusCode));
@@ -279,11 +284,10 @@ public void OnStopActivity(Activity activity, object payload)
279284
if (this.emitNewAttributes)
280285
{
281286
activity.SetTag(SemanticConventions.AttributeHttpResponseStatusCode, TelemetryHelper.GetBoxedStatusCode(response.StatusCode));
282-
}
283-
284-
if (currentStatusCode == ActivityStatusCode.Unset)
285-
{
286-
activity.SetStatus(SpanHelper.ResolveSpanStatusForHttpStatusCode(activity.Kind, (int)response.StatusCode));
287+
if (activity.Status == ActivityStatusCode.Error)
288+
{
289+
activity.SetTag(SemanticConventions.AttributeErrorType, TelemetryHelper.GetBoxedStatusCode(response.StatusCode));
290+
}
287291
}
288292

289293
try
@@ -337,14 +341,19 @@ public void OnException(Activity activity, object payload)
337341
return;
338342
}
339343

344+
if (this.emitNewAttributes)
345+
{
346+
activity.SetTag(SemanticConventions.AttributeErrorType, GetErrorType(exc));
347+
}
348+
340349
if (this.options.RecordException)
341350
{
342351
activity.RecordException(exc);
343352
}
344353

345354
if (exc is HttpRequestException)
346355
{
347-
activity.SetStatus(ActivityStatusCode.Error, exc.Message);
356+
activity.SetStatus(ActivityStatusCode.Error);
348357
}
349358

350359
try
@@ -372,4 +381,33 @@ static bool TryFetchException(object payload, out Exception exc)
372381
return true;
373382
}
374383
}
384+
385+
private static string GetErrorType(Exception exc)
386+
{
387+
#if NET8_0_OR_GREATER
388+
// For net8.0 and above exception type can be found using HttpRequestError.
389+
// https://learn.microsoft.com/dotnet/api/system.net.http.httprequesterror?view=net-8.0
390+
if (exc is HttpRequestException httpRequestException)
391+
{
392+
return httpRequestException.HttpRequestError switch
393+
{
394+
HttpRequestError.NameResolutionError => "name_resolution_error",
395+
HttpRequestError.ConnectionError => "connection_error",
396+
HttpRequestError.SecureConnectionError => "secure_connection_error",
397+
HttpRequestError.HttpProtocolError => "http_protocol_error",
398+
HttpRequestError.ExtendedConnectNotSupported => "extended_connect_not_supported",
399+
HttpRequestError.VersionNegotiationError => "version_negotiation_error",
400+
HttpRequestError.UserAuthenticationError => "user_authentication_error",
401+
HttpRequestError.ProxyTunnelError => "proxy_tunnel_error",
402+
HttpRequestError.InvalidResponse => "invalid_response",
403+
HttpRequestError.ResponseEnded => "response_ended",
404+
HttpRequestError.ConfigurationLimitExceeded => "configuration_limit_exceeded",
405+
406+
// Fall back to the exception type name in case of HttpRequestError.Unknown
407+
_ => exc.GetType().FullName,
408+
};
409+
}
410+
#endif
411+
return exc.GetType().FullName;
412+
}
375413
}

0 commit comments

Comments
 (0)