From d9968a5f1f325abce744adc58b6c69585853e23e Mon Sep 17 00:00:00 2001 From: Bryan English Date: Thu, 29 Oct 2026 16:37:09 -0400 Subject: [PATCH] fix: drop the port from server.address on HTTP/2 server spans The HTTP/2 server spans set server.address to the raw :authority pseudo-header, port included. The semantic conventions keep the port out of server.address, which the HTTP/1.1 server spans already follow. The HTTP/2 spans now split the authority the same way, and the test that asserted the port-included value now asserts the bare host. Signed-off-by: Bryan English --- README.md | 2 +- lib/instrumentations.js | 3 ++- test/test-http2.js | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index b4cf5db..f663287 100644 --- a/README.md +++ b/README.md @@ -114,7 +114,7 @@ Attributes set on HTTP/2 server spans: | `url.path` | Request URL path (without query) | Always | | `url.query` | Query string (without `?`) | When query string is present | | `url.scheme` | `http` or `https` | Always | -| `server.address` | `:authority` pseudo-header value | When present | +| `server.address` | Requested host, without the port | When `:authority` is present | | `network.protocol.version` | `2.0` | Always | | `http.response.status_code` | Response status code | When the response is sent | | `error.type` | HTTP status code as string | On 5xx responses | diff --git a/lib/instrumentations.js b/lib/instrumentations.js index cecfa14..8b3d9e2 100644 --- a/lib/instrumentations.js +++ b/lib/instrumentations.js @@ -262,7 +262,8 @@ function onHttp2ServerStreamStart({ stream, headers }) { span.setAttribute('network.protocol.version', '2.0'); const authority = headers?.[':authority']; - if (authority) span.setAttribute('server.address', authority); + if (authority) + span.setAttribute('server.address', splitAuthority(authority)[0]); // The span is stashed on the stream so the finish and close handlers do // not need a second AsyncLocalStorage lookup. diff --git a/test/test-http2.js b/test/test-http2.js index 84736d2..2c898f7 100644 --- a/test/test-http2.js +++ b/test/test-http2.js @@ -109,7 +109,7 @@ describe('otel HTTP/2 server spans', () => { 'url.scheme': 'http', 'network.protocol.version': '2.0', 'http.response.status_code': '200', - 'server.address': `127.0.0.1:${target.port}`, + 'server.address': '127.0.0.1', }); });