OpenTracing Instrumentation for JMS 2 API


License

License

GroupId

GroupId

io.opentracing.contrib
ArtifactId

ArtifactId

opentracing-jms-2
Last Version

Last Version

0.1.11
Release Date

Release Date

Type

Type

jar
Description

Description

OpenTracing Instrumentation for JMS 2 API
OpenTracing Instrumentation for JMS 2 API

Download opentracing-jms-2

How to add to project

<!-- https://jarcasting.com/artifacts/io.opentracing.contrib/opentracing-jms-2/ -->
<dependency>
    <groupId>io.opentracing.contrib</groupId>
    <artifactId>opentracing-jms-2</artifactId>
    <version>0.1.11</version>
</dependency>
// https://jarcasting.com/artifacts/io.opentracing.contrib/opentracing-jms-2/
implementation 'io.opentracing.contrib:opentracing-jms-2:0.1.11'
// https://jarcasting.com/artifacts/io.opentracing.contrib/opentracing-jms-2/
implementation ("io.opentracing.contrib:opentracing-jms-2:0.1.11")
'io.opentracing.contrib:opentracing-jms-2:jar:0.1.11'
<dependency org="io.opentracing.contrib" name="opentracing-jms-2" rev="0.1.11">
  <artifact name="opentracing-jms-2" type="jar" />
</dependency>
@Grapes(
@Grab(group='io.opentracing.contrib', module='opentracing-jms-2', version='0.1.11')
)
libraryDependencies += "io.opentracing.contrib" % "opentracing-jms-2" % "0.1.11"
[io.opentracing.contrib/opentracing-jms-2 "0.1.11"]

Dependencies

compile (1)

Group / Artifact Type Version
io.opentracing.contrib : opentracing-jms-common jar 0.1.11

provided (1)

Group / Artifact Type Version
javax.jms : javax.jms-api jar 2.0.1

test (5)

Group / Artifact Type Version
org.apache.activemq : artemis-server jar 2.11.0
org.apache.activemq : artemis-jms-client jar 2.11.0
org.awaitility : awaitility jar 3.1.6
junit : junit jar 4.12
io.opentracing : opentracing-mock jar 0.33.0

Project Modules

There are no modules declared in this project.

Build Status Coverage Status Released Version Apache-2.0 license

OpenTracing JMS Instrumentation

OpenTracing instrumentation for JMS.

Installation

JMS 1

pom.xml

<dependency>
    <groupId>io.opentracing.contrib</groupId>
    <artifactId>opentracing-jms-1</artifactId>
    <version>VERSION</version>
</dependency>

JMS 2

pom.xml

<dependency>
    <groupId>io.opentracing.contrib</groupId>
    <artifactId>opentracing-jms-2</artifactId>
    <version>VERSION</version>
</dependency>

Spring JMS

pom.xml

<dependency>
    <groupId>io.opentracing.contrib</groupId>
    <artifactId>opentracing-jms-spring</artifactId>
    <version>VERSION</version>
</dependency>

You most likely need to exclude spring-jms and spring-context dependencies and add own (to avoid jar hell):

<dependency>
    <groupId>io.opentracing.contrib</groupId>
    <artifactId>opentracing-jms-spring</artifactId>
    <version>VERSION</version>
    <exclusions>
        <exclusion>
            <groupId>org.springframework</groupId>
            <artifactId>spring-jms</artifactId>
        </exclusion>
        <exclusion>
             <groupId>org.springframework</groupId>
             <artifactId>spring-context</artifactId>
        </exclusion>
    </exclusions>
</dependency>

<dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-jms</artifactId>
    <version>required version</version>
</dependency>

<dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-context</artifactId>
    <version>required version</version>
</dependency>

Usage

// Instantiate tracer
Tracer tracer = ...

JMS API

// decorate JMS MessageProducer with TracingMessageProducer
TracingMessageProducer producer = new TracingMessageProducer(messageProducer, tracer);

// decorate JMS JMSProducer with TracingJMSProducer need Session
Session session = ...
TracingJMSProducer producer = new TracingJMSProducer(jmsProducer, session, tracer);
// or with JMSContext
JMSContext jmsContext = ...
TracingJMSProducer producer = new TracingJMSProducer(jmsProducer, jmsContext, tracer);

// decorate JMS MessageConsumer with TracingMessageConsumer
TracingMessageConsumer consumer = new TracingMessageConsumer(messageConsumer, tracer);

// decorate JMS MessageListener if used with TracingMessageListener
TracingMessageListener listener = new TracingMessageListener(messageListener, tracer);
consumer.setMessageListener(listener);

// send message
Message message = ...
producer.send(message);

// receive message
Message message = consumer.receive();

Spring JMS

// create TracingJmsTemplate which extends Spring JmsTemplate
JmsTemplate jmsTemplate = new TracingJmsTemplate(connectionFactory, tracer); 

// send and receive messages as usual
jmsTemplate.send(...)
jmsTemplate.convertAndSend(...);
jmsTemplate.receive(...)
jmsTemplate.receiveAndConvert(...);
...

If @JmsListener is used then it is required to import TracingJmsConfiguration e.g.

@Configuration 
@Import(TracingJmsConfiguration.class)
@EnableJms
public class JmsConfiguration {
 ...
}

Java 9+

Modules opentracing-jms-1 and opentracing-jms-2 have next Automatic-Module-Name accordingly:

  • io.opentracing.contrib.jms1
  • io.opentracing.contrib.jms2

OpenTracing Conventions

Message properties

When a message exchange between a producer and consumer is traced using an OpenTracing compliant tracer, the trace context and any defined baggage items will be carried in the JMS message properties.

OpenTracing does not place any restrictions on the names used for the trace context and baggage item properties. However the JMS API does not permit the hyphen/dash - character to be used. Therefore, it is necessary to encode the trace context and baggage item names.

The steps used to encode the key names are:

  • replace any - character with __dash__

When the message is consumed, the steps are reversed to decode the original key names.

Any libraries that instrument the JMS API should conform to this convention to enable tracing interoperability.

License

Apache 2.0 License.

io.opentracing.contrib

3rd-Party OpenTracing API Contributions

3rd-party contributions that use OpenTracing. **The repositories in this org are *not* affiliated with the CNCF.**

Versions

Version
0.1.11
0.1.10
0.1.9
0.1.8
0.1.7
0.1.6
0.1.5
0.1.4
0.1.3
0.1.2
0.1.1
0.1.0
0.0.11
0.0.10
0.0.9
0.0.8
0.0.7
0.0.6
0.0.5
0.0.4
0.0.3
0.0.2
0.0.1