MCPcopy Create free account
hub / github.com/coder/aibridge / verifyTraces

Function verifyTraces

internal/integrationtest/trace_test.go:812–831  ·  view source on GitHub ↗

checks counts of traces with given name, status and attributes

(t *testing.T, spanRecorder *tracetest.SpanRecorder, expect []expectTrace, attrs []attribute.KeyValue)

Source from the content-addressed store, hash-verified

810
811// checks counts of traces with given name, status and attributes
812func verifyTraces(t *testing.T, spanRecorder *tracetest.SpanRecorder, expect []expectTrace, attrs []attribute.KeyValue) {
813 spans := spanRecorder.Ended()
814
815 for _, e := range expect {
816 found := 0
817 for _, s := range spans {
818 if s.Name() != e.name || s.Status().Code != e.status {
819 continue
820 }
821 found++
822 want := slices.SortedFunc(slices.Values(attrs), cmpAttrKeyVal)
823 got := slices.SortedFunc(slices.Values(s.Attributes()), cmpAttrKeyVal)
824 require.Equal(t, want, got)
825 assert.Equalf(t, e.status, s.Status().Code, "unexpected status for trace naned: %v got: %v want: %v", e.name, s.Status().Code, e.status)
826 }
827 if found != e.count {
828 t.Errorf("found unexpected number of spans named: %v with status %v, got: %v want: %v", e.name, e.status, found, e.count)
829 }
830 }
831}

Callers 6

TestTraceAnthropicFunction · 0.85
TestTraceAnthropicErrFunction · 0.85
TestInjectedToolsTraceFunction · 0.85
TestTraceOpenAIFunction · 0.85
TestTraceOpenAIErrFunction · 0.85

Calls 1

NameMethod · 0.65

Tested by

no test coverage detected