Skip to content

[HTTP] Remove peer.address from connection OTel counters#128940

Open
ManickaP wants to merge 1 commit into
dotnet:mainfrom
ManickaP:otel-http
Open

[HTTP] Remove peer.address from connection OTel counters#128940
ManickaP wants to merge 1 commit into
dotnet:mainfrom
ManickaP:otel-http

Conversation

@ManickaP
Copy link
Copy Markdown
Member

@ManickaP ManickaP commented Jun 3, 2026

OTel changed specification for these 2 tags to "Opt-In". We do not have any toggles for Opt-In tags and we simply omit them. Therefore, I'm removing them from the code.

OTel change: open-telemetry/semantic-conventions#3759
Contributes to #122752

@dotnet-policy-service
Copy link
Copy Markdown
Contributor

Tagging subscribers to this area: @karelz, @dotnet/ncl
See info in area-owners.md if you want to be subscribed.

Copy link
Copy Markdown
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

Removes the network.peer.address tag from System.Net.Http connection metrics tag sets, aligning emitted dimensions with updated OpenTelemetry semantic conventions (where that attribute is now opt-in for http.client.open_connections) and reducing metric cardinality pressure.

Changes:

  • Stop emitting network.peer.address from SocketsHttpHandler connection metric tags.
  • Remove peer-address validation helper and usages from System.Net.Http functional metrics tests.

Reviewed changes

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

File Description
src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/Metrics/ConnectionMetrics.cs Removes network.peer.address from the TagList used by connection metrics.
src/libraries/System.Net.Http/tests/FunctionalTests/MetricsTest.cs Updates metrics functional test helpers to no longer validate network.peer.address.

Comment thread src/libraries/System.Net.Http/tests/FunctionalTests/MetricsTest.cs
Comment thread src/libraries/System.Net.Http/tests/FunctionalTests/MetricsTest.cs
Comment thread src/libraries/System.Net.Http/tests/FunctionalTests/MetricsTest.cs Outdated
Copilot AI review requested due to automatic review settings June 3, 2026 11:07
Copy link
Copy Markdown
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

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

Comments suppressed due to low confidence (1)

src/libraries/System.Net.Http/tests/FunctionalTests/MetricsTest.cs:137

  • validPeerAddresses is no longer used to validate peer addresses (the peer-address tag was removed). It now only serves as a non-null sentinel to skip the duration range assertion, so the parameter name is misleading and makes the test harder to understand/maintain.
        protected static void VerifyConnectionDuration(string instrumentName, object measurement, KeyValuePair<string, object?>[] tags, Uri uri, Version? protocolVersion, IPAddress[] validPeerAddresses = null)
        {
            Assert.Equal(InstrumentNames.ConnectionDuration, instrumentName);
            double value = Assert.IsType<double>(measurement);

            // This flakes for remote requests on CI.
            if (validPeerAddresses is null)
            {

Comment on lines 125 to 128
VerifySchemeHostPortTags(tags, uri);
VerifyTag(tags, "network.protocol.version", GetVersionString(protocolVersion));
VerifyTag(tags, "http.connection.state", state);
VerifyPeerAddress(tags, validPeerAddresses);
}
Comment on lines 140 to 142
VerifySchemeHostPortTags(tags, uri);
VerifyTag(tags, "network.protocol.version", GetVersionString(protocolVersion));
VerifyPeerAddress(tags, validPeerAddresses);
}
Comment on lines 389 to +392
Measurement<double> cd = Assert.Single(connectionDurationRecorder.GetMeasurements());
VerifyConnectionDuration(InstrumentNames.ConnectionDuration, cd.Value, cd.Tags.ToArray(), uri, UseVersion, addresses);
Measurement<long> oc = openConnectionsRecorder.GetMeasurements().First();
VerifyOpenConnections(InstrumentNames.OpenConnections, oc.Value, oc.Tags.ToArray(), 1, uri, UseVersion, "idle", addresses);
VerifyOpenConnections(InstrumentNames.OpenConnections, oc.Value, oc.Tags.ToArray(), 1, uri, UseVersion, "idle");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants