Skip to content

Commit afb1772

Browse files
feat: add processing time queries per pipeline step and per document
Added 3 new queries/panels: - Processing Time by Pipeline Step (avg, p50, p90, max per step) - Total Document Processing Time (end-to-end workflow summary) - Per-Document Processing Time Breakdown (individual step timing) Queries parse elapsed time from traces logged by queue_handler_base and claim_processor workflow. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 1c0f510 commit afb1772

2 files changed

Lines changed: 109 additions & 1 deletion

File tree

infra/dashboards/token-usage-queries.kql

Lines changed: 60 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,66 @@ customEvents
293293
by process_id, Step = agent
294294
| order by process_id, TotalTokens desc
295295

296-
// 18. Daily processing volume with token costs
296+
// 18. Processing time per pipeline step
297+
traces
298+
| where timestamp > ago(7d)
299+
| where message has "Pipeline stage completed"
300+
| parse message with * "process_id=" process_id ", document=" document ", stage=" stage ", elapsed=" elapsed
301+
| where isnotempty(stage)
302+
| extend elapsed_parts = split(elapsed, ":")
303+
| extend hours = toint(elapsed_parts[0])
304+
| extend mins = toint(elapsed_parts[1])
305+
| extend sec_parts = split(tostring(elapsed_parts[2]), ".")
306+
| extend secs = toint(sec_parts[0])
307+
| extend ms = toint(sec_parts[1])
308+
| extend elapsed_seconds = hours * 3600.0 + mins * 60.0 + secs + ms / 100.0
309+
| summarize
310+
AvgSeconds = round(avg(elapsed_seconds), 2),
311+
P50Seconds = round(percentile(elapsed_seconds, 50), 2),
312+
P90Seconds = round(percentile(elapsed_seconds, 90), 2),
313+
MaxSeconds = round(max(elapsed_seconds), 2),
314+
Invocations = count()
315+
by Step = stage
316+
| order by AvgSeconds desc
317+
318+
// 19. Total document processing time (end-to-end workflow)
319+
traces
320+
| where timestamp > ago(7d)
321+
| where message has "Workflow elapsed time"
322+
| parse message with * "Workflow elapsed time: " elapsed " (start=" * ", end=" *
323+
| where isnotempty(elapsed)
324+
| extend elapsed_parts = split(elapsed, ":")
325+
| extend hours = toint(elapsed_parts[0])
326+
| extend mins = toint(elapsed_parts[1])
327+
| extend sec_parts = split(tostring(elapsed_parts[2]), ".")
328+
| extend secs = toint(sec_parts[0])
329+
| extend ms = toint(sec_parts[1])
330+
| extend elapsed_seconds = hours * 3600.0 + mins * 60.0 + secs + ms / 100.0
331+
| summarize
332+
DocumentsProcessed = count(),
333+
AvgSeconds = round(avg(elapsed_seconds), 2),
334+
P50Seconds = round(percentile(elapsed_seconds, 50), 2),
335+
P90Seconds = round(percentile(elapsed_seconds, 90), 2),
336+
P95Seconds = round(percentile(elapsed_seconds, 95), 2),
337+
MaxSeconds = round(max(elapsed_seconds), 2)
338+
339+
// 20. Per-document processing time breakdown by step
340+
traces
341+
| where timestamp > ago(7d)
342+
| where message has "Pipeline stage completed"
343+
| parse message with * "process_id=" process_id ", document=" document ", stage=" stage ", elapsed=" elapsed
344+
| where isnotempty(stage)
345+
| extend elapsed_parts = split(elapsed, ":")
346+
| extend hours = toint(elapsed_parts[0])
347+
| extend mins = toint(elapsed_parts[1])
348+
| extend sec_parts = split(tostring(elapsed_parts[2]), ".")
349+
| extend secs = toint(sec_parts[0])
350+
| extend ms = toint(sec_parts[1])
351+
| extend elapsed_seconds = round(hours * 3600.0 + mins * 60.0 + secs + ms / 100.0, 2)
352+
| project timestamp, process_id, document, Step=stage, ElapsedSeconds=elapsed_seconds
353+
| order by process_id, timestamp asc
354+
355+
// 21. Daily processing volume with token costs
297356
customEvents
298357
| where name == 'LLM_Agent_Token_Usage'
299358
| where timestamp > ago(30d)

