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

Function pushTracesToInstance

modules/livestore/instance_search_test.go:665–690  ·  view source on GitHub ↗
(t *testing.T, i *instance, numTraces int)

Source from the content-addressed store, hash-verified

663}
664
665func pushTracesToInstance(t *testing.T, i *instance, numTraces int) ([]*tempopb.Trace, [][]byte) {
666 var ids [][]byte
667 var traces []*tempopb.Trace
668
669 for j := 0; j < numTraces; j++ {
670 id := make([]byte, 16)
671 _, err := crand.Read(id)
672 require.NoError(t, err)
673
674 testTrace := test.MakeTrace(10, id)
675 trace.SortTrace(testTrace)
676 traceBytes, err := testTrace.Marshal()
677 require.NoError(t, err)
678
679 // Create a push request for livestore
680 req := &tempopb.PushBytesRequest{
681 Traces: []tempopb.PreallocBytes{{Slice: traceBytes}},
682 Ids: [][]byte{id},
683 }
684 i.pushBytes(t.Context(), time.Now(), req)
685
686 ids = append(ids, id)
687 traces = append(traces, testTrace)
688 }
689 return traces, ids
690}
691
692// writes traces to the given instance along with search data. returns
693// ids expected to be returned from a tag search and strings expected to

Calls 7

MakeTraceFunction · 0.92
SortTraceFunction · 0.92
ReadMethod · 0.65
MarshalMethod · 0.65
pushBytesMethod · 0.65
ContextMethod · 0.65
NowMethod · 0.65

Tested by

no test coverage detected