Configure ObservationRegistry on JmsListener

Prior to this commit, we set in gh-37388 the ObservationRegistry on the
auto-configured JmsTemplate bean. This enables observations and context
propagation when sending JMS messages.

This commit applies the same to the `DefaultJmsListenerContainerFactory`
and the `DefaultJmsListenerContainerFactoryConfigurer`, in order to
enable observations on `@JmsListener` annotated methods.

This commit also refactors the support implemented in gh-37388 to avoid
relying on a bean post processor and instead set the observation
registry directly in the main auto-configuration: while Micrometer core
is an actuator-only dependency, Micrometer Observation API is a compile
dependnecy for spring-jms itself and there is no need to separate
concerns there.

Fixes gh-38613
This commit is contained in:
Brian Clozel
2023-12-01 09:36:00 +01:00
parent d172b22064
commit 0321a8a05b
10 changed files with 54 additions and 169 deletions

View File

@@ -745,10 +745,9 @@ Metrics are tagged by the name of the executor, which is derived from the bean n
[[actuator.metrics.supported.jms]]
==== JMS Metrics
Auto-configuration enables the instrumentation of all available `JmsTemplate` beans.
`JmsMessagingTemplate` instances built with instrumented `JmsTemplate` beans will also record observations.
See the {spring-framework-docs}/integration/observability.html#observability.jms.publish[Spring Framework reference documentation for more information on produced observations].
Auto-configuration enables the instrumentation of all available `JmsTemplate` beans and `@JmsListener` annotated methods.
This will produce `"jms.message.publish"` and `"jms.message.process"` metrics respectively.
See the {spring-framework-docs}/integration/observability.html#observability.jms[Spring Framework reference documentation for more information on produced observations].
[[actuator.metrics.supported.spring-mvc]]