sessions for observability.
This instrumentation proxies JMS sessions to intercept various calls and
create dedicated observations:
send* method calls on jakarta.jms.MessageProducer will create
"jms.message.publish"
observations.
jakarta.jms.MessageListener on
jakarta.jms.MessageConsumer instances 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));
JmsObservationDocumentation
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| public static Session | Returns: the instrumented session that should be used to record observationsthe target session to proxy for instrumentation session, ObservationRegistry the Observation registry to use registry)Instrument the |
| JmsInstrumentation | back to summary |
|---|---|
| private JmsInstrumentation() | |
| instrumentSession | back to summary |
|---|---|
| public static Session instrumentSession(Session session, ObservationRegistry registry) Instrument the
| |