Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow JMS listener instrumentation [SPR-14683] #19247

Open
spring-issuemaster opened this issue Sep 9, 2016 · 5 comments

Comments

@spring-issuemaster
Copy link
Collaborator

@spring-issuemaster spring-issuemaster commented Sep 9, 2016

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: spring-cloud/spring-cloud-sleuth#151 (comment)

2 votes, 9 watchers

@spring-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

@spring-issuemaster spring-issuemaster commented Sep 28, 2017

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.

@spring-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

@spring-issuemaster spring-issuemaster commented Sep 28, 2017

Ales Justin commented

For OT I've just added such integration, which should imho handle any payload:

@spring-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

@spring-issuemaster spring-issuemaster commented Sep 29, 2017

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?

@spring-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

@spring-issuemaster spring-issuemaster commented Sep 29, 2017

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().

@spring-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

@spring-issuemaster spring-issuemaster commented Oct 15, 2018

Jon Schneider commented

We'll need the same feature for Micrometer. See this related issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
1 participant
You can’t perform that action at this time.