cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Fetch Spans to Calculate Duration as shown in Distributed Tracing

StrangerThing
Advisor

I'm trying to mimic the way duration of a trace is shown in the Distributed Tracing apps. I'm getting very, very close but seem to be missing something. I realize this may be slightly different depending on the application, but I'd like to know if anyone has had any success with this or if anyone from Dynatrace would like to chime in and describe how it's calculated. 

My trouble is some of the spans seem to be duplicated to represent code functions and if I don't exclude them from my query they will contribute to the overall sum of the durations.

The reason this is important is because I'd like to calculate duration of a trace, but without certain specific spans and their sub-spans. I'm trying to recreate the duration in DQL as a start.

Observability Engineer at FreedomPay
2 REPLIES 2

marco_irmer
Champion

I think you can get the main trace if you look for spans where the span.parent_id value is not present (null). 

In its simplest form and without any additional filters, the DQL might look like this:

fetch spans
| filter isNull(span.parent_id)
| fields start_time, trace.id, dt.entity.service, endpoint.name, duration

That doesn't seem to work because my beginning span also has a span.parent_id

Observability Engineer at FreedomPay

Featured Posts