OpenTracing Spring RabbitMQ
Provides message tracing for RabbitMQ through Spring AMQP. It can be used with any OpenTracing compatible implementation.
Compatibility table
Version | OpenTracing API | Spring Boot version |
---|---|---|
0.x.x | 0.31.0 | 1.5.x |
1.x.x | 0.31.0 | 2.1.x |
1.0.2 | 0.32.0 | 2.1.x |
2.0.x | 0.32.0 | 2.1.x |
3.0.x | 0.33.0 | 2.1.x |
Sent messages
The following methods are instrumented:
Class | Method | Instrumented |
---|---|---|
AmqpTemplate | void send(Message message) |
|
AmqpTemplate | void send(String routingKey, Message message) |
|
AmqpTemplate | void send(String exchange, String routingKey, Message message) |
|
AmqpTemplate | void convertAndSend(Object message) |
|
AmqpTemplate | void convertAndSend(String routingKey, Object message) |
|
AmqpTemplate | void convertAndSend(String exchange, String routingKey, Object message) |
|
AmqpTemplate | void convertAndSend(Object message, MessagePostProcessor messagePostProcessor) |
|
AmqpTemplate | void convertAndSend(String routingKey, Object message, MessagePostProcessor messagePostProcessor) |
|
AmqpTemplate | void convertAndSend(String exchange, String routingKey, Object message, MessagePostProcessor messagePostProcessor) |
|
AmqpTemplate | void convertAndSend(String exchange, String routingKey, Object message, @Nullable CorrelationData correlationData) |
|
AmqpTemplate | Message sendAndReceive(Message message) |
|
AmqpTemplate | Message sendAndReceive(String routingKey, Message message) |
|
AmqpTemplate | Message sendAndReceive(String exchange, String routingKey, Message message) |
|
AmqpTemplate | Object convertSendAndReceive(Object message) |
|
AmqpTemplate | Object convertSendAndReceive(String routingKey, Object message) |
|
AmqpTemplate | Object convertSendAndReceive(String exchange, String routingKey, Object message) |
|
AmqpTemplate | Object convertSendAndReceive(Object message, MessagePostProcessor messagePostProcessor) |
|
AmqpTemplate | Object convertSendAndReceive(String routingKey, Object message, MessagePostProcessor messagePostProcessor) |
|
AmqpTemplate | Object convertSendAndReceive(String exchange, String routingKey, Object message, MessagePostProcessor messagePostProcessor) |
|
AmqpTemplate | <T> T convertSendAndReceiveAsType(Object message, ParameterizedTypeReference<T> responseType) |
|
AmqpTemplate | <T> T convertSendAndReceiveAsType(String routingKey, Object message,ParameterizedTypeReference<T> responseType) |
|
AmqpTemplate | <T> T convertSendAndReceiveAsType(String routingKey, Object message, MessagePostProcessor messagePostProcessor, ParameterizedTypeReference<T> responseType) |
|
AmqpTemplate | <T> T convertSendAndReceiveAsType(String exchange, String routingKey, Object message,MessagePostProcessor messagePostProcessor, ParameterizedTypeReference<T> responseType) |
|
RabbitTemplate | Message sendAndReceive(final String exchange, final String routingKey, final Message message, @Nullable CorrelationData correlationData) |
|
RabbitTemplate | Object convertSendAndReceive(final String exchange, final String routingKey, final Object message, @Nullable CorrelationData correlationData) |
|
Received messages
At startup a RabbitMqReceiveTracingInterceptor
, will be added toSimpleMessageListenerContainer
or DirectMessageListenerContainer
advice chain, depending on your configuration.
@RabbitListener
will also benefit from it.
Span decorator
By default, a RabbitMqSpanDecorator
is provided, with the following attributes:
On send span
- component: rabbitmq
- exchange: [exchange_name]
- messageid: [message_id]
- routingkey: [routing_key]
On receive span
- component: rabbitmq
- exchange: [exchange_name]
- messageid: [message_id]
- routingkey: [routing_key]
- consumerqueue: [consumer_queue]
On send reply
Nothing by default.
On error
- event: error key
- error.object: exception
Note: you can customize your spans by declaring an overridden
RabbitMqSpanDecorator
bean.
Usage
This library is embedded in java-spring-cloud
Usage with Jaeger tracer
If you want to use Jaeger as tracer, you can benefit directly from it by importing java-spring-jaeger.
<dependency>
<groupId>io.opentracing.contrib</groupId>
<artifactId>opentracing-spring-jaeger-cloud-starter</artifactId>
</dependency>
Usage with Zipkin tracer
If you want to use Zipkin as tracer, you can benefit directly from it by importing java-spring-zipkin.
<dependency>
<groupId>io.opentracing.contrib</groupId>
<artifactId>opentracing-spring-zipkin-cloud-starter</artifactId>
</dependency>
Standalone usage
Note: make sure that an
io.opentracing.Tracer
bean is available. It is not provided by this library.
With Spring Boot
Add the following starter dependency to your pom.xml:
<dependency>
<groupId>io.opentracing.contrib</groupId>
<artifactId>opentracing-spring-rabbitmq-starter</artifactId>
</dependency>
With Spring
Add the following dependency to your pom.xml:
<dependency>
<groupId>io.opentracing.contrib</groupId>
<artifactId>opentracing-spring-rabbitmq</artifactId>
</dependency>
Jaeger UI example
Development
Maven checkstyle plugin is used to maintain consistent code style based on Google Style Guides
./mvnw clean install
Release
Follow instructions in RELEASE