Record unhanlded JMS exceptions as observation errors

Prior to this commit, when using the `DefaultMessageListenerContainer`
as a backing listener container for JMS messages, the instrumentation
would not record JMS exceptions as observation errors when they were not
handled by configured `ErrorHandler`.

This commit ensures that this is the case.

Fixes gh-32458
This commit is contained in:
Brian Clozel
2024-03-15 22:45:36 +01:00
parent d2000efbd8
commit a78704af24
2 changed files with 38 additions and 2 deletions

View File

@@ -339,7 +339,12 @@ public abstract class AbstractPollingMessageListenerContainer extends AbstractMe
}
status.setRollbackOnly();
}
handleListenerException(ex);
try {
handleListenerException(ex);
}
catch (Throwable throwable) {
observation.error(throwable);
}
// Rethrow JMSException to indicate an infrastructure problem
// that may have to trigger recovery...
if (ex instanceof JMSException jmsException) {