java-spring-cloud icon indicating copy to clipboard operation
java-spring-cloud copied to clipboard

Trace messaging

Open pavolloffay opened this issue 8 years ago • 31 comments

Trace org.springframework.messaging.MessageChannel

pavolloffay avatar Jul 12 '17 15:07 pavolloffay

This integration should trace all messaging platforms supported by Spring:

  • [x] JmsTemplate
  • [x] KafkaTemplate https://projects.spring.io/spring-kafka/
  • [x] 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 )

pavolloffay avatar Aug 08 '17 07:08 pavolloffay

Reopened, it's not done completely.

pavolloffay avatar Aug 11 '17 13:08 pavolloffay

Currently, only artemis and activemq are supported. We need to implement rabbitmq integration for RabbitTemplate and AmqpTemplate and also kafka.

pavolloffay avatar Aug 30 '17 10:08 pavolloffay

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.

malafeev avatar Sep 25 '17 08:09 malafeev

@malafeev thanks, we should fix it. Can you provide examples of methods annotated with @JmsListener?

cc @alesj

pavolloffay avatar Sep 25 '17 08:09 pavolloffay

https://docs.spring.io/spring/docs/current/spring-framework-reference/html/jms.html#jms-annotated

malafeev avatar Sep 25 '17 08:09 malafeev

@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.

alesj avatar Sep 28 '17 07:09 alesj

Hi @pavolloffay Any update on this? I'd like to be able to trace messages using Spring amqp/RabbitTemplate Thank you!

ask4gilles avatar Feb 23 '18 17:02 ask4gilles

@gytis would the integration you have recently added (spring messaging) trace amqp/rabbit template?

pavolloffay avatar Feb 23 '18 17:02 pavolloffay

@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 avatar Feb 26 '18 08:02 gytis

@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?

ask4gilles avatar Feb 26 '18 09:02 ask4gilles

Yes it probably needs a dedicated insturmentation

pavolloffay avatar Feb 26 '18 10:02 pavolloffay

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?

ask4gilles avatar Apr 13 '18 08:04 ask4gilles

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.

gytis avatar Apr 13 '18 08:04 gytis

Thanks @gytis , that's also the way I saw it.

ask4gilles avatar Apr 13 '18 08:04 ask4gilles

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 avatar Apr 13 '18 08:04 pavolloffay

@pavolloffay https://github.com/opentracing-contrib/java-spring-cloud/pull/126 is ready for review :)

ask4gilles avatar Apr 17 '18 05:04 ask4gilles

RabbitMQ instrumentation is located here. https://github.com/opentracing-contrib/java-spring-rabbitmq Its starter has been integrated here https://github.com/opentracing-contrib/java-spring-cloud/pull/158

ask4gilles avatar Jun 19 '18 16:06 ask4gilles

Hi @pavolloffay Any update on kafka integration? I'd like to be able to trace messages using Spring Cloud Stream and Kafka. Thank you!!

bygui86 avatar Jul 13 '18 14:07 bygui86

hi @bygui86, not yet. Would you like to contribute it?

pavolloffay avatar Jul 13 '18 14:07 pavolloffay

Thanks @pavolloffay, I will try to have a look and understand how to achieve that :)

bygui86 avatar Jul 18 '18 08:07 bygui86

Hmm; wasn't aware of this issue; this seems related for passing tracing data between Kafka & Spring Cloud: https://github.com/opentracing-contrib/java-kafka-client/issues/26 Any chance you can improve the current integration? The proposed workaround at present seems too cumbersome to be practical.

timtebeek avatar Jul 19 '18 16:07 timtebeek

Looking at JMS/RabbitMQ integrations looks like Kafka also requires some bean post processing hacks :)

malafeev avatar Jul 20 '18 02:07 malafeev

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.

bygui86 avatar Jul 20 '18 07:07 bygui86

@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 https://github.com/jaegertracing/jaeger-client-java/issues/363 https://github.com/jaegertracing/jaeger-client-java/issues/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 avatar Jul 20 '18 11:07 bygui86

@bygui86 thanks, I will have a look at it

pavolloffay avatar Jul 20 '18 11:07 pavolloffay

@bygui86 does kafka tracing work via spring stream without any changes in this repo? Do we need to provide some auto configs here?

pavolloffay avatar Jul 23 '18 11:07 pavolloffay

@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.

bygui86 avatar Jul 23 '18 11:07 bygui86

@pavolloffay any idea when KafkaTemplate will be supported?

ghilainm avatar Mar 18 '19 15:03 ghilainm

@pavolloffay Can support for KafkaTemplate be assumed done with the PR referred to, above? The comment here reflects it as open.

garimakemwal avatar May 11 '20 18:05 garimakemwal