In certain Spring Boot applications, the DX APM Java Agent may report error counts (Errors Per Interval) that are two to three times higher than the actual number of exceptions triggered. This typically occurs when a custom global error handler and a log filter both process the same exception, leading to multiple metric increments for a single transaction.
The discrepancy is caused by how the Spring Boot server handles uncaught exceptions when using custom filters (e.g., LogFilter) and global exception handlers. If a servlet or filter throws an exception, the request is forwarded to a custom error page. Because the agent monitors servlet service methods, it detects the original request and the forwarded error page request as separate events, counting the error for each.
To resolve the overcounting of errors, implement the following changes:
Consolidate error handling logic so that only one component (either the Global Exception Handler or the LogFilter) attempts to write to the response or log the error event.
-Dintroscope.agent.log.level.root=DEBUG -Dintroscope.agent.log.destination=console,logfile