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

Method Next

tempodb/encoding/vparquet3/block_traceql.go:1143–1211  ·  view source on GitHub ↗

Next has to handle two different style results. First is an initial set of spans that does not have a callback spanset. These can be passed directly through. Second is a set of spans that have spansets imposed by the callback (i.e. for grouping) these must be regrouped into the callback spansets

()

Source from the content-addressed store, hash-verified

1141// Second is a set of spans that have spansets imposed by the callback (i.e. for grouping)
1142// these must be regrouped into the callback spansets
1143func (i *rebatchIterator) Next() (*parquetquery.IteratorResult, error) {
1144 for {
1145 // see if we have a queue
1146 res := i.resultFromNextSpans()
1147 if res != nil {
1148 return res, nil
1149 }
1150
1151 // check the iterator for anything
1152 res, err := i.iter.Next()
1153 if err != nil {
1154 return nil, err
1155 }
1156 if res == nil {
1157 return nil, nil
1158 }
1159
1160 // get the spanset and see if we should pass it through or buffer for rebatching
1161 iface := res.OtherValueFromKey(otherEntrySpansetKey)
1162 if iface == nil {
1163 return nil, fmt.Errorf("engine assumption broken: spanset not found in other entries in rebatch")
1164 }
1165 ss, ok := iface.(*traceql.Spanset)
1166 if !ok {
1167 return nil, fmt.Errorf("engine assumption broken: spanset is not of type *traceql.Spanset in rebatch")
1168 }
1169
1170 // if this has no call back spanset just pass it on
1171 if len(ss.Spans) > 0 && ss.Spans[0].(*span).cbSpanset == nil {
1172 return res, nil
1173 }
1174
1175 // dump all spans into our buffer
1176 for _, s := range ss.Spans {
1177 sp := s.(*span)
1178 if !sp.cbSpansetFinal {
1179 continue
1180 }
1181
1182 // copy trace level data from the current iteration spanset into the rebatch spanset. only do this if
1183 // we don't have current data
1184 if sp.cbSpanset.DurationNanos == 0 {
1185 sp.cbSpanset.DurationNanos = ss.DurationNanos
1186 }
1187 if len(sp.cbSpanset.TraceID) == 0 {
1188 sp.cbSpanset.TraceID = ss.TraceID
1189 }
1190 if len(sp.cbSpanset.RootSpanName) == 0 {
1191 sp.cbSpanset.RootSpanName = ss.RootSpanName
1192 }
1193 if len(sp.cbSpanset.RootServiceName) == 0 {
1194 sp.cbSpanset.RootServiceName = ss.RootServiceName
1195 }
1196 if sp.cbSpanset.StartTimeUnixNanos == 0 {
1197 sp.cbSpanset.StartTimeUnixNanos = ss.StartTimeUnixNanos
1198 }
1199
1200 i.nextSpans = append(i.nextSpans, sp)

Callers

nothing calls this directly

Calls 4

resultFromNextSpansMethod · 0.95
OtherValueFromKeyMethod · 0.80
putSpansetFunction · 0.70
NextMethod · 0.65

Tested by

no test coverage detected