From 99c673f3ea79b1fc8080cc227828f20c6d16fd5e Mon Sep 17 00:00:00 2001 From: Brian Clozel Date: Tue, 10 Oct 2023 15:40:32 +0200 Subject: [PATCH] Upgrade to Micrometer 1.12.0-RC1 Closes gh-31398 --- .../ROOT/pages/integration/observability.adoc | 8 ++++---- framework-platform/framework-platform.gradle | 4 ++-- spring-jms/spring-jms.gradle | 3 ++- .../org/springframework/jms/core/JmsTemplate.java | 10 +++++----- .../listener/AbstractMessageListenerContainer.java | 14 +++++++------- 5 files changed, 20 insertions(+), 19 deletions(-) diff --git a/framework-docs/modules/ROOT/pages/integration/observability.adoc b/framework-docs/modules/ROOT/pages/integration/observability.adoc index f080bccc30..8b35f1b4ef 100644 --- a/framework-docs/modules/ROOT/pages/integration/observability.adoc +++ b/framework-docs/modules/ROOT/pages/integration/observability.adoc @@ -117,8 +117,8 @@ By default, the following `KeyValues` are created: [[observability.jms]] == JMS messaging instrumentation -Spring Framework uses the Jakarta JMS instrumentation provided by Micrometer if the `io.micrometer:micrometer-core` dependency is on the classpath. -The `io.micrometer.core.instrument.binder.jms.JmsInstrumentation` instruments `jakarta.jms.Session` and records the relevant observations. +Spring Framework uses the Jakarta JMS instrumentation provided by Micrometer if the `io.micrometer:micrometer-jakarta9` dependency is on the classpath. +The `io.micrometer.jakarta9.instrument.jms.JmsInstrumentation` instruments `jakarta.jms.Session` and records the relevant observations. This instrumentation will create 2 types of observations: @@ -158,7 +158,7 @@ You will need to configure the `ObservationRegistry` on the `JmsTemplate` to ena include-code::./JmsTemplatePublish[] -It uses the `io.micrometer.core.instrument.binder.jms.DefaultJmsPublishObservationConvention` by default, backed by the `io.micrometer.core.instrument.binder.jms.JmsPublishObservationContext`. +It uses the `io.micrometer.jakarta9.instrument.jms.DefaultJmsPublishObservationConvention` by default, backed by the `io.micrometer.jakarta9.instrument.jms.JmsPublishObservationContext`. [[observability.jms.process]] === JMS message Processing instrumentation @@ -178,7 +178,7 @@ In all cases, Observations are only recorded if the observation registry is conf Similar observations are recorded with `JmsTemplate` when messages are processed by a `MessageListener`. Such listeners are set on a `MessageConsumer` within a session callback (see `JmsTemplate.execute(SessionCallback)`). -This observation uses the `io.micrometer.core.instrument.binder.jms.DefaultJmsProcessObservationConvention` by default, backed by the `io.micrometer.core.instrument.binder.jms.JmsProcessObservationContext`. +This observation uses the `io.micrometer.jakarta9.instrument.jms.DefaultJmsProcessObservationConvention` by default, backed by the `io.micrometer.jakarta9.instrument.jms.JmsProcessObservationContext`. [[observability.http-server]] == HTTP Server instrumentation diff --git a/framework-platform/framework-platform.gradle b/framework-platform/framework-platform.gradle index d60054fd76..55f6d7d13a 100644 --- a/framework-platform/framework-platform.gradle +++ b/framework-platform/framework-platform.gradle @@ -8,7 +8,7 @@ javaPlatform { dependencies { api(platform("com.fasterxml.jackson:jackson-bom:2.15.2")) - api(platform("io.micrometer:micrometer-bom:1.12.0-M3")) + api(platform("io.micrometer:micrometer-bom:1.12.0-RC1")) api(platform("io.netty:netty-bom:4.1.97.Final")) api(platform("io.netty:netty5-bom:5.0.0.Alpha5")) api(platform("io.projectreactor:reactor-bom:2023.0.0-M3")) @@ -46,7 +46,7 @@ dependencies { api("com.thoughtworks.xstream:xstream:1.4.20") api("commons-io:commons-io:2.11.0") api("de.bechte.junit:junit-hierarchicalcontextrunner:4.12.2") - api("io.micrometer:context-propagation:1.1.0-M4") + api("io.micrometer:context-propagation:1.1.0-RC1") api("io.mockk:mockk:1.13.4") api("io.projectreactor.netty:reactor-netty5-http:2.0.0-M3") api("io.projectreactor.tools:blockhound:1.0.8.RELEASE") diff --git a/spring-jms/spring-jms.gradle b/spring-jms/spring-jms.gradle index bbea35eedf..31da2fb302 100644 --- a/spring-jms/spring-jms.gradle +++ b/spring-jms/spring-jms.gradle @@ -11,13 +11,14 @@ dependencies { optional(project(":spring-context")) optional(project(":spring-oxm")) optional("com.fasterxml.jackson.core:jackson-databind") - optional("io.micrometer:micrometer-core") + optional("io.micrometer:micrometer-jakarta9") optional("jakarta.resource:jakarta.resource-api") optional("jakarta.transaction:jakarta.transaction-api") testImplementation(testFixtures(project(":spring-beans"))) testImplementation(testFixtures(project(":spring-tx"))) testImplementation("jakarta.jms:jakarta.jms-api") testImplementation('io.micrometer:context-propagation') + testImplementation("io.micrometer:micrometer-jakarta9") testImplementation("io.micrometer:micrometer-observation-test") testImplementation("org.apache.activemq:artemis-junit-5") testImplementation("org.apache.activemq:artemis-jakarta-client") diff --git a/spring-jms/src/main/java/org/springframework/jms/core/JmsTemplate.java b/spring-jms/src/main/java/org/springframework/jms/core/JmsTemplate.java index 403f7b56d8..d4aefcfa03 100644 --- a/spring-jms/src/main/java/org/springframework/jms/core/JmsTemplate.java +++ b/spring-jms/src/main/java/org/springframework/jms/core/JmsTemplate.java @@ -16,7 +16,7 @@ package org.springframework.jms.core; -import io.micrometer.core.instrument.binder.jms.JmsInstrumentation; +import io.micrometer.jakarta9.instrument.jms.JmsInstrumentation; import io.micrometer.observation.ObservationRegistry; import jakarta.jms.Connection; import jakarta.jms.ConnectionFactory; @@ -92,8 +92,8 @@ import org.springframework.util.ClassUtils; */ public class JmsTemplate extends JmsDestinationAccessor implements JmsOperations { - private static final boolean micrometerCorePresent = ClassUtils.isPresent( - "io.micrometer.core.instrument.binder.jms.JmsInstrumentation", JmsTemplate.class.getClassLoader()); + private static final boolean micrometerJakartaPresent = ClassUtils.isPresent( + "io.micrometer.jakarta9.instrument.jms.JmsInstrumentation", JmsTemplate.class.getClassLoader()); /** Internal ResourceFactory adapter for interacting with ConnectionFactoryUtils. */ private final JmsTemplateResourceFactory transactionalResourceFactory = new JmsTemplateResourceFactory(); @@ -474,7 +474,7 @@ public class JmsTemplate extends JmsDestinationAccessor implements JmsOperations * Configure the {@link ObservationRegistry} to use for recording JMS observations. * @param observationRegistry the observation registry to use. * @since 6.1 - * @see io.micrometer.core.instrument.binder.jms.JmsObservationDocumentation + * @see io.micrometer.jakarta10.instrument.jms.JmsInstrumentation */ public void setObservationRegistry(ObservationRegistry observationRegistry) { this.observationRegistry = observationRegistry; @@ -524,7 +524,7 @@ public class JmsTemplate extends JmsDestinationAccessor implements JmsOperations if (logger.isDebugEnabled()) { logger.debug("Executing callback on JMS Session: " + sessionToUse); } - if (micrometerCorePresent && this.observationRegistry != null) { + if (micrometerJakartaPresent && this.observationRegistry != null) { sessionToUse = MicrometerInstrumentation.instrumentSession(sessionToUse, this.observationRegistry); } return action.doInJms(sessionToUse); diff --git a/spring-jms/src/main/java/org/springframework/jms/listener/AbstractMessageListenerContainer.java b/spring-jms/src/main/java/org/springframework/jms/listener/AbstractMessageListenerContainer.java index 47fc2057a8..27493687f3 100644 --- a/spring-jms/src/main/java/org/springframework/jms/listener/AbstractMessageListenerContainer.java +++ b/spring-jms/src/main/java/org/springframework/jms/listener/AbstractMessageListenerContainer.java @@ -16,10 +16,10 @@ package org.springframework.jms.listener; -import io.micrometer.core.instrument.binder.jms.DefaultJmsProcessObservationConvention; -import io.micrometer.core.instrument.binder.jms.JmsObservationDocumentation; -import io.micrometer.core.instrument.binder.jms.JmsProcessObservationContext; -import io.micrometer.core.instrument.binder.jms.JmsProcessObservationConvention; +import io.micrometer.jakarta9.instrument.jms.DefaultJmsProcessObservationConvention; +import io.micrometer.jakarta9.instrument.jms.JmsObservationDocumentation; +import io.micrometer.jakarta9.instrument.jms.JmsProcessObservationContext; +import io.micrometer.jakarta9.instrument.jms.JmsProcessObservationConvention; import io.micrometer.observation.Observation; import io.micrometer.observation.ObservationRegistry; import jakarta.jms.Connection; @@ -150,8 +150,8 @@ import org.springframework.util.ErrorHandler; public abstract class AbstractMessageListenerContainer extends AbstractJmsListeningContainer implements MessageListenerContainer { - private static final boolean micrometerCorePresent = ClassUtils.isPresent( - "io.micrometer.core.instrument.binder.jms.JmsInstrumentation", AbstractMessageListenerContainer.class.getClassLoader()); + private static final boolean micrometerJakartaPresent = ClassUtils.isPresent( + "io.micrometer.jakarta9.instrument.jms.JmsInstrumentation", AbstractMessageListenerContainer.class.getClassLoader()); @Nullable private volatile Object destination; @@ -716,7 +716,7 @@ public abstract class AbstractMessageListenerContainer extends AbstractJmsListen } private Observation createObservation(Message message) { - if (micrometerCorePresent && this.observationRegistry != null) { + if (micrometerJakartaPresent && this.observationRegistry != null) { return ObservationFactory.create(this.observationRegistry, message); } else {