Query Observability Store
Changed onRuns a single read-only SQL query against the local trace store and returns { columns, rows }.
Only one SELECT/WITH statement is allowed; writes, DDL, PRAGMA, ATTACH, and multiple statements are rejected, and at most 10000 rows are returned. Bind values with params rather than string-interpolating them. attributes is stored as JSONB — wrap it with json(attributes) to read it back as JSON.
Schema (the query contract):
CREATE TABLE spans ( trace_id TEXT NOT NULL, span_id TEXT NOT NULL, parent_id TEXT, -- parent_id IS NULL on a root (invocation) span service TEXT, -- owning worker name (multi-worker attribution) name TEXT, kind TEXT, start_ms INTEGER, -- absolute epoch ms duration_ms INTEGER, -- whole ms; NULL while the span is still running outcome TEXT, error TEXT, attributes BLOB, -- JSONB; read via json(attributes) created_at TEXT, PRIMARY KEY (trace_id, span_id) ); -- index spans_roots ON spans (start_ms) WHERE parent_id IS NULL
CREATE TABLE logs ( trace_id TEXT NOT NULL, span_id TEXT, seq INTEGER NOT NULL, -- order within the trace ts_ms INTEGER, level TEXT, message TEXT, -- message is a JSON-encoded console arg array operation TEXT, created_at TEXT, PRIMARY KEY (trace_id, seq) );
Request
- Base URL: /cdn-cgi/local/explorer/api (relative, and the document was published on a file host, not at the API’s origin)
- URL: /cdn-cgi/local/explorer/api/local/observability/query
- Auth: none declared
Request body
Response
Query response.
Example response
{
"errors": [],
"messages": [],
"success": true
}Changes
- ○
endpoint added
- ○