DoSpansOnly is the same as Do but using the new span-only fetch layer.
(ctx context.Context, f SpansetFetcher, fetcherStart, fetcherEnd uint64, maxSeries int)
| 1384 | |
| 1385 | // DoSpansOnly is the same as Do but using the new span-only fetch layer. |
| 1386 | func (e *MetricsEvaluator) DoSpansOnly(ctx context.Context, f SpansetFetcher, fetcherStart, fetcherEnd uint64, maxSeries int) error { |
| 1387 | // Make a copy of the request so we can modify it. |
| 1388 | storageReq := *e.storageReq |
| 1389 | |
| 1390 | if fetcherStart > 0 && fetcherEnd > 0 && |
| 1391 | // exclude special case for a block with the same start and end |
| 1392 | fetcherStart != fetcherEnd { |
| 1393 | // Dynamically decide whether to use the trace-level timestamp columns |
| 1394 | // for filtering. |
| 1395 | overlap := timeRangeOverlap(e.start, e.end, fetcherStart, fetcherEnd) |
| 1396 | |
| 1397 | if overlap == 0.0 { |
| 1398 | // This shouldn't happen but might as well check. |
| 1399 | // No overlap == nothing to do |
| 1400 | return nil |
| 1401 | } |
| 1402 | |
| 1403 | // Our heuristic is if the overlap between the given fetcher (i.e. block) |
| 1404 | // and the request is less than X%, use them. Above X%, the cost of loading |
| 1405 | // them doesn't outweight the benefits. The default 20% was measured in |
| 1406 | // local benchmarking. |
| 1407 | if overlap < e.timeOverlapCutoff { |
| 1408 | storageReq.StartTimeUnixNanos = e.start |
| 1409 | storageReq.EndTimeUnixNanos = e.end // Should this be exclusive? |
| 1410 | } |
| 1411 | } |
| 1412 | |
| 1413 | fetch, err := f.FetchSpans(ctx, storageReq) |
| 1414 | if err != nil { |
| 1415 | return err |
| 1416 | } |
| 1417 | |
| 1418 | defer fetch.Results.Close() |
| 1419 | |
| 1420 | for { |
| 1421 | done, err := func() (done bool, err error) { |
| 1422 | s, err := fetch.Results.Next(ctx) |
| 1423 | if err != nil { |
| 1424 | return true, err |
| 1425 | } |
| 1426 | if s == nil { |
| 1427 | return true, nil |
| 1428 | } |
| 1429 | |
| 1430 | // Acquire lock while doing engine work. It is |
| 1431 | // not locked above while doing storage work. |
| 1432 | // TODO(mdisibio): Removed batching so that the mutex lock is not held during |
| 1433 | // storage work and allows the secondPass callback to be called. However this |
| 1434 | // represents ~20% performance loss, so we need to re-add batching. |
| 1435 | e.mtx.Lock() |
| 1436 | defer e.mtx.Unlock() |
| 1437 | |
| 1438 | if e.checkTime { |
| 1439 | st := s.StartTimeUnixNanos() |
| 1440 | if st <= e.start || st > e.end { |
| 1441 | return false, nil |
| 1442 | } |
| 1443 | } |
no test coverage detected