21 Apr 2025 08:26 PM
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.
22 Apr 2025 12:05 AM
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
22 Apr 2025 02:54 PM
That doesn't seem to work because my beginning span also has a span.parent_id