diff --git a/micrometer-jakarta9/src/main/java/io/micrometer/jakarta9/instrument/jms/JmsProcessObservationContext.java b/micrometer-jakarta9/src/main/java/io/micrometer/jakarta9/instrument/jms/JmsProcessObservationContext.java index 4d8d29a892..3c28fe457f 100644 --- a/micrometer-jakarta9/src/main/java/io/micrometer/jakarta9/instrument/jms/JmsProcessObservationContext.java +++ b/micrometer-jakarta9/src/main/java/io/micrometer/jakarta9/instrument/jms/JmsProcessObservationContext.java @@ -16,6 +16,7 @@ package io.micrometer.jakarta9.instrument.jms; +import io.micrometer.common.util.internal.logging.WarnThenDebugLogger; import io.micrometer.observation.transport.ReceiverContext; import jakarta.jms.JMSException; import jakarta.jms.Message; @@ -33,12 +34,15 @@ */ public class JmsProcessObservationContext extends ReceiverContext { + private static final WarnThenDebugLogger logger = new WarnThenDebugLogger(JmsProcessObservationContext.class); + public JmsProcessObservationContext(Message receivedMessage) { super((message, key) -> { try { return message.getStringProperty(key); } - catch (JMSException exc) { + catch (JMSException | RuntimeException exc) { + logger.log("Failed get message property.", exc); return null; } }); diff --git a/micrometer-jakarta9/src/main/java/io/micrometer/jakarta9/instrument/jms/JmsPublishObservationContext.java b/micrometer-jakarta9/src/main/java/io/micrometer/jakarta9/instrument/jms/JmsPublishObservationContext.java index f16d2154d9..64e015c74f 100644 --- a/micrometer-jakarta9/src/main/java/io/micrometer/jakarta9/instrument/jms/JmsPublishObservationContext.java +++ b/micrometer-jakarta9/src/main/java/io/micrometer/jakarta9/instrument/jms/JmsPublishObservationContext.java @@ -17,6 +17,7 @@ package io.micrometer.jakarta9.instrument.jms; import io.micrometer.common.lang.Nullable; +import io.micrometer.common.util.internal.logging.WarnThenDebugLogger; import io.micrometer.observation.transport.SenderContext; import jakarta.jms.JMSException; import jakarta.jms.Message; @@ -33,15 +34,17 @@ */ public class JmsPublishObservationContext extends SenderContext { + private static final WarnThenDebugLogger logger = new WarnThenDebugLogger(JmsPublishObservationContext.class); + public JmsPublishObservationContext(@Nullable Message sendMessage) { super((message, key, value) -> { - try { - if (message != null) { + if (message != null) { + try { message.setStringProperty(key, value); } - } - catch (JMSException exc) { - // ignore + catch (JMSException | RuntimeException exc) { + logger.log("Failed set message property.", exc); + } } }); setCarrier(sendMessage);