Skip to content
Open
Show file tree
Hide file tree
Changes from 36 commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
e1708ea
refactor(traceql): build the parser once and pin the grammar with AST…
44YHC Oct 12, 2026
f5ea8c4
feat(sql_select): render WITH RECURSIVE CTEs and comma-separated SETT…
44YHC Oct 12, 2026
a48324e
refactor(traceql): take search, autocomplete and metrics time bounds …
44YHC Oct 12, 2026
00130d2
feat(dbversion): add the 24.9 structural-queries capability
44YHC Oct 12, 2026
70ebff5
refactor(traceql): resolve version info for search, tags v2, values v…
44YHC Oct 12, 2026
9c831f9
refactor(traceql): name the closed span-start bound and resolve metri…
44YHC Oct 12, 2026
98f0b85
fix(traceql): require an operator between chained spanset operands
44YHC Oct 12, 2026
23587d5
refactor(traceql): plan search, autocomplete and metrics from a lower…
44YHC Oct 12, 2026
20b543c
refactor(traceql): lower spanset operators with Tempo precedence and …
44YHC Oct 12, 2026
4807b0f
fix(traceql): evaluate search over uncapped span sets and cap spanset…
44YHC Oct 12, 2026
f8e16c3
build(e2e): pin the gigapipe-tests ref and parametrise the ClickHouse…
44YHC Oct 12, 2026
df97b8b
fix(traceql): order the attribute-less trace pre-pick like the search…
44YHC Oct 12, 2026
32303c2
fix(traceql): evaluate && and || across selectors per trace
44YHC Oct 12, 2026
5bfce0a
refactor(traceql): fold the spanset operator tree in one place
44YHC Oct 12, 2026
2584057
feat(traceql): evaluate one-hop structural operators on the span tree
44YHC Oct 12, 2026
de7c4c3
refactor(traceql): name misspelt operators, key one-hop spans by type…
44YHC Oct 12, 2026
39a5657
feat(traceql): evaluate transitive structural operators by pointer ju…
44YHC Oct 12, 2026
5ef4922
refactor(traceql): share the pointer-jump step and the result conditi…
44YHC Oct 12, 2026
e03fad4
feat(traceql): count metrics over the search result spans
44YHC Oct 12, 2026
e298de2
refactor(traceql): read exemplars from one span and keep metrics plan…
44YHC Oct 12, 2026
33ac741
feat(traceql): suggest autocomplete tags and values from the search r…
44YHC Oct 12, 2026
523dfa7
refactor(traceql): share autocomplete planning between tags and values
44YHC Oct 12, 2026
8d01aac
feat(traceql): parse Tempo pipelines and filter spansets by script-le…
44YHC Oct 12, 2026
a166a4d
refactor(traceql): name spanset attribute types and read unscoped agg…
44YHC Oct 12, 2026
1b576e0
feat(traceql): evaluate Tempo field expressions in spanset filters an…
44YHC Oct 12, 2026
c19cb29
refactor(traceql): type negations and attribute arithmetic statically…
44YHC Oct 12, 2026
e5c5209
refactor(traceql): name the arithmetic result type helper
44YHC Oct 12, 2026
aba8a2d
feat(traceql): narrow later pipeline stages to the spans of the stage…
44YHC Oct 13, 2026
7ab38ad
refactor(traceql): name the narrowed stage's own attributes and share…
44YHC Oct 13, 2026
c566d5c
feat(traceql): group pipeline spansets with by() and merge them with …
44YHC Oct 13, 2026
34a1ecd
refactor(traceql): compute by() pivot keys once and semi-join the piv…
44YHC Oct 13, 2026
0696d34
feat(traceql): add select() stages and the sample and exemplars hints
44YHC Oct 13, 2026
d4abd43
refactor(traceql): build the selected-value columns up front and reje…
44YHC Oct 13, 2026
c85816a
docs(traceql): document structural operators, pipelines and the relea…
44YHC Oct 13, 2026
52c8468
docs(traceql): cover trailing-operator errors, nil in && and ||, sum …
44YHC Oct 13, 2026
a3a6b1b
docs(traceql): scope the autocomplete time range and tighten Tempo-di…
44YHC Oct 13, 2026
8ba62d4
Merge remote-tracking branch 'upstream/master' into feat/traceql-stru…
44YHC Nov 5, 2026
ceb2cb1
test(traceql): replace TestStringDanglingAndOr with TestParseRejectsD…
44YHC Nov 6, 2026
3795840
test(traceql): replace #1040's metrics join tests with a planner inva…
44YHC Nov 6, 2026
03708ca
test(traceql): add ClickHouse behaviour-test harness
44YHC Nov 6, 2026
ecfae8f
fix(traceql): query the requested range in every complexity portion
44YHC Nov 6, 2026
80180f0
fix(traceql): skip unresolved traces instead of failing the query
44YHC Nov 6, 2026
16e9402
docs(traceql): move TraceQL docs into configuration and README
44YHC Nov 6, 2026
5cb301a
feat(traceql): warn about unresolved traces after the response
44YHC Nov 6, 2026
23d18db
fix(traceql): run the unresolved-trace probe for readonly=1 readers
44YHC Nov 6, 2026
873ec89
fix(reader): pass the health check for readonly=1 readers over HTTP
44YHC Nov 6, 2026
657f58d
feat(traceql): add a date bound on a span's stored date in any time zone
44YHC Nov 7, 2026
7f385c8
fix(traceql): bound search and autocomplete dates in UTC, a day eithe…
44YHC Nov 7, 2026
1c9a120
fix(tempo): bound by-label, compare() and tag search dates in UTC, a …
44YHC Nov 7, 2026
0e42e5d
test(traceql): pin traces reads against a reader zone and another zon…
44YHC Nov 7, 2026
57d4a1f
Merge upstream/master into feat/traceql-structural-ops
44YHC Nov 9, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions .github/workflows/node-clickhouse-cluster.js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,17 @@ jobs:
- name: Rollback Deployment
if: failure() && steps.execution.outcome == 'failure'
run: npm test -- -u

