Trace messaging
pavolloffay opened this issue ยท 31 comments
Trace org.springframework.messaging.MessageChannel
This integration should trace all messaging platforms supported by Spring:
- JmsTemplate
- KafkaTemplate https://projects.spring.io/spring-kafka/
- RabbitTemplate https://projects.spring.io/spring-amqp/
- AmqpTemplate https://docs.spring.io/spring-boot/docs/current/reference/html/boot-features-messaging.html#boot-features-using-amqp-sending
In sleuth messaging is reused for tracing WebSockets ( #25 )
Reopened, it's not done completely.
Currently, only artemis
and activemq
are supported. We need to implement rabbitmq
integration for RabbitTemplate
and AmqpTemplate
and also kafka.
if method with @JmsListener
annotation has argument different than javax.jms.Message
then JmsListenerAspect
doesn't intercept a call and tracing is not working for such consumer.
@pavolloffay @malafeev hmmm, that's a bit trickier to handle, as you need to somehow get your hands on the actual JMS Message instance.
But I'll have a look to see what can be done.
Hi @pavolloffay
Any update on this? I'd like to be able to trace messages using Spring amqp/RabbitTemplate
Thank you!
@gytis would the integration you have recently added (spring messaging) trace amqp/rabbit template?
@pavolloffay I don't know, would have to run a test. It does trace Spring Cloud Stream with RabbitMQ, but not sure about Rabbit template.
@gytis @pavolloffay Looking at io.opentracing.contrib.spring.integration.messaging.OpenTracingChannelInterceptor, it instruments org.springframework.messaging.MessageChannel which is not used by org.springframework.amqp.rabbit.core.RabbitTemplate. I think a "traced" implementation of org.springframework.amqp.core.AmqpTemplate would be needed?
Yes it probably needs a dedicated insturmentation
Hi @gytis and @pavolloffay, I'd like to contribute on the rabbitMq instrumentation.
Should this happen in the opentracing-spring-messaging repo or somewhere else?
It should probably go to a separate repo similar to https://github.com/opentracing-contrib/java-jms. opentracing-spring-messaging is an instrumentation for massaging of Spring Integration i.e. ChannelInterceptor.
Thanks @gytis , that's also the way I saw it.
It depends on how complex it is and whether it can be reused in other projects. If it will just a wrapper around JMS it can be here.
Generally speaking you can submit a PR here and we will see whether it makes sense to move it somewhere else.
@pavolloffay #126 is ready for review :)
RabbitMQ instrumentation is located here.
https://github.com/opentracing-contrib/java-spring-rabbitmq
Its starter has been integrated here
#158
Hi @pavolloffay
Any update on kafka integration? I'd like to be able to trace messages using Spring Cloud Stream and Kafka.
Thank you!!
hi @bygui86, not yet. Would you like to contribute it?
Thanks @pavolloffay, I will try to have a look and understand how to achieve that :)
Hmm; wasn't aware of this issue; this seems related for passing tracing data between Kafka & Spring Cloud:
opentracing-contrib/java-kafka-client#26
Any chance you can improve the current integration? The proposed workaround at present seems too cumbersome to be practical.
Looking at JMS/RabbitMQ integrations looks like Kafka also requires some bean post processing hacks :)
Probably I found another way to integrate Spring Cloud Stream Kafka with OpenTracing.
I will try it today, if it's working I will post an example.
@pavolloffay I found a sort of work around to let everything work with Spring Cloud Stream, Kafka and Jaeger. Unfortunately as you can see from following issues there is a concurrency problem
jaegertracing/jaeger-client-java#363
jaegertracing/jaeger-client-java#334
And here is the repo with my example ;)
https://github.com/bygui86/spring-cloud-stream-kafka-jaeger
Let me know if you guys have the same exception and if you managed to solve it :)
Thanks
@bygui86 thanks, I will have a look at it
@bygui86 does kafka tracing work via spring stream without any changes in this repo? Do we need to provide some auto configs here?
@pavolloffay I'm still working on that side. As you can see for example in the class SinkTracingConfig, I had to redefine some beans from spring-kafka (DefaultKafkaConsumerFactory, ConcurrentKafkaListenerContainerFactory) and from opentracing-contrib-kafka (TracingConsumerFactory).
I will try to understand and better use the class "ConcurrentKafkaListenerContainerFactoryConfigurer" from spring-boot-autoconfigure, in order to avoid some bean redefinitions. I will try also to avoid redefine the TracingConsumerFactory bean.
If everything is working just with the ConcurrentKafkaListenerContainerFactoryConfigurer, I would say no need of auto-configs, otherwise could be useful something like TracingConsumerFactory.
So for now I'm not sure.
@pavolloffay any idea when KafkaTemplate will be supported?
@pavolloffay Can support for KafkaTemplate be assumed done with the PR referred to, above?
The comment here reflects it as open.
Per #280 (comment) yes. I am marking it as done.