Class JmsInstrumentation
java.lang.Object
io.micrometer.jakarta9.instrument.jms.JmsInstrumentation
Instrument Jakarta JMS
sessions for observability.
This instrumentation proxies JMS sessions to intercept various calls and
create dedicated observations:
send*method calls onMessageProducerwill create"jms.message.publish"observations.- When configuring a
MessageListeneronMessageConsumerinstances returned by the session,"jms.message.process"observations are created when messages are received by the callback.
Here is how an existing JMS Session instance can be instrumented for observability:
Session original = ...
ObservationRegistry registry = ...
Session session = JmsInstrumentation.instrumentSession(original, registry);
Topic topic = session.createTopic("micrometer.test.topic");
MessageProducer producer = session.createProducer(topic);
// this operation will create a "jms.message.publish" observation
producer.send(session.createMessage("test message content"));
MessageConsumer consumer = session.createConsumer(topic);
// when a message is processed by the listener,
// a "jms.message.process" observation is created
consumer.setMessageListener(message -> consumeMessage(message));
- Since:
- 1.12.0
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionstatic jakarta.jms.SessioninstrumentSession(jakarta.jms.Session session, io.micrometer.observation.ObservationRegistry registry) Instrument theSessiongiven as argument for observability and record observations using the provided Observation registry.
-
Method Details
-
instrumentSession
public static jakarta.jms.Session instrumentSession(jakarta.jms.Session session, io.micrometer.observation.ObservationRegistry registry) Instrument theSessiongiven as argument for observability and record observations using the provided Observation registry.- Parameters:
session- the target session to proxy for instrumentationregistry- the Observation registry to use- Returns:
- the instrumented session that should be used to record observations
-