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
()
| 1305 | // Second is a set of spans that have spansets imposed by the callback (i.e. for grouping) |
| 1306 | // these must be regrouped into the callback spansets |
| 1307 | func (i *rebatchIterator) Next() (*parquetquery.IteratorResult, error) { |
| 1308 | for { |
| 1309 | // see if we have a queue |
| 1310 | res := i.resultFromNextSpans() |
| 1311 | if res != nil { |
| 1312 | return res, nil |
| 1313 | } |
| 1314 | |
| 1315 | // check the iterator for anything |
| 1316 | res, err := i.iter.Next() |
| 1317 | if err != nil { |
| 1318 | return nil, err |
| 1319 | } |
| 1320 | if res == nil { |
| 1321 | return nil, nil |
| 1322 | } |
| 1323 | |
| 1324 | // get the spanset and see if we should pass it through or buffer for rebatching |
| 1325 | iface := res.OtherValueFromKey(otherEntrySpansetKey) |
| 1326 | if iface == nil { |
| 1327 | return nil, fmt.Errorf("engine assumption broken: spanset not found in other entries in rebatch") |
| 1328 | } |
| 1329 | ss, ok := iface.(*traceql.Spanset) |
| 1330 | if !ok { |
| 1331 | return nil, fmt.Errorf("engine assumption broken: spanset is not of type *traceql.Spanset in rebatch") |
| 1332 | } |
| 1333 | |
| 1334 | // if this has no call back spanset just pass it on |
| 1335 | if len(ss.Spans) > 0 && ss.Spans[0].(*span).cbSpanset == nil { |
| 1336 | return res, nil |
| 1337 | } |
| 1338 | |
| 1339 | // dump all spans into our buffer |
| 1340 | for _, s := range ss.Spans { |
| 1341 | sp := s.(*span) |
| 1342 | if !sp.cbSpansetFinal { |
| 1343 | continue |
| 1344 | } |
| 1345 | |
| 1346 | // copy trace level data from the current iteration spanset into the rebatch spanset. only do this if |
| 1347 | // we don't have current data |
| 1348 | if sp.cbSpanset.DurationNanos == 0 { |
| 1349 | sp.cbSpanset.DurationNanos = ss.DurationNanos |
| 1350 | } |
| 1351 | if len(sp.cbSpanset.TraceID) == 0 { |
| 1352 | sp.cbSpanset.TraceID = ss.TraceID |
| 1353 | } |
| 1354 | if len(sp.cbSpanset.RootSpanName) == 0 { |
| 1355 | sp.cbSpanset.RootSpanName = ss.RootSpanName |
| 1356 | } |
| 1357 | if len(sp.cbSpanset.RootServiceName) == 0 { |
| 1358 | sp.cbSpanset.RootServiceName = ss.RootServiceName |
| 1359 | } |
| 1360 | if sp.cbSpanset.StartTimeUnixNanos == 0 { |
| 1361 | sp.cbSpanset.StartTimeUnixNanos = ss.StartTimeUnixNanos |
| 1362 | } |
| 1363 | if len(sp.cbSpanset.ServiceStats) == 0 { |
| 1364 | // If this spanset was created by a GroupOperation, the ServiceStats map is nil and must be allocated first |
nothing calls this directly
no test coverage detected