opentracing-contrib / java-spring-cloud

Distributed tracing for Spring Boot, Cloud and other Spring projects
Apache License 2.0
390 stars 143 forks source link

Trace messaging #5

Open pavolloffay opened 7 years ago

pavolloffay commented 7 years ago

Trace org.springframework.messaging.MessageChannel

pavolloffay commented 7 years ago

This integration should trace all messaging platforms supported by Spring:

In sleuth messaging is reused for tracing WebSockets ( #25 )

pavolloffay commented 7 years ago

Reopened, it's not done completely.

pavolloffay commented 7 years ago

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

malafeev commented 7 years ago

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 commented 7 years ago

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

cc @alesj

malafeev commented 7 years ago

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

alesj commented 6 years ago

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

ask4gilles commented 6 years ago

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

pavolloffay commented 6 years ago

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

gytis commented 6 years ago

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

ask4gilles commented 6 years ago

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

pavolloffay commented 6 years ago

Yes it probably needs a dedicated insturmentation

ask4gilles commented 6 years ago

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?

gytis commented 6 years ago

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.

ask4gilles commented 6 years ago

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

pavolloffay commented 6 years ago

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.

ask4gilles commented 6 years ago

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

ask4gilles commented 6 years ago

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

bygui86 commented 6 years ago

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

pavolloffay commented 6 years ago

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

bygui86 commented 6 years ago

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

timtebeek commented 6 years ago

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.

malafeev commented 6 years ago

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

bygui86 commented 6 years ago

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 commented 6 years ago

@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

pavolloffay commented 6 years ago

@bygui86 thanks, I will have a look at it

pavolloffay commented 6 years ago

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

bygui86 commented 6 years ago

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

ghilainm commented 5 years ago

@pavolloffay any idea when KafkaTemplate will be supported?

garimakemwal commented 4 years ago

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

pavolloffay commented 4 years ago

Per https://github.com/opentracing-contrib/java-spring-cloud/pull/280#issuecomment-602683961 yes. I am marking it as done.