(t *testing.T)
| 54 | } |
| 55 | |
| 56 | func TestTraceBuilder_BuildSpanTree(t *testing.T) { |
| 57 | tb := NewTraceBuilder() |
| 58 | |
| 59 | now := time.Now() |
| 60 | events := []types.AgentEventEnvelope{ |
| 61 | { |
| 62 | Cursor: 1, |
| 63 | Bookmark: types.Bookmark{ |
| 64 | Cursor: 1, |
| 65 | Timestamp: now.UnixMilli(), |
| 66 | }, |
| 67 | Event: types.MonitorStepCompleteEvent{ |
| 68 | Step: 1, |
| 69 | DurationMs: 500, |
| 70 | }, |
| 71 | }, |
| 72 | { |
| 73 | Cursor: 2, |
| 74 | Bookmark: types.Bookmark{ |
| 75 | Cursor: 2, |
| 76 | Timestamp: now.Add(200 * time.Millisecond).UnixMilli(), |
| 77 | }, |
| 78 | Event: types.MonitorToolExecutedEvent{ |
| 79 | Call: types.ToolCallSnapshot{ |
| 80 | ID: "tool-1", |
| 81 | Name: "search", |
| 82 | State: types.ToolCallStateCompleted, |
| 83 | }, |
| 84 | }, |
| 85 | }, |
| 86 | { |
| 87 | Cursor: 3, |
| 88 | Bookmark: types.Bookmark{ |
| 89 | Cursor: 3, |
| 90 | Timestamp: now.Add(500 * time.Millisecond).UnixMilli(), |
| 91 | }, |
| 92 | Event: types.MonitorTokenUsageEvent{ |
| 93 | InputTokens: 1000, |
| 94 | OutputTokens: 500, |
| 95 | TotalTokens: 1500, |
| 96 | }, |
| 97 | }, |
| 98 | } |
| 99 | |
| 100 | root := tb.buildSpanTree(events) |
| 101 | |
| 102 | if root == nil { |
| 103 | t.Fatal("buildSpanTree() returned nil") |
| 104 | } |
| 105 | |
| 106 | if root.Type != TraceNodeTypeAgent { |
| 107 | t.Errorf("buildSpanTree() root type = %v, want agent", root.Type) |
| 108 | } |
| 109 | |
| 110 | if root.Name != "agent.run" { |
| 111 | t.Errorf("buildSpanTree() root name = %v, want agent.run", root.Name) |
| 112 | } |
| 113 |
nothing calls this directly
no test coverage detected