Skip to content

[Hosting] Do not set activity status on exception#65825

Open
martincostello wants to merge 1 commit intodotnet:mainfrom
martincostello:align-hosting-tracing-with-otel
Open

[Hosting] Do not set activity status on exception#65825
martincostello wants to merge 1 commit intodotnet:mainfrom
martincostello:align-hosting-tracing-with-otel

Conversation

@martincostello
Copy link
Member

Do not set activity status on exception

Do not set the Activity status description when an exception is thrown.

Description

Do not set the status description when an exception occurs as it can be inferred from the HTTP status that will be served to align with the existing behaviour of OpenTelemetry.Instrumentation.AspNetCore (code).

Fixes open-telemetry/opentelemetry-dotnet-contrib#3968

Do not set the status description when an exception occurs as it can be inferred from the HTTP status that will be served to align with the existing behaviour of OpenTelemetry.Instrumentation.AspNetCore.

Resolves open-telemetry/opentelemetry-dotnet-contrib#3968.
Copilot AI review requested due to automatic review settings March 18, 2026 10:14
@github-actions github-actions bot added the area-hosting Includes Hosting label Mar 18, 2026
@dotnet-policy-service dotnet-policy-service bot added the community-contribution Indicates that the PR has been added by a community member label Mar 18, 2026
@dotnet-policy-service
Copy link
Contributor

Thanks for your PR, @@martincostello. Someone from the team will get assigned to your PR shortly and we'll get it reviewed.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates Hosting’s Activity end-tagging behavior so exceptions no longer set an Activity status description, aligning with existing OpenTelemetry AspNetCore instrumentation behavior while still marking the span as Error and recording error.type.

Changes:

  • Stop passing exception.Message into Activity.SetStatus(...) when an exception is present.
  • Update the corresponding diagnostics test to assert StatusDescription is null for exception scenarios.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
src/Hosting/Hosting/src/Internal/HostingApplicationDiagnostics.cs Removes exception message from Activity.SetStatus so status description is not set on exceptions.
src/Hosting/Hosting/test/HostingApplicationDiagnosticsTests.cs Adjusts assertion to expect StatusDescription to be null when an exception is reported.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-hosting Includes Hosting community-contribution Indicates that the PR has been added by a community member

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[bug] Should SetStatus() set the description if an exception occurs during ASP.NET Core HTTP request processing?

3 participants