checks counts of traces with given name, status and attributes
(t *testing.T, spanRecorder *tracetest.SpanRecorder, expect []expectTrace, attrs []attribute.KeyValue)
| 809 | |
| 810 | // checks counts of traces with given name, status and attributes |
| 811 | func 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 | } |
no test coverage detected