Skip to content

Commit

Permalink
Merge branch 'main' into alanwest/fix-activity-http-route
Browse files Browse the repository at this point in the history
  • Loading branch information
alanwest committed Nov 9, 2023
2 parents 9d32b66 + 0a989a9 commit eb1f2ce
Show file tree
Hide file tree
Showing 39 changed files with 3,673 additions and 174 deletions.
23 changes: 14 additions & 9 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -16,23 +16,24 @@
<PackageVersion Include="Microsoft.AspNetCore.Http.Abstractions" Version="[2.1.1,6.0)" />
<PackageVersion Include="Microsoft.AspNetCore.Http.Features" Version="[2.1.1,6.0)" />
<PackageVersion Include="Microsoft.CSharp" Version="[4.7.0]" />
<PackageVersion Include="Microsoft.Extensions.Configuration" Version="[3.1.0,)" />
<PackageVersion Include="Microsoft.Extensions.DependencyInjection" Version="[3.1.0,)" />
<PackageVersion Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="[3.1.0,)" />
<PackageVersion Include="Microsoft.Extensions.Hosting.Abstractions" Version="[2.1.0,)" />

<!--
Typically, the latest stable version of Microsoft.Extensions.Logging should be used here because:
1) Each major version bump will have some new API capabilities (e.g. .NET 6 introduced compile-time logging
Typically, for the Microsoft.Extensions.* packages relating to DI Abstractions, Hosting Abstractions, and Logging,
the latest stable version should be used because:
1) Each major version bump will have some new API capabilities (e.g.For Logging, .NET 6 introduced compile-time logging
source generation, .NET 8 introduced automatic event id generation).
2) Each minor version bump is normally security hotfixes or critical bug fixes.
3) Since version 3.1.0, the .NET runtime team is holding a high bar for backward compatibility on
Microsoft.Extensions.Logging even during major version bumps, so compatibility is not a concern here.
these packages even during major version bumps, so compatibility is not a concern here.
-->
<PackageVersion Include="Microsoft.Extensions.Logging" Version="8.0.0-rc.2.23479.6" />

<PackageVersion Include="Microsoft.Extensions.Configuration" Version="8.0.0-rc.2.23479.6" />
<PackageVersion Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="8.0.0-rc.2.23479.6" />
<PackageVersion Include="Microsoft.Extensions.Hosting.Abstractions" Version="8.0.0-rc.2.23479.6" />
<PackageVersion Include="Microsoft.Extensions.Logging" Version="8.0.0-rc.2.23479.6" />
<PackageVersion Include="Microsoft.Extensions.Logging.Configuration" Version="8.0.0-rc.2.23479.6" />
<PackageVersion Include="Microsoft.Extensions.Options" Version="[3.1.0,)" />
<PackageVersion Include="Microsoft.Extensions.Options" Version="8.0.0-rc.2.23479.6" />

<PackageVersion Include="OpenTelemetry" Version="$(OTelLatestStableVer)" />
<PackageVersion Include="OpenTelemetry.Api" Version="$(OTelLatestStableVer)" />
<PackageVersion Include="OpenTelemetry.Api.ProviderBuilderExtensions" Version="$(OTelLatestStableVer)" />
Expand Down Expand Up @@ -75,6 +76,7 @@
<PackageVersion Include="Grpc.Tools" Version="[2.56.2,3.0)" />
<PackageVersion Include="Microsoft.CodeAnalysis.PublicApiAnalyzers" Version="[3.11.0-beta1.23402.2]" />
<PackageVersion Include="Microsoft.Data.SqlClient" Version="2.1.2" />
<PackageVersion Include="Microsoft.Extensions.DependencyInjection" Version="8.0.0-rc.2.23479.6" />
<PackageVersion Include="Microsoft.Extensions.Hosting" Version="[3.1.6,5.0)" />
<PackageVersion Include="Microsoft.Extensions.Http" Version="3.1.20" />
<PackageVersion Include="Microsoft.Extensions.Logging.Abstractions" Version="[6.0.0,)" />
Expand All @@ -96,13 +98,16 @@
<ItemGroup Condition="'$(TargetFramework)' == 'net6.0'">
<PackageVersion Include="Microsoft.AspNetCore.TestHost" Version="6.0.21" />
<PackageVersion Include="Microsoft.AspNetCore.Mvc.Testing" Version="6.0.21" />
<PackageVersion Include="Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation" Version="6.0.21" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'net7.0'">
<PackageVersion Include="Microsoft.AspNetCore.TestHost" Version="7.0.9" />
<PackageVersion Include="Microsoft.AspNetCore.Mvc.Testing" Version="7.0.9" />
<PackageVersion Include="Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation" Version="7.0.9" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'net8.0'">
<PackageVersion Include="Microsoft.AspNetCore.TestHost" Version="8.0.0-rc.2.23480.2" />
<PackageVersion Include="Microsoft.AspNetCore.Mvc.Testing" Version="8.0.0-rc.2.23480.2" />
<PackageVersion Include="Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation" Version="8.0.0-rc.2.23480.2" />
</ItemGroup>
</Project>
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ extension scenarios:

