Skip to content

feat(traceql): parse Tempo durations and quoted attribute names - #1087

Open
44YHC wants to merge 6 commits into
feat/traceql-dot-floatfrom
feat/traceql-literals
Open

44YHC wants to merge 6 commits into
feat/traceql-dot-floatfrom
feat/traceql-literals

Conversation

@44YHC

@44YHC 44YHC commented Nov 9, 2026 •

Copy link
Copy Markdown
Collaborator

Stacked on #1086; merge that first. The neighbouring literal gaps found while fixing .95 for #1034's review. The rule is to match Tempo v3.1.0 exactly: accept what it accepts and reject what it rejects, at parse time.

Summary

  • Durations. One Duration token before Float/Integer: a number followed by the units ns us µs ms s m h d w y, repeatable. 1h30m, 1d, 1w and 1y parse. 1e3s, 1.5d and 1h30 fail at parse time with the literal named. Planning reuses the parsed value.
  • Quoted attribute names. After a dot scope Gigapipe already parses, a name can mix bare runes and "…" parts, with Tempo's escapes (\", \\). ."5xx" and span."http status" read those attributes, and ."foo" behaves exactly like .foo, in filters, by(), select(), metrics, compare() and autocomplete. Colon intrinsics can't be quoted, and no new scopes are added. An unclosed quote or a bad escape fails at parse time, worded like Tempo's.
  • Names in SQL. Every attribute name reaches SQL as an escaped string literal. A test sends hostile quoted names through search, metrics, compare(), tags, values and the unresolved-trace probe.

Breaking changes

Queries that now fail

  • 5 s, .5 s and 5. s (a number, a space, a unit) were accepted and are now syntax errors, as in Tempo.
  • A number followed directly by a letter that isn't a duration unit (1x) is a syntax error.

Results that change

  • by (.foo) labels change: the series were all one group with an empty value, because the pivot read key .foo, and they split by the attribute's values with this PR. Series labels and by()/aggregate result names hold the plain decoded name: by (."http status") labels .http status. This differs from Tempo, which quotes names that need quotes (."http status").

Upgrade notes

None. No setting, schema or plugin change.

Evidence

  • Parser tests pin accepted and rejected durations and quoted names against Tempo v3.1.0's behaviour, including the error wording.
  • Plan tests pin quoted names on every plan as one string literal.
  • go test ./... passes. The full e2e suite and grid.traceql pass on the full stack tip, which includes this branch.

Merge Danger

Door: two-way. Parser and plan rendering only.

Blast Radius: TraceQL parsing, and by() labels for dot-scoped attributes.

Known differences, not changed here: /api/v2/search/tag/."foo"/values keeps the quotes and returns no values (Tempo decodes them); duration hint values such as with(sample=1s) are still rejected; plain integers with a leading zero (09) parse here and not in Tempo; with(foo=1s) is rejected here and accepted by Tempo.

44YHC added 6 commits November 6, 2026 04:34
Durations lex as one Duration token ahead of Float and Integer, and lower
through a parseDuration helper copied from Tempo v3.1.0. 1h30m, 1d, 1w, 1y
and 1d12h work; planning reuses the parsed value.

Invalid literals fail at parse time and name the literal: invalid duration
for 1.5d, 1h30 and 1hh, invalid literal for a number directly followed by a
letter, such as 1x and 1e3s.

Behaviour change: a number, a space and a unit (5 s, .5 s, 5. s) is a syntax
error, as in Tempo.
After a dot scope, Label_name mixes bare runes and quoted parts. Parts are
unquoted and joined with Tempo's escapes, so the IR holds the plain name.
Unclosed quotes, bad escapes and quoted colon intrinsics are rejected at parse
time, worded like Tempo.
…ge key

by (.foo) read key .foo, which is never stored, so its label was always empty.
…y plan

Covers search, the complexity plan, metrics by, compare, tags, values and the unresolved probes, for quotes, a trailing backslash, NUL and newline.
# Conflicts:
#	reader/tempo/metrics_query.go

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant