Top Description Constructors Methods
io.micrometer.jakarta9.instrument.jms

public abstract Class JmsInstrumentation

extends Object
Class Inheritance
Imports
io.micrometer.observation.ObservationRegistry, jakarta.jms.Session, java.lang.reflect.Proxy

Instrument Jakarta JMS sessions for observability.

This instrumentation proxies JMS sessions to intercept various calls and create dedicated observations:

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));
Author
Brian Clozel
Since
1.12.0
See Also
JmsObservationDocumentation

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static Session

Returns:

the instrumented session that should be used to record observations
instrumentSession
(Session
the target session to proxy for instrumentation
session
,
ObservationRegistry
the Observation registry to use
registry
)

Instrument the Session given as argument for observability and record observations using the provided Observation registry.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

JmsInstrumentationback to summary
private JmsInstrumentation()

Method Detail

instrumentSessionback to summary
public static Session instrumentSession(Session session, ObservationRegistry registry)

Instrument the Session given as argument for observability and record observations using the provided Observation registry.

Parameters
session:Session

the target session to proxy for instrumentation

registry:ObservationRegistry

the Observation registry to use

Returns:Session

the instrumented session that should be used to record observations