MCPcopy
hub / github.com/grafana/tempo / SearchStreamAndAssertTrace

Function SearchStreamAndAssertTrace

integration/util/harness_api_reads.go:91–122  ·  view source on GitHub ↗

SearchStreamAndAssertTrace will search and assert that the trace is present in the streamed results. nolint: revive

(t *testing.T, ctx context.Context, client tempopb.StreamingQuerierClient, info *tempoUtil.TraceInfo, start, end int64)

Source from the content-addressed store, hash-verified

89// SearchStreamAndAssertTrace will search and assert that the trace is present in the streamed results.
90// nolint: revive
91func SearchStreamAndAssertTrace(t *testing.T, ctx context.Context, client tempopb.StreamingQuerierClient, info *tempoUtil.TraceInfo, start, end int64) {
92 expected, err := info.ConstructTraceFromEpoch()
93 require.NoError(t, err)
94
95 attr := tempoUtil.RandomAttrFromTrace(expected)
96 query := fmt.Sprintf(`{ .%s = "%s"}`, attr.GetKey(), attr.GetValue().GetStringValue())
97
98 // -- assert search
99 resp, err := client.Search(ctx, &tempopb.SearchRequest{
100 Query: query,
101 Start: uint32(start),
102 End: uint32(end),
103 })
104 require.NoError(t, err)
105
106 // drain the stream until everything is returned while watching for the trace in question
107 found := false
108 for {
109 resp, err := resp.Recv()
110 if resp != nil {
111 found = traceIDInResults(t, info.HexID(), resp)
112 if found {
113 break
114 }
115 }
116 if errors.Is(err, io.EOF) {
117 break
118 }
119 require.NoError(t, err)
120 }
121 require.True(t, found)
122}
123
124func traceIDInResults(t *testing.T, hexID string, resp *tempopb.SearchResponse) bool {
125 for _, s := range resp.Traces {

Callers

nothing calls this directly

Calls 8

traceIDInResultsFunction · 0.85
GetKeyMethod · 0.80
GetStringValueMethod · 0.80
HexIDMethod · 0.80
SearchMethod · 0.65
RecvMethod · 0.65
GetValueMethod · 0.45

Tested by

no test coverage detected