Toniotti
Toniotti

Reputation: 85

DataDog trace JMS

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?

Upvotes: 1

Views: 1347

Answers (1)

Toniotti
Toniotti

Reputation: 85

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

Upvotes: 1

Related Questions