# Traces on Grail: getting the "processing" time

**URL:** <https://community.dynatrace.com/t/traces-on-grail-getting-the-processing-time/45160>\
**Category:** Open Q&A\
**Tags:** distributed-traces-classic\
**Created:** [April 16, 2024, 2:55pm UTC](https://community.dynatrace.com/t/traces-on-grail-getting-the-processing-time/45160 "2024-04-16T14:55:42Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![r\_weber](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/r_weber/32/24884_2.png) [@r\_weber](https://community.dynatrace.com/u/r_weber)\
**Post date:** [April 16, 2024, 2:55pm UTC](https://community.dynatrace.com/t/traces-on-grail-getting-the-processing-time/45160/1 "2024-04-16T14:55:42Z")

</div>

I was just asking myself how to get the overall processing time of a trace. In Grail spans and traces all have a duration field but there is no knowledge of what runs asynchronously or sequentially.

Imagine this trace in the UI:

 ![r_weber_0-1713279094517.png](https://global.discourse-cdn.com/dynatrace/original/3X/9/2/928dd7255824e7ea11f6d3f9066aa85c34ab2f14.png)

With the async stuff going on the “response time” is 30.7ms. One can see this on the root span of the trace as well. But then there are a lot of async calls and the actual time I’d be interested is the “Processing time” which is ~1s.

If I want to know how much time is spent on a individual service int total I can’t just sum up the “duration” of these service calls, neither can I add up all span durations for the overall duration of the trace?

Any ideas how to solve this? How could one get the duration/processing time of this trace using a query?

---

<div class="post-metadata">

**Author:** ![imrj99](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/imrj99/32/21367_2.png) [@imrj99](https://community.dynatrace.com/u/imrj99)\
**Post date:** [December 10, 2024, 7:54pm UTC](https://community.dynatrace.com/t/traces-on-grail-getting-the-processing-time/45160/2 "2024-12-10T19:54:43Z")

</div>

anyone figured this out?

---

<div class="post-metadata">

**Author:** ![Andreas\_Gruber](https://avatars.discourse-cdn.com/v4/letter/a/ee59a6/32.png) [@Andreas\_Gruber](https://community.dynatrace.com/u/Andreas_Gruber)\
**Post date:** [January 24, 2025, 1:28pm UTC](https://community.dynatrace.com/t/traces-on-grail-getting-the-processing-time/45160/3 "2025-01-24T13:28:18Z")

</div>

[@r\_weber](https://community.dynatrace.com/user/35901) the processing time as you describe it would be the difference of the earliest start and latest end time of the spans of a trace when I got your question right. If you want to have this also for the spans of a the services within a trace you need to make a multi step summarize query.

I tried this in DQL and would get this result.

```auto
fetch spans
| summarize {request.start_time = min(start_time),
request.end_time = max(end_time)}, by: {trace.id, dt.entity.service}
| summarize {trace.start_time = min(request.start_time),
trace.end_time = max(request.end_time),
request.processing_times = collectArray(record(dt.entity.service, request.start_time, request.end_time, request.processing_time = request.end_time-request.start_time))}, by: {trace.id}
| fieldsAdd trace.processing_time = trace.end_time - trace.start_time

```

 ![Andreas_Gruber_1-1737725274796.png](https://global.discourse-cdn.com/dynatrace/original/3X/7/e/7e44a17019e7e97a636ff4447aee2e7bf2a8f7f7.png)

Does this help? For a single trace you could add a trace.id filter right after the fetch.
