Document how to mark an observation as an error if the exception was handled #29848
Labels
in: web
Issues in web modules (web, webmvc, webflux, websocket)
theme: observability
An issue related to observability and tracing
theme: web-error-handling
An issue related to web error handling
type: documentation
A documentation task
Milestone
Affects: 6.0.3 (6.0.x)
With the current version (6.0.3) (and Boot 3.1), if I throw out an error from an MVC controller method and if I have an
@ExceptionHandler
, the error is not reported to the observation, i.e.:observation.error(...)
is not called.The issue is reproducible with a simple Boot project (initializer) and adding a
@RestController
with an error handler:After I call the endpoint and see the error response (500), if I check the metrics (or traces), I can see that the exception was never reported to the observation (e.g.: by checking the
/actuator/metrics
endpoint of the tracing backend).Here's what I see in the metrics endpoint (I simplified the JOSN):
Both the
exception
and theerror
tags should contain the error (IllegalStateException
) but they don't.After debugging this, I think the issue is that the exception attribute is not set in mvc, if I set it manually in the
@ExceptionHandler
, the error is reported as expected:If you need a reproducer on top of the initializer link and the snippets, you can use apps in micrometer-samples repo, e.g.: this one or this one but they already contain the workaround you need to remove it.
The text was updated successfully, but these errors were encountered: