opentracing-contrib / java-spring-rabbitmq

OpenTracing RabbitMQ instrumentation
Apache License 2.0
18 stars 21 forks source link

Wrong tracer method is being called due to pointcut not being specific enough #58

Open sasavilic opened 1 year ago

sasavilic commented 1 year ago

We had internal fork of your library and in one of our projects we used MessagePostProcessor together with RabbitTemplate, like in example below:

String topic = "foo";
String payload = "bar";
rabbitTemplate.convertAndSend(topic, (Object)payload, postProcessor);

Sometimes code would work and sometimes we would get error, that our classes that implements MessagePostProcessor could not be serialized, because it is neither string, byte array not it implements serializable interface.

Upon deep dive, we noticed that method convertAndSend(String, String, Object) would be called instead of convertAndSend(String, Object, MessagePostProcessor).

We noticed that whenever correct or wrong method is called is somewhat random: depends on how method proxy cache is built. We noticed that both wrapper would match, it was only matter of which one comes first in cache. If it is convertAndSend(String, Object, MessagePostProcessor), then everything works fine, if not, then we get error.

We were able to create tiny project where similar behaviour can be reproduced and observed.

I would recommend to update your pointcut specification to also include required types.