MCPcopy Index your code
hub / github.com/coder/coder / verifyTraces

Function verifyTraces

aibridge/internal/integrationtest/trace_internal_test.go:811–830  ·  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

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

Callers 6

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

Calls 4

NameMethod · 0.65
StatusMethod · 0.45
EqualMethod · 0.45
ErrorfMethod · 0.45

Tested by

no test coverage detected