How to trace rabbitmq end to end between producer and consumer for multiple microservices?

Viewed 1270

I am using rabbitmq as one of the microservice and for that I want trace the rabbitmq spans, I have used following dependencies for tracing the rabbitmq spans through opentracing,

compile io.opentracing.contrib:opentracing-spring-jaeger-cloud-starter:1.0.1
compile group: 'io.opentracing.contrib', name: 'opentracing-spring-rabbitmq-parent', version: '2.0.5'

I am getting only producer side spans for this microservice. producer

Tags routingkey
"" messageid
"null"

component
"rabbitmq"

exchange
"audit_exchange"

span.kind
"producer"

I want to get end to end tracing for the request which passed through multiple micro services and one of them is rabbitmq

like microservice1==>rabbitMQ(Producer)==>Microservice2==>rabbitMQ(Consumer)==>Response Service

How can I achieve this kind of tracing in jaeger UI?

1 Answers

I use io.opentracing.contrib:opentracing-spring-rabbitmq-starter:3.0.0. You can find some documentation here. With this mechanism I achieved exactly what you asked for.

I found 2 important things to make sure:

  1. The rabbit template has to be initialized BEFORE the RabbitMqTracingAutoConfiguration is called. In the beginning I had the problem that the bean was not created as the RabbitTemplate was created AFTER the RabbitMqTracingAutoConfiguration was called.
  2. Not all RestTemplate methods are surrounded with the Aspect. Here you can find an overview of which methods are currently supported. We have currently the problem, that RabbitTemplate.invoke is not supported.

Hopefully you find this helpful.

Related