Repository navigation
feat: Add span and trace presence queries - #6079
simonswine wants to merge 1 commit into
Conversation
Add API bindings, v2 frontend routing and validation, backend execution, and report aggregation. Filter dictionary-encoded span and trace IDs before profile filters and late sample-value materialization; enforce combined selectors on the same sample.
89559dc to
244778a
Compare
| // span_selector = ["0000000000000001", "0000000000000002"] | ||
| // trace_id_selector = ["0000000000000000000000000000000a", | ||
| // "0000000000000000000000000000000b"] | ||
| // Matches (span 1, trace A), (span 1, trace B), (span 2, trace A), | ||
| // or (span 2, trace B), if those pairs occur on stored samples. |
There was a problem hiding this comment.
This part is not super intuitive to me, what is the use case for this API behavior?
|
|
||
| // SelectSpanPresence returns spans with stored profiling samples and their | ||
| // total sample values, grouped by trace ID, span ID, and profile type. | ||
| rpc SelectSpanPresence(SelectSpanPresenceRequest) returns (SelectSpanPresenceResponse) { |
There was a problem hiding this comment.
Nit, "presence" sounds like a yes/no signal but we return profile types and totals - what other names can we consider?
| x.maxPageRowNum = rn + pageNumRows | ||
| x.rowsFetched += pageNumRows | ||
| x.vit.reset(x.page, x.readSize) | ||
| x.rejected = x.predicate != nil && !x.predicate.KeepPage(x.page) |
There was a problem hiding this comment.
KeepPage only looks at page.Dictionary(), which is the column chunk's dictionary, so every page in a row group gets the same verdict. The probe still reads and decompresses every page that holds a candidate row, and rescans the whole dictionary each time. Is it easily possible to evaluate the predicate once per row group (on the first page) and then accept or reject the remaining candidates in that row group without further page reads?
| columns..., | ||
| ), | ||
| rows: rows, | ||
| columns: NewMultiColumnIterator(ctx, WrapWithRowNumber(numbers), o.batchSize, rowGroups, columns...), |
There was a problem hiding this comment.
For rows that pass the gate, the SpanID/TraceID pages the probe just read are read again here, since the multi-column iterator opens its own readers for the same columns.
With a per-row-group verdict (see my comment on readPage) the probe would only touch one page per row group, which would make this less relevant.
| decoded, _ := hex.DecodeString(id) | ||
| ids = append(ids, string(decoded)) | ||
| } | ||
| options = append(options, pq.WithPagePredicate(traceIndex, pq.NewStringInPredicate(ids))) |
There was a problem hiding this comment.
StringInPredicate.KeepPage keeps pages whose dictionary is empty, which is what an all-null TraceID chunk looks like. So for trace-only queries, row groups without any trace IDs are not skipped: every candidate row gets decoded and then dropped by the sample predicate.
spanPresencePredicate rejects those early. It's also a nested loop over dictionary entries x IDs; a map-based predicate like the span one would fix both.
Summary
Add an internal
SelectSpanPresenceAPI to identify spans with stored profiling samples within a time range and label selector, without resolving symbols.Supports querying by span IDs, trace IDs, or both. IDs are ORed within each selector; when both selectors are supplied, they must match the same sample.
Changes
Unimplemented.Testing
Adds unit and integration coverage for selector validation, routing, filtering, aggregation, and span-only, trace-only, combined, and nonmatching queries.
Tests not run as part of preparing this PR.