Skip to content

Use req.Body readers to reduce allocs#489

Merged
tigrannajaryan merged 3 commits intoopen-telemetry:mainfrom
michel-laterman:enhacement/server-reduce-allocs
Jan 13, 2026
Merged

Use req.Body readers to reduce allocs#489
tigrannajaryan merged 3 commits intoopen-telemetry:mainfrom
michel-laterman:enhacement/server-reduce-allocs

Conversation

@michel-laterman
Copy link
Copy Markdown
Contributor

@michel-laterman michel-laterman commented Jan 9, 2026

Pass req.Body directly to decompressGzip in order to remove the allocs an io.ReadAll call creates.

@codecov
Copy link
Copy Markdown

codecov Bot commented Jan 9, 2026

Codecov Report

❌ Patch coverage is 60.00000% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 81.79%. Comparing base (d508718) to head (67b4b8e).
⚠️ Report is 19 commits behind head on main.

Files with missing lines Patch % Lines
server/serverimpl.go 60.00% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #489      +/-   ##
==========================================
+ Coverage   81.71%   81.79%   +0.07%     
==========================================
  Files          27       27              
  Lines        2122     2131       +9     
==========================================
+ Hits         1734     1743       +9     
  Misses        263      263              
  Partials      125      125              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

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

@michel-laterman
Copy link
Copy Markdown
Contributor Author

The only other alloc reduction I think we should consider is replacing io.ReadAll with something like:

var b bytes.Buffer
_, err := io.Copy(&b, reader)
return b.Bytes(), err

which performs better, but may be over doing it

Comment thread server/serverimpl.go
Comment thread server/serverimpl.go
@tigrannajaryan tigrannajaryan merged commit c95f57f into open-telemetry:main Jan 13, 2026
10 of 11 checks passed
@michel-laterman michel-laterman deleted the enhacement/server-reduce-allocs branch January 14, 2026 17:51
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.

2 participants