See [CONTRIBUTING.md](CONTRIBUTING.md)

We meet weekly on Tuesdays, and the time of the meeting alternates between 11AM
We meet weekly on Tuesdays, and the time of the meeting alternates between 9AM
PT and 4PM PT. The meeting is subject to change depending on contributors'
availability. Check the [OpenTelemetry community
calendar](https://calendar.google.com/calendar/embed?src=google.com_b79e3e90j7bbsa2n2p5an5lf60%40group.calendar.google.com)
Expand Down
4 changes: 4 additions & 0 deletions src/OpenTelemetry.Api.ProviderBuilderExtensions/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## Unreleased

* Updated `Microsoft.Extensions.DependencyInjection.Abstractions` package
version to `8.0.0-rc.2.23479.6`.
([#5015](https://github.com/open-telemetry/opentelemetry-dotnet/pull/5015))

## 1.7.0-alpha.1

Released 2023-Oct-16
Expand Down
4 changes: 4 additions & 0 deletions src/OpenTelemetry.Extensions.Hosting/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## Unreleased

* Updated `Microsoft.Extensions.Hosting.Abstractions` package
version to `8.0.0-rc.2.23479.6`.
([#5015](https://github.com/open-telemetry/opentelemetry-dotnet/pull/5015))

## 1.7.0-alpha.1

Released 2023-Oct-16
Expand Down
6 changes: 6 additions & 0 deletions src/OpenTelemetry.Instrumentation.AspNetCore/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

## Unreleased

* Removed the Activity Status Description that was being set during
exceptions. Activity Status will continue to be reported as `Error`.
This is a **breaking change**. `EnrichWithException` can be leveraged
to restore this behavior.
([#5025](https://github.com/open-telemetry/opentelemetry-dotnet/pull/5025))

* Updated `http.request.method` to match specification guidelines.
* For activity, if the method does not belong to one of the [known
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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -453,7 +453,7 @@ public void OnException(Activity activity, object payload)
activity.RecordException(exc);
}

activity.SetStatus(ActivityStatusCode.Error, exc.Message);
activity.SetStatus(ActivityStatusCode.Error);

try
{
Expand Down
22 changes: 22 additions & 0 deletions src/OpenTelemetry.Instrumentation.Http/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

## Unreleased

* Removed the Activity Status Description that was being set during
exceptions. Activity Status will continue to be reported as `Error`.
This is a **breaking change**. `EnrichWithException` can be leveraged
to restore this behavior.
([#5025](https://github.com/open-telemetry/opentelemetry-dotnet/pull/5025))

* Updated `http.request.method` to match specification guidelines.
* For activity, if the method does not belong to one of the [known
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)
Expand All @@ -18,6 +24,22 @@
`http` or `http/dup`.
([#5003](https://github.com/open-telemetry/opentelemetry-dotnet/pull/5003))

* An additional attribute `error.type` will be added to activity and
`http.client.request.duration` metric in case of failed requests as per the
[specification](https://github.com/open-telemetry/semantic-conventions/blob/v1.23.0/docs/http/http-spans.md#common-attributes).

Users moving to `net8.0` or newer frameworks from lower versions will see
difference in values in case of an exception. `net8.0` or newer frameworks add
the ability to further drill down the exceptions to a specific type through
[HttpRequestError](https://learn.microsoft.com/dotnet/api/system.net.http.httprequesterror?view=net-8.0)
enum. For lower versions, the individual types will be rolled in to a single
type. This could be a **breaking change** if alerts are set based on the values.

The attribute will only be added when `OTEL_SEMCONV_STABILITY_OPT_IN`
environment variable is set to `http` or `http/dup`.

([#5005](https://github.com/open-telemetry/opentelemetry-dotnet/pull/5005))

## 1.6.0-beta.2

Released 2023-Oct-26
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,11 @@ public void OnStopActivity(Activity activity, object payload)

if (TryFetchResponse(payload, out HttpResponseMessage response))
{
if (currentStatusCode == ActivityStatusCode.Unset)
{
activity.SetStatus(SpanHelper.ResolveSpanStatusForHttpStatusCode(activity.Kind, (int)response.StatusCode));
}

if (this.emitOldAttributes)
{
activity.SetTag(SemanticConventions.AttributeHttpStatusCode, TelemetryHelper.GetBoxedStatusCode(response.StatusCode));
Expand All @@ -279,11 +284,10 @@ public void OnStopActivity(Activity activity, object payload)
if (this.emitNewAttributes)
{
activity.SetTag(SemanticConventions.AttributeHttpResponseStatusCode, TelemetryHelper.GetBoxedStatusCode(response.StatusCode));
}

if (currentStatusCode == ActivityStatusCode.Unset)
{
activity.SetStatus(SpanHelper.ResolveSpanStatusForHttpStatusCode(activity.Kind, (int)response.StatusCode));
if (activity.Status == ActivityStatusCode.Error)
{
activity.SetTag(SemanticConventions.AttributeErrorType, TelemetryHelper.GetBoxedStatusCode(response.StatusCode));
}
}

try
Expand Down Expand Up @@ -337,14 +341,19 @@ public void OnException(Activity activity, object payload)
return;
}

if (this.emitNewAttributes)
{
activity.SetTag(SemanticConventions.AttributeErrorType, GetErrorType(exc));
}

if (this.options.RecordException)
{
activity.RecordException(exc);
}

if (exc is HttpRequestException)
{
activity.SetStatus(ActivityStatusCode.Error, exc.Message);
activity.SetStatus(ActivityStatusCode.Error);
}

try
Expand Down Expand Up @@ -372,4 +381,33 @@ static bool TryFetchException(object payload, out Exception exc)
return true;
}
}

private static string GetErrorType(Exception exc)
{
#if NET8_0_OR_GREATER
// For net8.0 and above exception type can be found using HttpRequestError.
// https://learn.microsoft.com/dotnet/api/system.net.http.httprequesterror?view=net-8.0
if (exc is HttpRequestException httpRequestException)
{
return httpRequestException.HttpRequestError switch
{
HttpRequestError.NameResolutionError => "name_resolution_error",
HttpRequestError.ConnectionError => "connection_error",
HttpRequestError.SecureConnectionError => "secure_connection_error",
HttpRequestError.HttpProtocolError => "http_protocol_error",
HttpRequestError.ExtendedConnectNotSupported => "extended_connect_not_supported",
HttpRequestError.VersionNegotiationError => "version_negotiation_error",
HttpRequestError.UserAuthenticationError => "user_authentication_error",
HttpRequestError.ProxyTunnelError => "proxy_tunnel_error",
HttpRequestError.InvalidResponse => "invalid_response",
HttpRequestError.ResponseEnded => "response_ended",
HttpRequestError.ConfigurationLimitExceeded => "configuration_limit_exceeded",

// Fall back to the exception type name in case of HttpRequestError.Unknown
_ => exc.GetType().FullName,
};
}
#endif
return exc.GetType().FullName;
}
}
Loading

0 comments on commit eb1f2ce

Please sign in to comment.