# The TraceQL grid suite on ClickHouse 24.9, the oldest version structural queries support.
traceql-clickhouse-24-9:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Check out the e2e test suite
run: make e2e-deps
- name: Install Compose
uses: ndeloof/install-compose-action@v0.0.1
with:
version: v2.1.0
legacy: true
- run: make e2e-ci E2E_CLICKHOUSE_IMAGE=clickhouse/clickhouse-server:24.9 E2E_TEST_ARGS=--testNamePattern=grid.traceql
12 changes: 9 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ docker-compose ?= docker-compose
# rather than duplicating the checkout.
E2E_TESTS_REPO ?= https://github.com/metrico/gigapipe-tests.git
E2E_TESTS_DIR ?= ./deps/gigapipe-tests
# Branch, tag or commit of the suite to run; a PR may pin its own tests branch.
E2E_TESTS_REF ?= traceql-structural-ops
# ClickHouse image of the e2e stack; the TraceQL suite also runs on the 24.9 floor.
export E2E_CLICKHOUSE_IMAGE ?= clickhouse/clickhouse-server:25.3
# Extra jest arguments, e.g. --testNamePattern=grid.traceql to run one suite.
E2E_TEST_ARGS ?=

# Enable the recording-rules ruler for e2e: exported so both the gigapipe
# server (via compose interpolation) and the test runner see the same value.
Expand All @@ -15,7 +21,7 @@ docker:

e2e-deps:
if [ ! -d $(E2E_TESTS_DIR) ]; then git clone $(E2E_TESTS_REPO) $(E2E_TESTS_DIR); fi
cd $(E2E_TESTS_DIR) && git pull && git checkout main && git pull;
cd $(E2E_TESTS_DIR) && git fetch origin $(E2E_TESTS_REF) && git checkout --detach FETCH_HEAD

