Xuanwo opened a new pull request, #8732:
URL: https://github.com/apache/opendal/pull/8732

   # Which issue does this PR close?
   
   Closes #.
   
   # Rationale for this change
   
   `MetricsHttpTransport` returned HTTP 4xx/5xx responses early after counting 
`http_status_errors_total`. As a result:
   
   - `http_request_bytes`, `http_request_bytes_rate`, 
`http_request_duration_seconds`, `http_response_bytes`, 
`http_response_bytes_rate`, and `http_response_duration_seconds` were never 
recorded for error responses, even when a real request/response body was 
transferred (e.g. an S3 XML error body).
   - `http_executing` was decremented as soon as the response headers arrived 
instead of when the response body finished or was dropped, inconsistent with 
2xx/3xx handling.
   
   # What changes are included in this PR?
   
   - `MetricsHttpTransport::fetch` now handles every received `Ok(resp)` 
through one path: `http_status_errors_total` is counted when the status is a 
client or server error, request metrics are recorded, and the response body is 
wrapped so response metrics and the `http_executing` decrement follow body 
completion or drop.
   - The `Err` (transport/connection failure) path is unchanged: the request 
never produced a response, so only `http_connection_errors_total` and the gauge 
decrement are recorded.
   - Added unit tests covering a 404 response with non-empty request and 
response bodies (status error + request/response metrics + gauge lifecycle) and 
an early-dropped 500 response body.
   - No downstream layer changes: `metrics`, `fastmetrics`, `prometheus`, 
`prometheus-client`, and `otelmetrics` contain only interceptor impls and no 
tests asserting the old behavior.
   
   # Are there any user-facing changes?
   
   Yes — a metrics fix: HTTP error responses now produce the same 
request/response metrics as successful responses, and `http_executing` remains 
elevated until the error response body completes or is dropped. Dropping an 
unconsumed error body records `http_connection_errors_total`, matching the 
existing early-drop semantics of successful response bodies.
   
   # Breaking changes
   
   # AI Usage Statement
   
   - Harness: pi coding agent inside T3 Code.
   - Model: devin/swe-2.
   - Effort: max.
   - Role: Implemented the transport fix and the unit tests, and ran the local 
verification commands.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to