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

Method Combine

pkg/model/v2/object_decoder.go:56–97  ·  view source on GitHub ↗
(objs ...[]byte)

Source from the content-addressed store, hash-verified

54}
55
56func (d *ObjectDecoder) Combine(objs ...[]byte) ([]byte, error) {
57 var minStart, maxEnd uint32
58 minStart = math.MaxUint32
59
60 c := trace.NewCombiner(0, false)
61 for i, obj := range objs {
62 t, err := d.PrepareForRead(obj)
63 if err != nil {
64 return nil, fmt.Errorf("error unmarshaling trace: %w", err)
65 }
66
67 if len(obj) != 0 {
68 start, end, err := d.FastRange(obj)
69 if err != nil {
70 return nil, fmt.Errorf("error getting range: %w", err)
71 }
72
73 if start < minStart {
74 minStart = start
75 }
76 if end > maxEnd {
77 maxEnd = end
78 }
79 }
80
81 _, err = c.ConsumeWithFinal(t, i == len(objs)-1)
82 if err != nil {
83 return nil, fmt.Errorf("error combining trace: %w", err)
84 }
85 }
86
87 combinedTrace, _ := c.Result()
88
89 traceBytes := &tempopb.TraceBytes{}
90 bytes, err := proto.Marshal(combinedTrace)
91 if err != nil {
92 return nil, fmt.Errorf("error marshaling traceBytes: %w", err)
93 }
94 traceBytes.Traces = append(traceBytes.Traces, bytes)
95
96 return marshalWithStartEnd(traceBytes, minStart, maxEnd)
97}
98
99func (d *ObjectDecoder) FastRange(buff []byte) (uint32, uint32, error) {
100 _, start, end, err := stripStartEnd(buff)

Callers

nothing calls this directly

Implementers 2

ObjectDecoderpkg/model/v2/object_decoder.go
ObjectDecoderpkg/model/v1/object_decoder.go

Calls 7

PrepareForReadMethod · 0.95
FastRangeMethod · 0.95
ConsumeWithFinalMethod · 0.95
ResultMethod · 0.95
NewCombinerFunction · 0.92
marshalWithStartEndFunction · 0.85
MarshalMethod · 0.65

Tested by

no test coverage detected