Skip to content

[FEATURE] Trino: add trace, JSON and SQL variable plugins - #956

Open
dougkirkley wants to merge 3 commits into
perses:mainfrom
dougkirkley:feat/trino-trace-json-variable
Open

dougkirkley wants to merge 3 commits into
perses:mainfrom
dougkirkley:feat/trino-trace-json-variable

Conversation

@dougkirkley

Copy link
Copy Markdown
Contributor

Description

Closes #955.

Adds three plugin kinds to the Trino plugin, each with an editor, CUE schema and tests, Go SDK builder, and docs with examples:

  • TrinoTraceQuery (TraceQuery) reads spans from a SQL result by column name (trace_id, span_id, start_time, plus optional parent, service, span name, end or duration, status, kind and attributes; the GreptimeDB column names are accepted too). Several trace ids become search results for TraceTable and ScatterChart. A single trace id returns the full trace for TracingGanttChart, which refuses results that also carry search results, so a search matching exactly one trace is shown as that trace. varbinary ids become hex. Only this query sends X-Trino-Client-Capabilities: PARAMETRIC_DATETIME, so timestamp(9) keeps its nanoseconds; the header is added to the editor's proxy allowHeaders default, and a proxy that doesn't allow it still works with millisecond precision.
  • TrinoJsonQuery (JsonQuery) returns rows as objects for the Table panel, with no time column needed. Perses gives a JSON query no time range, so {start} and {end} aren't replaced. Rows are JS objects, so integer-like column names come first and a repeated name keeps its last value; the docs say so.
  • TrinoSQLVariable fills a list variable from the first column, with an optional second column as the label. It reads at most 10,000 rows: the client now takes an optional maxRows and cancels the query there.

Client changes shared by all kinds: maxRows (clamped to 1..100,000), and truncated is now also set when the last page goes past the limit.

Every SQL example in the docs was run against Trino 484. The examples use :sqlstring for variables. The new editors reject variable datasources like the existing ones (#937), and, like them, have no editor tests.

Screenshots

Perses main with this branch's plugin and Trino in Docker. The dashboard runs the README examples as written, on synthetic OpenTelemetry spans (catalog iceberg backed by the memory connector).

Trace table and scatter (search), Gantt chart (single trace), and Table (JSON query):

Trino trace, JSON and variable plugins

TrinoSQLVariable with a value and label column:

TrinoSQLVariable

Checklist

  • Pull request has a descriptive title and context useful to a reviewer.
  • Pull request title follows the [<catalog_entry>] <commit message> naming convention using one of the
    following catalog_entry values: FEATURE, ENHANCEMENT, BUGFIX, BREAKINGCHANGE, DOC,IGNORE.
  • All commits have DCO signoffs.

UI Changes

  • Changes that impact the UI include screenshots and/or screencasts of the relevant changes.
  • Code follows the UI guidelines.

Add TrinoTraceQuery, TrinoJsonQuery and TrinoSQLVariable, each with an
editor, CUE schema and tests, Go SDK builder and docs with examples.

The trace query reads spans by column name, returns search results for
several traces and only the full trace for a single one, and asks Trino
for nanosecond timestamps. The client gains an optional maxRows, used by
the variable to stop at 10,000 rows, and flags a result cut on its last
page as truncated.

Closes perses#955

Signed-off-by: Douglass Kirkley <doug.kirkley@gmail.com>
@dougkirkley
dougkirkley requested review from adrianSepiol and removed request for a team November 22, 2026 17:54

@jgbernalp jgbernalp 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.

Thanks for this, the new plugins are consistent across the runtime, CUE schemas, Go SDK and docs, and well tested. I left a few inline comments: one important (bigint precision in SQL variable values), the rest minor or nits.

Comment thread trino/README.md Resolved
Comment thread trino/sdk/go/query/json/json.go Resolved
Comment thread trino/src/model/trino-client.ts Resolved
Comment thread trino/README.md Resolved
- Document that bigint values lose precision above 2^53 and cast the
  variable examples to varchar.
- Rename the JSON query Go package to jsonquery.
- Stop flagging a result of exactly maxRows rows as truncated.
- Document the CORS header needed for trace queries with a direct URL.
- Move the span type aliases below the imports.

Signed-off-by: Douglass Kirkley <doug.kirkley@gmail.com>
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.

[Trino] Add trace, table and variable plugins

2 participants