DataDog trace JMS

88
July 02, 2022, at 9:00 PM

I'am using the "dd-trace-ot" version 0.93.0 lib to trace my methods using DataDog.

I'am using spring JMS to consume messages. What i want is to search for the service in DataDog and see the JMS message consume as a trace, but i can only see HTTP requests.

I have a serice that from a HTTP request posts a message in the queue so another service can consume it. In this case, as the trace is started from the HTTP request i'am able to see the entire chain, the start of the request and the message consume. But if i go the service that consume the message i can't see a trace from the JMS.

Another thing is that in the case above, in the flame graph the service that consumes has the subtitle "jms" and not the service name (the service names i correct in the span tags).

How can i make DataDog shows the span as a trace in the service?

Answer 1

Datadog will not do this automaticly using @Trace. What i had to do is create a span by hand on the JMS annotated method and set the tag "service.name".

@JmsListerner(...)
@Trace
public void receiveMessage(Message message) {
    var span = GlobalTracer.get().activeSpan();
    if (span != null) {
        span.setTag(DDTags.SERVICE_NAME, "servie-name"); // this is the same as "service.name"
    }
    try {
        ...
    } finally {
        if (span != null)  span.finish();
    }
    
}
Rent Charter Buses Company
READ ALSO
Auto generate hal links for in spring boot

Auto generate hal links for in spring boot

Is it possible to have Spring Boot automatically generate hal links for rest controller just like it does for repository?

101
How to read ArrayList<String> field from database with PostgreSQL JDBC

How to read ArrayList<String> field from database with PostgreSQL JDBC

I'm having an issue with getting the value of stored ArrayList<String> as VARCHAR[] in the database

97
Connection error returned from successful microservices call

Connection error returned from successful microservices call

Consider a scenario where I have 3 microservices say A, B, and C

129