Skip to content

[Breaking change]: HttpClient Metrics reporting server.port unconditionally #42810

@antonfirsov

Description

@antonfirsov

Description

When implementing HttpClient Metrics in .NET 8, server.port was introduced as a Conditionally Required attribute in accordance with the state of the standard at that time, meaning that the port was only reported if it did not match the default port of the corresponding protocol (80 for HTTP, 443 for HTTPS). However, the standard requirement level of the attribute has been changed later to Required.

To maintain compliance with the Open Telemetry standard while keeping the instrument's behaviors consistent with each other, the instruments http.client.request.duration, http.client.connection.duration and http.client.open_connections have been changed to unconditionally report the server.port attribute.

This may break existing queries in monitoring software like Prometheus.

Version

.NET 9 Preview 7

Previous behavior

http.client.request.duration, http.client.connection.duration and http.client.open_connections reported the server.port attribute only if it did not match the corresponding protocol's default port (80 for HTTP, 443 for HTTPS).

New behavior

dotnet/runtime#104741 has changed the previos behavior so the server.port attribute is unconditionally reported by the instruments http.client.request.duration, http.client.connection.duration and http.client.open_connections.

Type of breaking change

  • Binary incompatible: Existing binaries might encounter a breaking change in behavior, such as failure to load or execute, and if so, require recompilation.
  • Source incompatible: When recompiled using the new SDK or component or to target the new runtime, existing source code might require source changes to compile successfully.
  • Behavioral change: Existing binaries might behave differently at run time.

Reason for change

Maintaining compliance with the corresponding Open Telemetry specification, while keeping HttpClient instruments consistent with each other.

Recommended action

No action is needed for users who do not rely on HttpClient Metrics.

For users of the http.client.request.duration, http.client.connection.duration and http.client.open_connections instruments, the change may break existing queries in monitoring software like Prometheus.

Feature area

Core .NET libraries, Networking

Affected APIs

System.Net.Http.SocketsHttpHandler.Send(...)
System.Net.Http.SocketsHttpHandler.SendAsync(...)
System.Net.Http.HttpClientHandler.Send(...)
System.Net.Http.HttpClientHandler.SendAsync(...)


Associated WorkItem - 340215

Metadata

Metadata

Assignees

Labels

📌 seQUESTeredIdentifies that an issue has been imported into Quest.breaking-changeIndicates a .NET Core breaking changein-prThis issue will be closed (fixed) by an active pull request.

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions