Skip to content

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

Merged
ManickaP merged 2 commits into
dotnet:mainfrom
ManickaP:otel-http
Jun 4, 2026
Merged

ManickaP merged 2 commits into
dotnet:mainfrom
ManickaP:otel-http

Conversation

@ManickaP

@ManickaP ManickaP commented Jun 3, 2026 •

Copy link
Copy Markdown
Member

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.

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

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

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

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 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
@ManickaP

ManickaP commented Jun 4, 2026

Copy link
Copy Markdown
Member Author

/azp list

@azure-pipelines

Copy link
Copy Markdown
CI/CD Pipelines for this repository:

@ManickaP

ManickaP commented Jun 4, 2026

Copy link
Copy Markdown
Member Author

/azp run runtime-libraries-coreclr outerloop

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

@martincostello

Copy link
Copy Markdown
Member

We do not have any toggles for Opt-In tags

Maybe this is something worth investigating separately?

The OTel HTTP instrumentation delegates to the runtime implementation since .NET 8, so if people wanted these we'd have to re-introduce functionality there to bring these attributes back for users who wanted them.

@ManickaP

ManickaP commented Jun 4, 2026

Copy link
Copy Markdown
Member Author

Filed #128985, likely will happen earliest in .NET 12 (i.e. won't be in 11).

@ManickaP
ManickaP merged commit 9dd152c into dotnet:main Jun 4, 2026
93 of 103 checks passed
@ManickaP
ManickaP deleted the otel-http branch June 4, 2026 17:05
ManickaP added a commit that referenced this pull request Jun 5, 2026
Fix for httpbin returning 503, which is out of our control.
Based on Kusto, started 28.5., seen in
#128940
@dotnet-milestone-bot dotnet-milestone-bot Bot added this to the 11.0-preview6 milestone Jun 5, 2026
@cijothomas

Copy link
Copy Markdown
Contributor

Was this metric marked stable in .NET?

@ManickaP

Copy link
Copy Markdown
Member Author

I'm not sure I understand the question fully. I've made this change based on your change in open-telemetry/semantic-conventions#3759. Am I missing something?

@cijothomas

Copy link
Copy Markdown
Contributor

I'm not sure I understand the question fully. I've made this change based on your change in open-telemetry/semantic-conventions#3759. Am I missing something?

The semantic convention in OTel is marked "experimental", so it is free to change including breaking changes. My question was - is this metric marked as experimental in .NET/HTTPClient too? if not, this is breaking users, and may need different treatment.

@ManickaP

Copy link
Copy Markdown
Member Author

If you mean if we have it in code marked as "Experimental" then no. This is a bit confusing for me, but how could this differ? Also looking at https://opentelemetry.io/docs/specs/semconv/dotnet/dotnet-http-metrics/#metric-httpclientopen_connections where it says "Stable", how can it be "Experimental" in your case?

I can always revert, that's not a problem. But I'm kind of missing the point of making it Opt-In if we wouldn't be able to switch from Recommended to it due to being "Stable" anyway? Or am I missing something else?

@cijothomas

Copy link
Copy Markdown
Contributor

If you mean if we have it in code marked as "Experimental" then no. This is a bit confusing for me, but how could this differ? Also looking at https://opentelemetry.io/docs/specs/semconv/dotnet/dotnet-http-metrics/#metric-httpclientopen_connections where it says "Stable", how can it be "Experimental" in your case?

I can always revert, that's not a problem. But I'm kind of missing the point of making it Opt-In if we wouldn't be able to switch from Recommended to it due to being "Stable" anyway? Or am I missing something else?

The link you are lookin at is the dotnet specific conventions, not OTel http convention. The .NET is marked stable, and it still have the network.peer.address as recommended (I haven't changed that).

What I changed was the OTel semantic conventions for HTTP, and specifically the open_connections one, which is marked "development" stage i.e it is not stable (and hence free to make breaking changes)

https://github.com/open-telemetry/semantic-conventions/blob/main/docs/http/http-metrics.md#metric-httpclientopen_connections

@ManickaP

Copy link
Copy Markdown
Member Author

I'd assume that the .NET specific conventions are based on OTel semantic ones. And if so, how come the later is experimental while the former is stable? And what effect has the OTel semantic convention change if it doesn't affect the actual implementations?

Either way, I will revert this just to be on the safe side. I'm just curious about the ins and outs of this whole specs hierarchy.

@cijothomas

Copy link
Copy Markdown
Contributor

I'd assume that the .NET specific conventions are based on OTel semantic ones. And if so, how come the later is experimental while the former is stable? And what effect has the OTel semantic convention change if it doesn't affect the actual implementations?

Either way, I will revert this just to be on the safe side. I'm just curious about the ins and outs of this whole specs hierarchy.

I do not know the full history behind why .NET has own conventions :(

@martincostello Does OTel .NET contrib instrumentation enable the .NET specific convention or OTel conventions internally?

And what effect has the OTel semantic convention change if it doesn't affect the actual implementations?

Not sure I follow this - if OTel Convention changes, then the implementation would also change in line with the convention change.

@martincostello

Copy link
Copy Markdown
Member

Does OTel .NET contrib instrumentation enable the .NET specific convention or OTel conventions internally?

For the code we implement we go with OTel's - where .NET has support for something in-box we delegate to the runtime so we don't have two parallel implementations.

ManickaP added a commit that referenced this pull request Jun 16, 2026
…29317)

Reverts #128940

Apparently, there are 2 different specs, and the one for .NET is stable.
See discussion in
#128940 (comment)
@github-actions github-actions Bot locked and limited conversation to collaborators Jul 12, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants