opentelemetry-go
opentelemetry-go copied to clipboard
fix: http.flavor attribute is not respected in client-side HTTP trace
Fixes https://github.com/open-telemetry/opentelemetry-go-contrib/issues/3185
Making an http2.0 connection using net/http default transport (negotiating h2 over tls through ForceAttemptHTTP2: true) wrapped by otelhttp.NewTransport generates a trace/span with the wrong flavor: 1.1 instead of 2.0.
I think this is due to the fact that net/http Client Request Proto header is ignored.
Currently otel-go uses ClientRequest to fill in the http.flavor attribute, but in order to use the actually used Proto as an attribute, it is necessary to fill in the attribute in ClientResponse.
I also found a problem that when throwing an http2.0 Client Request using net/http, the extracted value of Proto could be HTTP/2.0 and http.flavor did not become 2.0, so I have also addressed this issue.
e.g. https://cs.opensource.google/go/go/+/refs/tags/go1.20.1:src/net/http/h2_bundle.go;l=5998;bpv=1;bpt=1
Although I used otel-go-contrib example with self-signed certs to serve http2.0 to check the behavior, you can easily reproduce the problem by using the script from the issue.
The committers listed above are authorized under a signed CLA.
- :white_check_mark: login: terakoya76 / name: Hajime Terasawa (643b890f86a762831ffad5972bfe77db7361dded, 538c81fc5c4394ea24b6c3f40756e0bca959ade0)
otelhttp no longer uses httpconv. You can make a PR directly in https://github.com/open-telemetry/opentelemetry-go-contrib. Sorry for late feedback.