You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix: rewrite processing time queries to use customEvents timestamps
The trace-based queries weren't working because Python Azure Monitor SDK
stores log templates and args separately. New approach:
- Step Completion Time: uses LLM_Agent_Token_Usage event timestamps to
compute time from doc start to each step's completion
- OpenAI API Call Durations: uses dependencies table for HTTP call times
- Per-Document Step Timeline: shows when each step completed per document
- Total Processing Time: first-to-last step duration per document
All queries now use customEvents/dependencies tables which reliably
capture data from both ContentProcessor and ContentProcessorWorkflow.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
"title": "Total Document Processing Time (End-to-End)",
245
+
"query": "dependencies\r\n| where timestamp > ago(7d)\r\n| where target has \"openai\" or name has \"chat\"or type == \"HTTP\"or name has \"openai\"\r\n| where success == true\r\n| extend durationSeconds = round(duration / 1000.0, 2)\r\n| summarize\r\nTotalCalls = count(),\r\n AvgSeconds = round(avg(durationSeconds), 2),\r\n P50Seconds = round(percentile(durationSeconds, 50), 2),\r\n P90Seconds = round(percentile(durationSeconds, 90), 2),\r\nMaxSeconds = round(max(durationSeconds), 2)\r\nby OperationName = name\r\n| order by TotalCalls desc\r\n| take 10",
246
+
"size": 0,
247
+
"title": "OpenAI API Call Durations",
248
248
"timeContextFromParameter": "TimeRange",
249
249
"queryType": 0,
250
250
"resourceType": "microsoft.insights/components",
251
251
"visualization": "table"
252
252
},
253
-
"name": "total-processing-time"
253
+
"name": "openai-call-durations"
254
254
},
255
255
{
256
256
"type": 3,
257
257
"content": {
258
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",
259
+
"query": "customEvents\r\n| where name == 'LLM_Agent_Token_Usage'\r\n| where timestamp > ago(7d)\r\n| extend agent = tostring(customDimensions['agent_name'])\r\n| extend process_id = tostring(customDimensions['process_id'])\r\n| join kind=inner (\r\n customEvents\r\n | where name == 'LLM_Agent_Token_Usage'\r\n | where timestamp > ago(7d)\r\n| extend process_id = tostring(customDimensions['process_id'])\r\n | summarize DocStartTime = min(timestamp) by process_id\r\n) on process_id\r\n| extend StepCompletedAt = round(datetime_diff('millisecond', timestamp, DocStartTime) / 1000.0, 2)\r\n| project timestamp, process_id, Step=agent, StepCompletedAtSeconds=StepCompletedAt\r\n| order by process_id, timestamp asc",
260
260
"size": 0,
261
-
"title": "Per-Document Processing Time Breakdown",
0 commit comments