Marcin Grzejszczak opened SPR-14683 and commented
In Spring Cloud Sleuth we would want to give the users a possibility to instrument all @JmsListener
annotated methods in order to propagate tracing information. In the Issue Garry mentions that
It's not currently possible to customize the adapter.
Or, a tweak in JmsListenerAnnotationBeanPostProcessor to wrap the listener in a proxy or similar.
Can we give the possibility of adding listeners / proxies / whatever to instrument the listeners?
For all incoming messages from JMS we would like to be able to do some pre processing and post processing (let's assume that the message arrived from a destination "foo").
class SomeMagicalClassThatWillHelpUsSolveThisProblem {
private final SpanExtractor<Message> messagingSpanExtractor;
private final Tracer tracer;
// constructor
public void magicalMethod(Message message, String destination, ProceedingPointcut pointcut) {
// we need to extract tracing information from a message and inject it into a span
Span parentSpan = messagingSpanExtractor.joinTrace(message);
Span continuedSpan = tracer.continueSpan(span);
tracer.addTag("method", pointcut.giveMeTheNameOfTheMethodThatWillProcessTheMessage());
tracer.addTag("class", pointcut.giveMeTheNameOfTheClassThatWillProcessTheMessage());
try {
// let the normal method execution take place
pointcut.proceed(...);
} finally {
// once the message has been processed we need to close the span
tracer.close(span);
}
}
}
Reference URL: https://github.com/spring-cloud/spring-cloud-sleuth/issues/151#issuecomment-245828688
2 votes, 9 watchers
Comment From: spring-projects-issues
Grenville Wilson commented
I'm a user directly affected by this problem, since it prevents Spring Sleuth spans from propagating across JMS connections. I can confirm that this would resolve the issue I've been having with @JmsListener
annotated methods not picking up spans in the headers of JMS messages.
Comment From: spring-projects-issues
Ales Justin commented
For OT I've just added such integration, which should imho handle any payload: * https://github.com/opentracing-contrib/java-spring-cloud/pull/59
Comment From: spring-projects-issues
Stéphane Nicoll commented
Ales Justin this is very interesting. Can you extract the API that would make this possible without a full replacement as you're doing now? I can see a much more elegant solution if we change how the registry creates endpoints.
Thoughts?
Comment From: spring-projects-issues
Ales Justin commented
Stéphane Nicoll yeah, was just thinking about this yday -- to provide a PR, but it was already 2am. :-) Will do it today, it should be simple, as all we need to do is to have abstraction over MethodJmsListenerEndpoint::createMessageListenerInstance().
Comment From: spring-projects-issues
Jon Schneider commented
We'll need the same feature for Micrometer. See this related issue.
Comment From: snicoll
Superseded by #30335