Skip to content

Commit a22ddca

Browse files
docs: document request ID propagation for /v1/cubesql endpoint (cube-js#10666)
Update REST API documentation to cover the request ID propagation feature added in commit 1bce74b (feat(api-gateway): propagate request ID for REST /cubesql endpoint). Changes: - REST API overview (index.mdx): Update 'Request span annotation' section to explicitly list both /v1/load and /v1/cubesql as supporting request span annotation, document traceparent header support, and describe the auto-generated request ID format. - REST API reference (reference.mdx): Add request span annotation note to the /v1/cubesql endpoint section explaining x-request-id and traceparent header support, and add a curl example with x-request-id header. Co-authored-by: Cursor Agent <cursoragent@cursor.com>
1 parent 810b776 commit a22ddca

2 files changed

Lines changed: 31 additions & 7 deletions

File tree

docs/content/product/apis-integrations/core-data-apis/rest-api/index.mdx

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -264,13 +264,19 @@ Cube REST API has basic errors and HTTP Error codes for all requests.
264264

265265
### Request span annotation
266266

267-
For monitoring tools such as Cube Cloud proper request span annotation should be
268-
provided in `x-request-id` header of a request. Each request id should consist
269-
of two parts: `spanId` and `requestSequenceId` which define `x-request-id` as
270-
whole: `${spanId}-span-${requestSequenceId}`. Values of `x-request-id` header
271-
should be unique for each separate request. `spanId` should define user
272-
interaction span such us `Continue wait` retry cycle and it's value shouldn't
273-
change during one single interaction.
267+
Both [`/v1/load`][ref-ref-load] and [`/v1/cubesql`][ref-ref-cubesql] endpoints
268+
support request span annotation for monitoring and tracing.
269+
270+
You can provide a request ID via the `x-request-id` header or the `traceparent`
271+
header. Each request ID should consist of two parts: `spanId` and
272+
`requestSequenceId` which define `x-request-id` as whole:
273+
`${spanId}-span-${requestSequenceId}`. Values of `x-request-id` header should
274+
be unique for each separate request. `spanId` should define user interaction span
275+
such as `Continue wait` retry cycle and its value shouldn't change during one
276+
single interaction.
277+
278+
If neither header is provided, Cube auto-generates a request ID in the
279+
`${uuid}-span-1` format.
274280

275281
## Cache control
276282

docs/content/product/apis-integrations/core-data-apis/rest-api/reference.mdx

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -335,6 +335,11 @@ This endpoint is part of the [SQL API][ref-sql-api].
335335
| `timezone` | The [time zone][ref-time-zone] for this query in the [TZ Database Name][link-tzdb] format, e.g., `America/Los_Angeles` | ❌ No |
336336
| `cache` | See [cache control][ref-cache-control]. `stale-if-slow` by default | ❌ No |
337337

338+
This endpoint supports [request span annotation][ref-request-span]. You can
339+
pass the `x-request-id` or `traceparent` HTTP header to propagate your
340+
request ID through the entire SQL execution chain for tracing and monitoring.
341+
If neither header is provided, Cube auto-generates a request ID.
342+
338343
Response: a stream of newline-delimited JSON objects. The first object contains
339344
the `schema` property with column names and types, and optionally
340345
`lastRefreshTime` indicating when the data was last refreshed.
@@ -381,6 +386,18 @@ Response:
381386
{"data":[["Max VERSTAPPEN","10","3.730769230769231"],["Lando NORRIS","4","4"],["Charles LECLERC","4","4.730769230769231"],["Oscar PIASTRI","3","4.8076923076923075"],["Andrea Kimi ANTONELLI","0","5"]]}
382387
```
383388

389+
Request with a custom request ID for tracing:
390+
391+
```bash
392+
curl \
393+
-X POST \
394+
-H "Authorization: TOKEN" \
395+
-H "Content-Type: application/json" \
396+
-H "x-request-id: my-trace-id-span-1" \
397+
-d '{"query": "SELECT 123 AS value"}' \
398+
http://localhost:4000/cubejs-api/v1/cubesql
399+
```
400+
384401
## `{base_path}/v1/pre-aggregations/jobs`
385402

386403
Trigger pre-aggregation build jobs or retrieve statuses of such jobs.
@@ -883,3 +900,4 @@ Keep-Alive: timeout=5
883900
[link-tzdb]: https://en.wikipedia.org/wiki/Tz_database
884901
[ref-control-plane-api]: /product/apis-integrations/control-plane-api
885902
[self-metadata-api]: #metadata-api
903+
[ref-request-span]: /product/apis-integrations/rest-api#request-span-annotation

0 commit comments

Comments
 (0)