Count non-OK responses in failed-requests metric#4564
Count non-OK responses in failed-requests metric#4564pepone wants to merge 2 commits intoicerpc:mainfrom
Conversation
MetricsInterceptor and MetricsMiddleware only counted thrown exceptions in failed-requests, ignoring returned IncomingResponse / OutgoingResponse with non-OK StatusCode. The library's own internal components routinely return non-OK responses rather than throwing — DeadlineMiddleware returns DeadlineExceeded, Router.NotFoundDispatcher returns NotFound, generated dispatchers convert DispatchException to non-OK responses — so a typical production setup silently under-reported failures and produced metrics that depended on whether each component chose to throw or return. Most strikingly, the same logical event produced different metrics on the two sides of a request: DeadlineInterceptor throws and counts as a failure on the client, while DeadlineMiddleware returns a non-OK response and was counted as success on the server. Inspect StatusCode after awaiting the next invoker/dispatcher and increment failed-requests when it is not Ok. Closes icerpc#4435
There was a problem hiding this comment.
Pull request overview
Updates IceRpc.Metrics to count non-OK responses as failures in the failed-requests metric, aligning metrics behavior between “returned error responses” and “thrown exceptions” (Fix #4435).
Changes:
- Increment
failed-requestswhen dispatch/invocation completes with a non-StatusCode.Okresponse. - Add regression tests covering non-OK
OutgoingResponse(dispatch) and non-OKIncomingResponse(invocation).
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
src/IceRpc.Metrics/MetricsMiddleware.cs |
Counts non-OK OutgoingResponse.StatusCode as a failed dispatch. |
src/IceRpc.Metrics/MetricsInterceptor.cs |
Counts non-OK IncomingResponse.StatusCode as a failed invocation. |
tests/IceRpc.Metrics.Tests/MetricsMiddlewareTests.cs |
Adds coverage asserting non-OK dispatch responses increment failed-requests. |
tests/IceRpc.Metrics.Tests/MetricsInterceptorTests.cs |
Adds coverage asserting non-OK invocation responses increment failed-requests. |
|
One case I'm not sure here is iceprc |
InsertCreativityHere
left a comment
There was a problem hiding this comment.
Looks good to me!
Also not clear to me whether these should be counted as failures... I'd lean towards "yes", but it's not a strong "yes" : v) |
Fix #4435