e2e-build:
docker build -f scripts/deploy/docker/Dockerfile -t gigapipe .
Expand All @@ -25,7 +31,7 @@ e2e-test:
docker rm -f qryn-go-test && \
sleep 60 && \
docker run \
-v `pwd`/$(E2E_TESTS_DIR):/deps/e2e \
-v $(abspath $(E2E_TESTS_DIR)):/deps/e2e \
--network=e2e_common \
--name=qryn-go-test \
-e INTEGRATION_E2E=1\
Expand All @@ -35,7 +41,7 @@ e2e-test:
-e QRYN_RULER_ENABLED \
-e OTEL_COLL_URL="http://a:b@e2e.aio:9080" \
node:18-alpine \
sh -c 'cd /deps/e2e && npm install && npm test -- --forceExit'
sh -c 'cd /deps/e2e && npm install && npm test -- --forceExit $(E2E_TEST_ARGS)'

e2e-cleanup:
$(docker-compose) -f ./scripts/test/e2e/docker-compose.yml down
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@

- [Configuration & Docker](docs/configuration.md) — environment variables, Docker quickstart, cross-cluster setup
- [Table Ordering](docs/table-ordering.md) — ClickHouse sort keys, `ADVANCED_SAMPLES_ORDERING`, changing the ordering of an existing deployment
- [TraceQL](docs/traceql.md) — structural operators, pipelines, field expressions, differences from Tempo
- [Release Notes](docs/release-notes.md) — behaviour changes to note before upgrading
- [Profiling API](docs/profiling-api.md) — profiling endpoints, DOT format export, Graphviz visualization
- [OTLP Profiles Ingestion](docs/otlp-profiles.md) — OpenTelemetry profiles signal ingestion via `/v1development/profiles`
- [OTLP Metrics Ingestion](docs/otlp-metrics.md) — OpenTelemetry metrics signal ingestion via `/v1/metrics` (protobuf + JSON)
Expand Down
4 changes: 4 additions & 0 deletions cmd/gigapipe/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"github.com/metrico/cloki-config/config"
"github.com/metrico/qryn/v5/ctrl"
"github.com/metrico/qryn/v5/reader"
"github.com/metrico/qryn/v5/reader/traceql/traceqlconfig"
"github.com/metrico/qryn/v5/reader/utils/logger"
"github.com/metrico/qryn/v5/reader/utils/middleware"
"github.com/metrico/qryn/v5/reader/utils/tables"
Expand Down Expand Up @@ -293,6 +294,9 @@ func main() {

func start() {
distconfig.Init()
if err := traceqlconfig.Init(); err != nil {
panic(err)
}
tables.InitDistTableNames()
var configPaths []string
if _, err := os.Stat(*appFlags.ConfigPath); err == nil {
Expand Down
6 changes: 6 additions & 0 deletions docs/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,12 @@ Variables that are not Gigapipe-specific — `CLICKHOUSE_*`, `PORT`, `HOST`,
- **`LOG_PATTERN_SIMILARITY`** - Similarity threshold for pattern grouping, range 0-1 (default: `0.7`). Higher values require more similarity.
- **`LOG_PATTERN_READ_LIMIT`** - Maximum number of log patterns to read per request (default: `300`)

## TraceQL

- **`GIGAPIPE_TRACEQL_ANCESTRY_ROUNDS`** - Number of rounds used to resolve span ancestry for TraceQL structural operators, an integer from `1` to `32` (default: `20`). With `R` rounds, traces up to `2^R` spans deep resolve; deeper or cyclic traces make the query fail. Each round adds work to every query using `>>` or `<<`. An invalid value stops Gigapipe at start-up. See [TraceQL](traceql.md#depth-limit).

Structural TraceQL queries need ClickHouse 24.9 or newer; see [TraceQL](traceql.md#requirements).

## Recording Rules (Ruler)

The ruler evaluates LogQL and PromQL recording rules on a schedule and writes
Expand Down
169 changes: 169 additions & 0 deletions docs/release-notes.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,169 @@
# Release Notes

Behaviour changes worth reading before an upgrade. The GitHub release page
lists every merged change.

## Unreleased

### TraceQL: structural operators and the Tempo pipeline

TraceQL now accepts Tempo's structural grammar and evaluates it against the
real span tree, in search, metrics and autocomplete alike. See
[TraceQL](traceql.md) for the full semantics.

#### New

- All 15 structural operators: `>`, `>>`, `<`, `<<`, `~`, their `!` variants
(`!>`, `!>>`, `!<`, `!<<`, `!~`) and their `&` variants (`&>`, `&>>`, `&<`,
`&<<`, `&~`).
- Pipelines: scalar filters (`count`, `avg`, `min`, `max`, `sum`) over the
whole preceding expression, `by()`, `coalesce()`, `select()`, stages at any
position with narrowing (`{A} | {B} > {C}`), and parenthesised pipelines as
operands.
- Field expressions in spanset filters and aggregate arguments: attribute
vs attribute (`{ .a = .b }`), arithmetic (`+ - * / % ^`), unary `-` and `!`,
and `= nil` / `!= nil`.
- Search spansets carry aggregate values and `by()` keys as spanset
attributes; `by()` groups are returned as separate spansets.
- The `spss` search parameter.
- The `sample` and `exemplars` hints for TraceQL metrics.
- Tag and value autocomplete suggest only from the spans the query returns,
and accept queries with `&&`, `||` and structural operators.

#### Results that change

These queries returned wrong results before and now return exact ones.
Saved dashboards and alerts that use them will see different numbers.

- **`&>>`, `!>>`, `~`** were evaluated as `&&` and never looked at the span
tree. They now evaluate parent, ancestor and sibling relations.
- **`&&` between selectors** matched only when a single span satisfied both
sides and both sides' newest timestamps were equal. `{A} && {B}` now
matches a trace when both sides have spans in it and returns the spans of
both sides. **`||`** returns the spans of either side, each once. Chains of
three or more operands no longer drop operands.
- **Metrics** flattened every selector's filters into one AND list, ignoring
`||` and structural operators, so `({A} >> {B}) | rate()` counted spans
matching A and B at once. A metrics query now counts exactly the spans a
search for the same expression returns.
- **Scalar filters** (`| count() > 2`) applied to the last selector only.
They now apply to the whole preceding expression's result spans, and a
scalar filter before a metrics function decides which traces contribute.
- **Span cap.** Each selector was capped at 100 spans before operators were
evaluated, which dropped true matches in large traces. Operands are now
uncapped. Search lists **3 spans per spanset by default** (was up to 100);
set `spss` for more. `matched` reports the true number of matched spans.
- **Time range.** TraceQL search, metrics and autocomplete with a filtering
query now count spans that start in **`(from, to]`**: a span starting
exactly at `from` is excluded, one starting exactly at `to` is included.
Search and metrics previously used `[from, to)`.
- **`metrics by (...)` labels.** `by (span.x, name)` could attach values to
the wrong label names; labels now match their values.
- **Filters mixing intrinsics and attributes.** Filters combining `status`,
`kind`, `rootName`, `rootServiceName` or `duration` with attribute terms
(for example `{ status = error && .a = 1 }` or
`{ duration > 1s || .a = 1 }`) could miss matching spans; they now return
every match.
- **`&&` and `||` inside `{...}`** are now one left-associative level, as in
Tempo. `{ .a = 1 && .b = 2 || .c = 3 }` was read as
`.a = 1 && (.b = 2 || .c = 3)`; it is now `(.a = 1 && .b = 2) || .c = 3`.
Add parentheses to keep the old reading.
- **`{ .a = .b }`** compares two attributes; `.b` used to be the string
`".b"`.
- **`({A} | count() > 1)`** now returns the `count()` spanset attribute.

#### Queries that now fail

- `<<&` and `<<~` are parse errors naming Tempo's spelling (`&<<`, `!<<`).
- Two spansets with no operator between them (`{A} {B}`) and a trailing
operator (`{A} &&`) are parse errors.
- `status` and `kind` compare only against their own keywords:
`status = "error"` is a type error, write `status = error`.
- A structural query on ClickHouse older than 24.9 fails with
`TraceQL structural operators need ClickHouse 24.9 or newer`.
- A structural query meeting a trace deeper than the round limit, or whose
parent links form a cycle, fails instead of returning partial results.

#### Other changes

- Clustered deployments: TraceQL search reads the Distributed tables, so it
sees traces on every shard. It used to read only the shard-local tables of
the node it ran on.
- TraceQL search reads the whole (limit-bounded) result before responding, so
errors raised during the query reach the client.
- `{}` can be an operand of `&&`, `||` and structural operators.
- Value autocomplete (`/api/v2/search/tag/{tag}/values`) accepts scoped tags
(`span.x`, `resource.x`, `.x`), as Grafana sends them, and without a query
lists the tag's values. Tag autocomplete accepts a lone `{}` query.
- Autocomplete for costly queries stays filtered by the query instead of
falling back to every tag.

#### For operators

- **ClickHouse 24.9 or newer** is required for structural queries. Other
TraceQL queries are unaffected. Structural queries run with
`enable_analyzer=1`.
- **No migration.** There is no schema change, writer change or backfill;
upgrading the reader is enough.
- **New setting `GIGAPIPE_TRACEQL_ANCESTRY_ROUNDS`** (1 to 32, default 20).
Traces up to `2^R` spans deep resolve. See
[Configuration](configuration.md#traceql).
- **Planner plugins.**
- A `TracesDataPlugin` receives rows of `trace_id`, `span_id` (all listed
span ids) and `spansets` (an array of group key, span ids, `matched` and
attributes), and must emit 16 columns: the 8 existing ones, then
`spanset_span_ids`, `matched`, `attr_names`, `attr_types`, `attr_values`,
`attr_texts` (one element per spanset), `span_attr_keys` and
`span_attr_vals` (one element per listed span). Plugins don't receive the
`select()` fields, so `select()` returns no values through a plugin.
- An `InitIndexPlannerPlugin`'s select must expose unqualified `trace_id`
and `span_id` columns.
- **Query cost.** Structural operators read the parent links of their
candidate traces from the traces table with no time bound, so every daily
partition in retention is looked up. `>>` and `<<` then run every configured
round.

#### Deliberate differences from Tempo

gigapipe returns what Tempo returns except for these, also listed in
[TraceQL](traceql.md#differences-from-tempo):

- Operands must start in the query range; Tempo draws operands from every
span of an overlapping trace.
- Tempo's rule that returns nothing for a trace in which three or more spans
share a span ID is not reproduced.
- The grouped-spanset error is static: it also fires where every trace has a
single group, and on spanset operators after `by()`
(`{A} | by(.x) | {B} > {C}`), which Tempo evaluates per group.
- `by()` groups are ordered by key; Tempo's order is random.
- Attribute `by()` keys are returned as strings; spans without a `status` or
`kind` attribute form the nil group, where Tempo reports `unset`.
- In aggregate arguments, a span where the expression is nil (`.a + nil`) is
skipped; Tempo counts it.
- `!` works inside spanset filters; Tempo returns nothing for them.
- `!x` on a non-boolean is false, where Tempo can fail.
- `x = nil` ignores scope (`span.a`, `resource.a` and `.a` all test `a`) and
matches only spans without `a`.
- Int, float and duration aren't distinguished in storage: `.a = "200"` and
`.a = 200` both match a stored `200`.
- `int ^ int` is evaluated as written; Tempo swaps base and exponent.
- Integer division and modulo by zero are nil, not an error.
- `&&` and `||` treat a nil operand as false and evaluate the other side;
Tempo usually makes the whole operation false.
- Typing is stricter: non-boolean filters and non-numeric aggregate
arguments built only from attributes are rejected before the query runs.
- Literal arithmetic in scalar filters isn't folded (`count() > 1 + 2` is
rejected); `count() > count()` reports Tempo's right-hand-side error text.
- `(count() > 2) && {B}` is a parse error.
- `sum()` over a mix of ints and floats adds every value as a float; Tempo
drops values whose type differs from the first value's.
- A bare word as an aggregate argument (`avg(spanN)`) reads that attribute;
Tempo rejects it.
- `select()` values are strings, and attributes named `name`, `status` or
`kind` share storage with the intrinsics of the same name.
- `sample` is a hash of the trace or span id; Tempo keeps one item in N with
a counter.
- Sampled metrics values are returned unscaled; Tempo scales them up by the
observed sampling ratio (except `min_over_time` and `max_over_time`).
- `exemplars=N` caps exemplars per series, spread over the buckets that have
one; Tempo applies the cap per query evaluator, not per series.
Loading
Loading