Browse Source

Upgrade to Micrometer 1.12.0-RC1

Closes gh-31398
pull/31413/head
Brian Clozel 1 year ago
parent
commit
99c673f3ea
  1. 8
      framework-docs/modules/ROOT/pages/integration/observability.adoc
  2. 4
      framework-platform/framework-platform.gradle
  3. 3
      spring-jms/spring-jms.gradle
  4. 10
      spring-jms/src/main/java/org/springframework/jms/core/JmsTemplate.java
  5. 14
      spring-jms/src/main/java/org/springframework/jms/listener/AbstractMessageListenerContainer.java

8
framework-docs/modules/ROOT/pages/integration/observability.adoc

@ -117,8 +117,8 @@ By default, the following `KeyValues` are created: @@ -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 @@ -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 @@ -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<T>)`).
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

4
framework-platform/framework-platform.gradle

@ -8,7 +8,7 @@ javaPlatform { @@ -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 { @@ -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")

3
spring-jms/spring-jms.gradle

@ -11,13 +11,14 @@ dependencies { @@ -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")

10
spring-jms/src/main/java/org/springframework/jms/core/JmsTemplate.java

@ -16,7 +16,7 @@ @@ -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; @@ -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 @@ -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 @@ -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);

14
spring-jms/src/main/java/org/springframework/jms/listener/AbstractMessageListenerContainer.java

@ -16,10 +16,10 @@ @@ -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; @@ -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 @@ -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 {

Loading…
Cancel
Save