Uploaded image for project: 'Spring Framework'
  1. Spring Framework
  2. SPR-14683

Allow JMS listener instrumentation

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Open
    • Priority: Minor
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: 5.x Backlog
    • Component/s: JMS
    • Labels:
      None

      Description

      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);
              }
          }
      
      }
      

        Attachments

          Activity

            People

            Assignee:
            snicoll St├ęphane Nicoll
            Reporter:
            mgrzejszczak Marcin Grzejszczak
            Last updater:
            Spring Issuemaster
            Votes:
            2 Vote for this issue
            Watchers:
            9 Start watching this issue

              Dates

              Created:
              Updated:
              Days since last comment:
              1 year, 28 weeks, 6 days ago