MCPcopy Create free account
hub / github.com/astercloud/aster / TestTraceBuilder_BuildFromEvents

Function TestTraceBuilder_BuildFromEvents

pkg/dashboard/trace_builder_test.go:10–54  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

8)
9
10func TestTraceBuilder_BuildFromEvents(t *testing.T) {
11 tb := NewTraceBuilder()
12
13 now := time.Now()
14 events := []types.AgentEventEnvelope{
15 {
16 Cursor: 1,
17 Bookmark: types.Bookmark{
18 Cursor: 1,
19 Timestamp: now.UnixMilli(),
20 },
21 Event: types.MonitorStepCompleteEvent{
22 Step: 1,
23 DurationMs: 100,
24 },
25 },
26 {
27 Cursor: 2,
28 Bookmark: types.Bookmark{
29 Cursor: 2,
30 Timestamp: now.Add(100 * time.Millisecond).UnixMilli(),
31 },
32 Event: types.MonitorTokenUsageEvent{
33 InputTokens: 1000,
34 OutputTokens: 500,
35 TotalTokens: 1500,
36 },
37 },
38 }
39
40 traces := tb.BuildFromEvents(events)
41
42 if len(traces) == 0 {
43 t.Fatal("BuildFromEvents() returned no traces")
44 }
45
46 trace := traces[0]
47 if trace.SpanCount == 0 {
48 t.Error("BuildFromEvents() trace has no spans")
49 }
50
51 if trace.TokenUsage.Total == 0 {
52 t.Error("BuildFromEvents() trace has no token usage")
53 }
54}
55
56func TestTraceBuilder_BuildSpanTree(t *testing.T) {
57 tb := NewTraceBuilder()

Callers

nothing calls this directly

Calls 4

BuildFromEventsMethod · 0.95
NewTraceBuilderFunction · 0.85
AddMethod · 0.65
ErrorMethod · 0.65

Tested by

no test coverage detected