Commit 4f64e0d
authored
fix(server): Track status for content-length terminated bodies (#580)
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`.1 parent 725ec28 commit 4f64e0d
5 files changed
Lines changed: 253 additions & 215 deletions
File tree
- objectstore-metrics/src
- objectstore-server
- src/web
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
318 | 318 | | |
319 | 319 | | |
320 | 320 | | |
321 | | - | |
| 321 | + | |
322 | 322 | | |
323 | 323 | | |
324 | 324 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
| 6 | + | |
6 | 7 | | |
7 | 8 | | |
8 | 9 | | |
| |||
26 | 27 | | |
27 | 28 | | |
28 | 29 | | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
29 | 54 | | |
30 | 55 | | |
31 | 56 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
64 | 64 | | |
65 | 65 | | |
66 | 66 | | |
| 67 | + | |
67 | 68 | | |
68 | 69 | | |
69 | 70 | | |
| |||
0 commit comments