Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Observability instrumentation for Jakarta JMS #4007

Merged
merged 1 commit into from
Aug 10, 2023

Commits on Aug 5, 2023

  1. Add Observability instrumentation for Jakarta JMS

    This commit adds a new `JmsInstrumentation` class that instruments
    an instances of a `jakarta.jms.Session` with the Observation API.
    This proxies the `MessageProducer` and `MessageConsumer` instances
    created by the session and creates dedicated observations:
    
    * `send*` method calls on `MessageProducer` will create `"jms.message.publish"`
      observations.
    * when configuring a `MessageListener` on `MessageConsumer` instances returned
    by the session, `"jms.message.process"` observations are created when messages
    are received and processed 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));
    ```
    
    This change does not instrument `receive` methods on the
    `MessageConsumer` as there is little value here. The resulting metric
    would only measure the time it takes to receive the message (i.e. not
    process it) and there would be no actionable trace, as those methods
    return the received `Message` and its processing will not happen in
    tracing scope.
    
    Closes micrometer-metricsgh-4007
    bclozel committed Aug 5, 2023
    Configuration menu
    Copy the full SHA
    e0661f3 View commit details
    Browse the repository at this point in the history