-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Add OTEL semantic conventions tags to HTTP server activity #64851
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR adds OpenTelemetry semantic convention tags to HTTP server activities and metrics in ASP.NET Core, aligning with OTEL specifications. The key change is that telemetry is now enabled by default in .NET 11.
- Changes the default value of
Microsoft.AspNetCore.Hosting.SuppressActivityOpenTelemetryDatafrom true to false, enabling OTEL data by default - Adds required OTEL semantic convention attributes to HTTP activities including
http.response.status_code,network.protocol.version,http.route, anderror.type - Implements error.type attribute for HTTP server metrics with 5xx status codes, following OTEL specifications
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
src/Shared/Diagnostics/RouteDiagnosticsHelpers.cs |
Updates comment to reference "telemetry attributes" instead of just "metrics" |
src/Hosting/Hosting/src/Internal/HostingTelemetryHelpers.cs |
Adds new attribute constants for OTEL semantic conventions and implements IsErrorStatusCode helper method |
src/Hosting/Hosting/src/Internal/HostingMetrics.cs |
Updates metrics to use attribute constants and adds error.type tag for 5xx status codes |
src/Hosting/Hosting/src/Internal/HostingApplicationDiagnostics.cs |
Changes default to enable OTEL data, adds end tags to activities including error handling logic |
src/Hosting/Hosting/test/HostingMetricsTests.cs |
Adds comprehensive tests for error.type behavior in metrics with various status codes |
src/Hosting/Hosting/test/HostingApplicationDiagnosticsTests.cs |
Adds extensive tests for activity tags, error handling, and sampling scenarios |
src/Hosting/Hosting/src/Internal/HostingApplicationDiagnostics.cs
Outdated
Show resolved
Hide resolved
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
|
There might be an issue with forwarded headers handling in the current implementation. The attributes The specification recommends setting these attributes based on the processed forwarded headers:
Should these attributes also be set when the activity stops? |
|
Do you plan to add specific support for activity enrichment based on the |
This PR adds OTEL telemetry tags to the HTTP activity:
Microsoft.AspNetCore.Hosting.SuppressActivityOpenTelemetryDatanow defaults to false. Telemetry is added to activity by default in .NET 11.Fixes #52439