lib/traceql: intersect traces by trace_id for && between spansets
Closed
AL
3d ago+178+178+012345678901234567890123456789-19-19-01234567890123456789
Fixes #324
Root Cause
parseFilterAnd previously emitted the same single-row a and b LogsQL expression both inside {...} (same-span conjunction) and between spansets {...} && {...}. For queries like { span.a = "x" } && { span.b = "y" }, LogsQL required a single span to carry both attributes, returning no traces when a and b sit on different spans of the same trace.
Fix
- Track
inSpancontext inlib/traceql/parser.goso&&inside{...}stays a single-spanandfilter, while&&between spansets is markedisSpanset: true. - In
lib/traceql/filter_and.go,spansetString()skips wildcard (*) operands and translates multi-spanset intersections to((s0) or (s1) ...) and trace_id:in({resource_attr:service.name!=""} AND (s0) | uniq by (trace_id)) and ...so matching traces return all spans matching any operand while requiring every operand to match at least one span in the trace. - Updated
TestParseQueryexpectations and addedTestSpansetAndQueryExecutionagainstlogstorage.Storagecovering parent/child spanset&&, 3-way&&, nested&&/||, stream-field spansets, and step-2FilterString()retrieval.
Testing
go test -v ./lib/traceql/...— PASSgo test ./lib/... ./app/...— PASSgo vet ./lib/traceql/...— PASS