Skip to content

fix(otelhttp): make Body handling in Transport consistent with stdlib#8618

Merged
dmathieu merged 3 commits into
open-telemetry:mainfrom
ash2k:fix-body-wrapping
Mar 4, 2026
Merged

fix(otelhttp): make Body handling in Transport consistent with stdlib#8618
dmathieu merged 3 commits into
open-telemetry:mainfrom
ash2k:fix-body-wrapping

Conversation

@ash2k
Copy link
Copy Markdown
Member

@ash2k ash2k commented Mar 3, 2026

First request uses Body, following requests use Body if it can be rewound, which is only possible for well-known types that stdlib knows about. Otherwise, GetBody() is used, when available.

This is a follow up for #8532.

Fixes #8524.

@codecov
Copy link
Copy Markdown

codecov Bot commented Mar 3, 2026

Codecov Report

❌ Patch coverage is 70.00000% with 6 lines in your changes missing coverage. Please review.
✅ Project coverage is 82.1%. Comparing base (518d65a) to head (32f0347).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
instrumentation/net/http/otelhttp/transport.go 70.0% 5 Missing and 1 partial ⚠️
Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##            main   #8618     +/-   ##
=======================================
- Coverage   82.2%   82.1%   -0.1%     
=======================================
  Files        180     180             
  Lines      13750   13759      +9     
=======================================
+ Hits       11304   11309      +5     
- Misses      2044    2048      +4     
  Partials     402     402             
Files with missing lines Coverage Δ
instrumentation/net/http/otelhttp/transport.go 92.6% <70.0%> (-4.7%) ⬇️

... and 1 file with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Copy Markdown
Member

@pellared pellared left a comment

Choose a reason for hiding this comment

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

Can you please add a changelog entry?

Comment thread instrumentation/net/http/otelhttp/transport.go Outdated
Comment thread instrumentation/net/http/otelhttp/transport.go Outdated
@ash2k
Copy link
Copy Markdown
Member Author

ash2k commented Mar 3, 2026

@pellared Done!

@ash2k ash2k force-pushed the fix-body-wrapping branch from c058a29 to d66dcdd Compare March 3, 2026 22:36
First request uses Body, following requests use Body if
it can be rewound, which is only possible for well-known types
that stdlib knows about. Otherwise, GetBody is used, when available.
@ash2k ash2k force-pushed the fix-body-wrapping branch from d66dcdd to 2df126e Compare March 3, 2026 22:38
Comment thread CHANGELOG.md Outdated
@pellared pellared changed the title fix(otelhttp): make Body and GetBody() behavior consistent with stdlib fix(otelhttp): make Body handling in Transport consistent with stdlib Mar 4, 2026
Co-authored-by: Robert Pająk <pellared@hotmail.com>
@pellared pellared added this to the v1.42.0 milestone Mar 4, 2026
@dmathieu dmathieu merged commit 8986a19 into open-telemetry:main Mar 4, 2026
28 of 29 checks passed
@ash2k ash2k deleted the fix-body-wrapping branch March 5, 2026 03:12
pellared added a commit that referenced this pull request Mar 6, 2026
#8649)

### Added

- Add environment variables propagation carrier in `go.opentelemetry.io/contrib/propagators/envcar`. (#8442)

### Changed

- Upgrade `go.opentelemetry.io/otel/semconv` to `v1.40.0`, including updates across instrumentation and detector modules. (#8631)
  - The semantic conventions v1.40.0 release introduces RPC breaking changes applied in this repository:
    - RPC spans and metrics no longer include `network.protocol.name`, `network.protocol.version`, or `network.transport` attributes.
    - `rpc.client.request.size`, `rpc.client.response.size`, `rpc.server.request.size`, and `rpc.server.response.size` are no longer emitted in `go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc`.
    - `rpc.message` span events and their message attributes are no longer emitted in `go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc` (including when `WithMessageEvents` is configured).

  See [semantic-conventions v1.40.0 release](https://github.com/open-telemetry/semantic-conventions/releases/tag/v1.40.0) for complete details.

### Fixed

- Ignore informational response status codes (`100-199`) except `101 Switching Protocols` when storing the HTTP status code in `go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp` and `go.opentelemetry.io/contrib/instrumentation/github.com/gorilla/mux/otelmux`. (#6913)
- Make `Body` handling in `Transport` consistent with stdlib in `go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp`. (#8618)
- Fix bucket boundaries for `rpc.server.call.duration` and `rpc.client.call.duration` in `go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc`. (#8642)
- Host resource detector in `go.opentelemetry.io/contrib/otelconf` now includes `os.` attributes. (#8578)

### Removed

- Drop support for [Go 1.24]. (#8628)

[Go 1.24]: https://go.dev/doc/go1.24
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.

[Bug]: otehttp.NewTransport causes requests to hang when server responds without consuming the request body in v0.65.0

3 participants