infra/dashboards/token-usage-workbook.json

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,55 @@
217217
},
218218
"name": "tokens-by-filetype"
219219
},
220+
{
221+
"type": 1,
222+
"content": {
223+
"json": "---\n## Processing Time"
224+
},
225+
"name": "section-processing-time"
226+
},
227+
{
228+
"type": 3,
229+
"content": {
230+
"version": "KqlItem/1.0",
231+
"query": "traces\r\n| where timestamp > ago(7d)\r\n| where message has \"Pipeline stage completed\"\r\n| parse message with * \"process_id=\" process_id \", document=\" document \", stage=\" stage \", elapsed=\" elapsed\r\n| where isnotempty(stage)\r\n| extend elapsed_parts = split(elapsed, \":\")\r\n| extend hours = toint(elapsed_parts[0])\r\n| extend mins = toint(elapsed_parts[1])\r\n| extend sec_parts = split(tostring(elapsed_parts[2]), \".\")\r\n| extend secs = toint(sec_parts[0])\r\n| extend ms = toint(sec_parts[1])\r\n| extend elapsed_seconds = hours * 3600.0 + mins * 60.0 + secs + ms / 100.0\r\n| summarize\r\n AvgSeconds = round(avg(elapsed_seconds), 2),\r\n P50Seconds = round(percentile(elapsed_seconds, 50), 2),\r\n P90Seconds = round(percentile(elapsed_seconds, 90), 2),\r\n MaxSeconds = round(max(elapsed_seconds), 2),\r\n Invocations = count()\r\n by Step = stage\r\n| order by AvgSeconds desc",
232+
"size": 0,
233+
"title": "Processing Time by Pipeline Step",
234+
"timeContextFromParameter": "TimeRange",
235+
"queryType": 0,
236+
"resourceType": "microsoft.insights/components",
237+
"visualization": "table"
238+
},
239+
"name": "processing-time-by-step"
240+
},
241+
{
242+
"type": 3,
243+
"content": {
244+
"version": "KqlItem/1.0",
245+
"query": "traces\r\n| where timestamp > ago(7d)\r\n| where message has \"Workflow elapsed time\"\r\n| parse message with * \"Workflow elapsed time: \" elapsed \" (start=\" * \", end=\" *\r\n| where isnotempty(elapsed)\r\n| extend elapsed_parts = split(elapsed, \":\")\r\n| extend hours = toint(elapsed_parts[0])\r\n| extend mins = toint(elapsed_parts[1])\r\n| extend sec_parts = split(tostring(elapsed_parts[2]), \".\")\r\n| extend secs = toint(sec_parts[0])\r\n| extend ms = toint(sec_parts[1])\r\n| extend elapsed_seconds = hours * 3600.0 + mins * 60.0 + secs + ms / 100.0\r\n| summarize\r\n DocumentsProcessed = count(),\r\n AvgSeconds = round(avg(elapsed_seconds), 2),\r\n P50Seconds = round(percentile(elapsed_seconds, 50), 2),\r\n P90Seconds = round(percentile(elapsed_seconds, 90), 2),\r\n P95Seconds = round(percentile(elapsed_seconds, 95), 2),\r\n MaxSeconds = round(max(elapsed_seconds), 2)",
246+
"size": 3,
247+
"title": "Total Document Processing Time (End-to-End)",
248+
"timeContextFromParameter": "TimeRange",
249+
"queryType": 0,
250+
"resourceType": "microsoft.insights/components",
251+
"visualization": "table"
252+
},
253+
"name": "total-processing-time"
254+
},
255+
{
256+
"type": 3,
257+
"content": {
258+
"version": "KqlItem/1.0",
259+
"query": "traces\r\n| where timestamp > ago(7d)\r\n| where message has \"Pipeline stage completed\"\r\n| parse message with * \"process_id=\" process_id \", document=\" document \", stage=\" stage \", elapsed=\" elapsed\r\n| where isnotempty(stage)\r\n| extend elapsed_parts = split(elapsed, \":\")\r\n| extend hours = toint(elapsed_parts[0])\r\n| extend mins = toint(elapsed_parts[1])\r\n| extend sec_parts = split(tostring(elapsed_parts[2]), \".\")\r\n| extend secs = toint(sec_parts[0])\r\n| extend ms = toint(sec_parts[1])\r\n| extend elapsed_seconds = round(hours * 3600.0 + mins * 60.0 + secs + ms / 100.0, 2)\r\n| project timestamp, process_id, document, Step=stage, ElapsedSeconds=elapsed_seconds\r\n| order by process_id, timestamp asc",
260+
"size": 0,
261+
"title": "Per-Document Processing Time Breakdown",
262+
"timeContextFromParameter": "TimeRange",
263+
"queryType": 0,
264+
"resourceType": "microsoft.insights/components",
265+
"visualization": "table"
266+
},
267+
"name": "per-document-time-breakdown"
268+
},
220269
{
221270
"type": 1,
222271
"content": {

0 commit comments

Comments
 (0)