You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When running a Micronaut server with a custom exception handler that maps specific exceptions to HTTP statuses other than 500, the metrics incorrectly record the status as 500. This issue arises when using Micronaut versions 4.7.x and above, whereas the expected behavior was observed in version 4.6.x.
Given
an exception "DemoException"
an endpoint "GET /api/error" which triggers the exception
a CustomExceptionHandler implementing ExceptionHandler<DemoException, HttpResponse> responding with http status 400
Upon invoking the endpoint that triggers the DemoException, the expected metric should be:
We are also seeing similar issue on 4.7.5 version, we are emitting bad request status code 400 from the exception handler but the metrics is capturing it as 500.
Till the fix is available is there any way to work around this problem, as we are heavily relying on the metrics.
Expected Behavior
When running a Micronaut server with a custom exception handler that maps specific exceptions to HTTP statuses other than 500, the metrics incorrectly record the status as 500. This issue arises when using Micronaut versions 4.7.x and above, whereas the expected behavior was observed in version 4.6.x.
Given
ExceptionHandler<DemoException, HttpResponse>
responding with http status 400Upon invoking the endpoint that triggers the DemoException, the expected metric should be:
http_server_requests_seconds_count{exception="none",method="GET",status="400",uri="/api/error"} 1
Actual Behaviour
Instead of recording the expected status, the metric is:
http_server_requests_seconds_count{exception="DemoException",method="GET",status="500",uri="/api/error"} 1
Steps To Reproduce
Please see the example in the repository below.
Environment Information
Example Application
https://github.com/danielksb/micronaut-demo-micrometer-bug
Version
4.7.x
The text was updated successfully, but these errors were encountered: