Skip to content

server.port is required on HTTP client spans#16388

Merged
trask merged 27 commits intoopen-telemetry:mainfrom
trask:http-client-default-port
Mar 13, 2026
Merged

server.port is required on HTTP client spans#16388
trask merged 27 commits intoopen-telemetry:mainfrom
trask:http-client-default-port

Conversation

@trask
Copy link
Copy Markdown
Member

@trask trask commented Mar 4, 2026

We missed this when moving to stable HTTP semantic conventions.

if (serverAddressAndPort.getAddress() != null) {
attributes.put(SERVER_ADDRESS, serverAddressAndPort.getAddress());
Integer port = serverAddressAndPort.getPort();
if (port == null || port <= 0) {
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.

pedantic, but....

Suggested change
if (port == null || port <= 0) {
if (port == null || port <= 0 || port > 65535) {

Copy link
Copy Markdown
Contributor

@breedx-splk breedx-splk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know it's Draft but I'll leave a review anyway. This seems good to me, the port is often helpful. I think saying it's "required" might be overstating it (spec says SHOULD?)

@trask
Copy link
Copy Markdown
Member Author

trask commented Mar 4, 2026

spec says SHOULD?

this is for HTTP server spans

for HTTP client spans it's marked as required


String fullUrl = stripSensitiveData(getter.getUrlFull(request));

if (SemconvStability.v3Preview()) {
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.

just curious why should we make this change only in the next major version, is there something that prevents us from doing it right now?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Member Author

@trask trask Mar 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it got annoying, let's call it a bug fix 😅

it will only "break apart" existing timeseries if the app was connecting to both 80 and 443 on the same target server.address, which is pretty uncommon in practice

trask added 5 commits March 9, 2026 14:19
The declarative config approach via GlobalOpenTelemetry fails because:
1. ExtendedOpenTelemetry may not be on classpath (old API tests)
2. GlobalOpenTelemetry returns noop during static init

Restore direct system property and env var reading.
@trask trask force-pushed the http-client-default-port branch from 0414767 to c48bc26 Compare March 9, 2026 21:53
@github-actions github-actions Bot added the test native This label can be applied to PRs to trigger them to run native tests label Mar 10, 2026
Fix connectionErrorNonRoutableAddress test failures by adding default port
resolution via HttpConstants.defaultPortForScheme() to getters that were
missed in the initial pass:
- async-http-client 1.8 and 1.9
- armeria 1.3
- reactor-netty 1.0
public Integer getServerPort(HttpMethod request) {
HostConfiguration hostConfiguration = request.getHostConfiguration();
return hostConfiguration != null ? hostConfiguration.getPort() : null;
if (hostConfiguration == null || hostConfiguration.getProtocol() == null) {
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.

why is the hostConfiguration.getProtocol() value relevant here?

}
return null;
}

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.

wondering whether something like

  @Nullable
  public static Integer portOrDefaultFromScheme(@Nullable Integer port, Supplier<String> scheme) {
    if (port != null && port > 0) {
      return port;
    }
    return defaultPortForScheme(scheme.get());
  }

would help

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added, looks nice, does introduce a capturing lambda, but really should get jitted away

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.

The lambda is only useful when getting the scheme does something complicated that is worth skipping when the port is already known. I'd guess that in most (if not all) cases we could pass the scheme directly. If you don't like the capturing lambda you could add an overload with plain string.

Copy link
Copy Markdown
Contributor

@laurit laurit left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should add the preview flag and use it in the PRs tagged for 3.0.0 so we could merge them immediately.

trask added 3 commits March 11, 2026 12:58
…java/io/opentelemetry/javaagent/instrumentation/apachehttpasyncclient/ApacheHttpAsyncClientHttpAttributesGetter.java
@trask trask force-pushed the http-client-default-port branch 2 times, most recently from b99206d to f775c81 Compare March 12, 2026 02:45
@trask trask force-pushed the http-client-default-port branch from f775c81 to 299f166 Compare March 12, 2026 02:47
@trask trask marked this pull request as ready for review March 12, 2026 04:10
@trask trask requested a review from a team as a code owner March 12, 2026 04:10
}

@Nullable
public static Integer portOrDefaultFromScheme(int port, Supplier<String> scheme) {
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.

not sure having this overload is worth it. Or could make the other one call this one.

@trask trask enabled auto-merge (squash) March 12, 2026 20:34
@trask trask merged commit 257ebe6 into open-telemetry:main Mar 13, 2026
94 of 95 checks passed
@trask trask deleted the http-client-default-port branch March 13, 2026 02:23
ezhang6811 added a commit to aws-observability/aws-application-signals-test-framework that referenced this pull request Mar 27, 2026
*Issue description:*

*Description of changes:*
ADOT Java is upgrading its OpenTelemetry Java Instrumentation dependency
to 2.26.1, which includes a change that adds the `server.port` attribute
to all HTTP client spans ([upstream
PR](open-telemetry/opentelemetry-java-instrumentation#16388)).

the ADOT logic appends server.port to RemoteService if it exists, so
this PR updates the java E2E tests to match the expected behavior.

*Rollback procedure:*

<Can we safely revert this commit if needed? If not, detail what must be
done to safely revert and why it is needed.>

*Ensure you've run the following tests on your changes and include the
link below:*

To do so, create a `test.yml` file with `name: Test` and workflow
description to test your changes, then remove the file for your PR. Link
your test run in your PR description. This process is a short term
solution while we work on creating a staging environment for testing.

NOTE: TESTS RUNNING ON A SINGLE EKS CLUSTER CANNOT BE RUN IN PARALLEL.
See the
[needs](https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idneeds)
keyword to run tests in succession.
- Run Java EKS on `e2e-playground` in us-east-1 and eu-central-2
- Run Python EKS on `e2e-playground` in us-east-1 and eu-central-2
- Run metric limiter on EKS cluster `e2e-playground` in us-east-1 and
eu-central-2
- Run EC2 tests in all regions
- Run K8s on a separate K8s cluster (check IAD test account for master
node endpoints; these will change as we create and destroy clusters for
OS patching)

By submitting this pull request, I confirm that my contribution is made
under the terms of the Apache 2.0 license.

---------

Co-authored-by: ADOT Patch workflow <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

test native This label can be applied to PRs to trigger them to run native tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants