Skip to content

docs(observability): correct TraceQL syntax in query reference and troubleshooting guide#3274

Open
marians wants to merge 3 commits into
mainfrom
traceql-accuracy-pass
Open

docs(observability): correct TraceQL syntax in query reference and troubleshooting guide#3274
marians wants to merge 3 commits into
mainfrom
traceql-accuracy-pass

Conversation

@marians

@marians marians commented Jul 9, 2026

Copy link
Copy Markdown
Member

What this PR does / why we need it

This is the owed TraceQL SME accuracy pass flagged during the team-atlas Diátaxis split (giantswarm/giantswarm#37089). The TraceQL query reference (formerly the "advanced TraceQL tutorial") and the troubleshooting how-to had accumulated several invalid query constructs that wouldn't parse or run against Tempo.

I verified every construct against the current Grafana Tempo TraceQL spec. The fixes assume colon-scoped intrinsics (Tempo 2.3+), which GS clusters supporting tracing (release v31+ alpha / v33+ full) run. Please sanity-check that version assumption — if any deployment is on pre-2.3 Tempo, the classic dotless intrinsics (duration, traceDuration, status, rootServiceName) would be needed instead.

Corrections

Issue Before (invalid) After
Span duration intrinsic span.duration span:duration
Trace duration intrinsic trace.duration trace:duration
Span name / kind / status span.name, span.kind, status span:name, span:kind, span:status
Root service intrinsic trace.root.service.name trace:rootService
Status message span.status.message span:statusMessage
Invalid attribute scope trace. scope trace fields are intrinsics only
Parent reference parent.resource.service.name / parent.span.name structural operators (>, >>, <, <<, ~)
Percentiles in search | quantile(0.95) avg()/count() search aggregates; note that percentiles need a TraceQL metrics query
Result limit | limit(100) set in Grafana's query editor (no limit() function)
Time filter | select(trace.start_time > now() - 1h) Grafana time range picker (no now()/time function; select() only picks fields)
Enum quoting status = "error" style / span.kind = "client" unquoted enums: span:status = error, span:kind = client

Attribute references (span.http.method, resource.service.name, span.db.system, …) correctly keep dot scope and are unchanged. Valid pipeline usage is now shown with comparisons (| count() > 3, | avg(span:duration) > 1s).

Verified locally with make lint-prose (no findings) and hugo --renderToMemory (relrefs resolve).

Things to check/remember before submitting

  • last_review_date not bumped: correcting syntax within an existing page, no structural change. (Reviewer: happy to bump if you'd prefer, since this is a genuine technical correction.)
  • SME check requested on the Tempo-version assumption above.

🤖 Generated with Claude Code

@marians
marians requested a review from a team as a code owner July 9, 2026 14:52
@marians
marians requested review from a team and removed request for a team July 9, 2026 14:52
…oubleshooting guide

The TraceQL query reference and the troubleshooting how-to contained several
invalid query constructs. Correct them against the current Grafana Tempo
TraceQL spec (colon-scoped intrinsics, Tempo 2.3+, which GS v31+/v33+ clusters
run):

- Intrinsics now use colon scope: span:duration, trace:duration, span:name,
  span:kind, span:status, trace:rootService (were span.duration, trace.duration,
  span.name, span.kind, status, trace.root.service.name).
- Attribute references keep dot scope (span.http.method, resource.service.name).
- Remove the invalid `trace.` attribute scope and `parent.` prefix; express
  parent/child with structural operators (>, >>, <, <<, ~).
- Replace invalid search functions: quantile() -> avg()/note on TraceQL metrics
  for percentiles; drop limit() (no such function); replace the
  select(trace.start_time > now() - 1h) time filter with the Grafana time range
  picker (TraceQL has no now()/time function).
- Unquote enum values (span:status = error, span:kind = client/server).
- Group error patterns by span:statusMessage (was span.status.message).

Add the TraceQL terms `intrinsic(s)` and `spanset(s)` to the vale vocabulary.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@marians
marians force-pushed the traceql-accuracy-pass branch from bae5b52 to e7e6955 Compare July 9, 2026 14:57
Comment thread .vale/styles/config/vocabularies/docs/accept.txt Outdated
marians and others added 2 commits July 9, 2026 17:31
…ines

Every by() stage is now followed by an aggregate and a comparison, and every
aggregate carries a trailing comparison, matching the only forms the Tempo
TraceQL spec documents (terminal by()/bare aggregates aren't shown as valid):

- Group-a-service's-operations example groups by span:name (not the
  already-filtered resource.service.name) and adds | count() > 1.
- Performance-analysis pattern pairs by() with avg(span:duration) > 1s.
- Error-investigation and span-kind examples get trailing count() > 1.
- Capacity-planning count() and the troubleshoot statusMessage grouping get
  trailing comparisons.
- Fix alphabetical order of the spanset vocabulary entry.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

@pipo02mix pipo02mix left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I cannot judge the traceql commands but if those come from official docs I'd say LTGM

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.

2 participants