Matti
Matti

Reputation: 55

No jms trace id in spring boot 3.1.3

I have two similiar projects. One with spring boot 2.7 and sleuth, another with spring boot 3.1.3 and micrometer. Codebase is almost the same, this is just a POC showing that micrometer still doesn't add traceid to jms messages using JmsTemplate and @JmsListener.

Working minimal examples are located here: https://github.com/mbadziong/micrometer-broken-tracing

Sender and Receiver classes:

@Component
public class Receiver {

    private static Logger logger = LoggerFactory.getLogger(Receiver.class);

    @JmsListener(destination = "test-queue")
//    @Observed
    public void receive(String s) {
        logger.info("received message: {}", s);
    }
}
@RestController
public class Sender {
    private static Logger logger = LoggerFactory.getLogger(Sender.class);

    @Autowired
    JmsTemplate jmsTemplate;

    @GetMapping
    @ResponseStatus(HttpStatus.ACCEPTED)
    public void send() {
        logger.info("sending message...");
        jmsTemplate.convertAndSend("test-queue", "hello");
    }
}

In version with sleuth, receiver logs to the console with traceId and spanId. In version with micrometer trace is missing.

Do I miss some additional configuration to make it work?

Upvotes: 0

Views: 1181

Answers (1)

ndrscodes
ndrscodes

Reputation: 41

there seems to be no JMS support with Micrometer as of now. There is a PR adding JMS instrumentation to micrometer (https://github.com/spring-projects/spring-framework/issues/30335) as well as a PR for adding this functionality to the Spring JmsTemplate (https://github.com/spring-projects/spring-framework/issues/30335). For micrometer, this seems to be included in the 1.12.0 release. For Spring, it will be Spring 6.1.

You could check out Milestone/Snapshot releases of both and check if they provide the functionality you need. Alternatively, you can build your own mechanism for reading and writing the corresponding JMS headers.

Upvotes: 0

Related Questions