Skip to content

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

Merged
halter73 merged 3 commits into
dotnet:mainfrom
martincostello:align-hosting-tracing-with-otel
May 14, 2026
Merged

[Hosting] Do not set activity status on exception#65825
halter73 merged 3 commits into
dotnet:mainfrom
martincostello:align-hosting-tracing-with-otel

Conversation

@martincostello

Copy link
Copy Markdown
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 left a comment

Copy link
Copy Markdown
Contributor

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.

@dotnet-policy-service dotnet-policy-service Bot added the pending-ci-rerun When assigned to a PR indicates that the CI checks should be rerun label Mar 25, 2026
@martincostello

Copy link
Copy Markdown
Member Author

/cc @danroth27

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 pending-ci-rerun When assigned to a PR indicates that the CI checks should be rerun

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?

4 participants