Skip to content

fix(server): Track status for content-length terminated bodies - #580

Merged
lcian merged 3 commits into
mainfrom
fix/metrics-body-content-length
Jul 28, 2026
Merged

fix(server): Track status for content-length terminated bodies#580
lcian merged 3 commits into
mainfrom
fix/metrics-body-content-length

Conversation

@jan-auer

@jan-auer jan-auer commented Jul 28, 2026

Copy link
Copy Markdown
Member

Streaming responses that declare a content-length were recorded as
client disconnects (499) in server.requests.duration, a regression
from #555. Hyper stops polling a response body once the declared number
of bytes has been written, so the wrapper never saw an end-of-stream
poll and its guard fell back to 499 when dropped.

MetricsBody now counts the bytes it forwards and completes the request
once the declared length is reached, alongside the existing
end-of-stream and trailers cases. Responses whose body hyper never polls
at all are completed up front when they are wrapped.

The tests were reworked around a helper that serves a real axum handler
through the middleware and returns the tracked status and duration,
which made room for a paused-clock test asserting the duration spans
body streaming rather than ending at the response headers. Capturing
metrics across await points needs a new
with_capturing_test_client_async in objectstore-metrics.

@jan-auer
jan-auer marked this pull request as ready for review July 28, 2026 12:50
@jan-auer
jan-auer requested a review from a team as a code owner July 28, 2026 12:50
@codecov

codecov Bot commented Jul 28, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 87.62%. Comparing base (5ea168b) to head (ccda332).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #580      +/-   ##
==========================================
- Coverage   87.69%   87.62%   -0.08%     
==========================================
  Files          94       94              
  Lines       15510    15591      +81     
==========================================
+ Hits        13601    13661      +60     
- Misses       1909     1930      +21     
Components Coverage Δ
Rust Backend 92.25% <100.00%> (-0.13%) ⬇️
Rust Client 79.89% <ø> (ø)
Python Client 90.98% <ø> (+0.07%) ⬆️

☔ View full report in Codecov by Harness.
📢 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.

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 7d7bcab. Configure here.

Comment thread objectstore-server/src/web/metrics_body.rs

@lcian lcian left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks good to me, nice refactor of the tests.

@lcian
lcian merged commit 4f64e0d into main Jul 28, 2026
26 checks passed
@lcian
lcian deleted the fix/metrics-body-content-length branch July 28, 2026 14:30
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