Skip to content

fix(http): fall back to URL.Host for client server.address - #762

Open
will-jg wants to merge 2 commits into
alibaba:mainfrom
will-jg:fix/http-client-server-address-fallback
Open

will-jg wants to merge 2 commits into
alibaba:mainfrom
will-jg:fix/http-client-server-address-fallback

Conversation

@will-jg

@will-jg will-jg commented Oct 12, 2026

Copy link
Copy Markdown
Contributor

Summary

  • net/http client instrumentation previously set server.address only from Request.Host.
  • For client requests, Host is optional and may be empty while URL.Host is set; the transport still works, but metrics/spans got server.address="".
  • Fall back to request.url.Host when Host is empty. GetServerPort is unchanged.

Test plan

  • go test -run TestNetHttpClientGetServerAddress ./pkg/rules/http
  • Confirm http.client.request.duration points no longer emit empty server.address for requests constructed with empty Request.Host and non-empty URL.Host

Client Request.Host is optional; when empty the transport uses URL.Host.
Populate server.address from URL.Host in that case so http.client metrics
keep a usable peer dimension.
Strip :port from Request.Host / URL host so server.address stays
hostname-or-IP per OTel semconv, and cover IPv4/IPv6 cases in tests.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant