Skip to main content
The examples use an open store (open a store). getTrace of a trace with 100,000 spans is hundreds of MB. A traceSpans row has spanId, parentSpanId, name, kind, model, startedAt, endedAt, hasError, inputTokens, outputTokens, cost, and the usage fields that the span has. Each page reads the time of every span of the trace once, so for a whole trace use a large limit.

Export spans to JSON Lines

export gives every span that matches the filter, oldest first. With no filter, it gives every span of the store.
  • Each chunk is a string of whole lines, at most a few MB. A line is one span as JSON, in the shape that write takes.
  • The next chunk is made when the loop asks for it, so memory stays small for a store of any size.
  • A line has no line break inside, also not U+2028, U+2029 or U+0085 (they are written as escapes). readline in Node.js and str.splitlines in Python read one span per line.
  • The export reads the commit of the moment it starts: later writes and deletes are not in it. It keeps the files of that commit open until the loop ends. Leave the loop (break) to give it up; in Python, .close() on the iterator also does.
  • A bad query: Node.js rejects it when the loop starts, Python raises at the call, Rust returns the error from export.

Load an export into another store

target is a second store, open for writing in another folder.

Export scores

exportScores({ from, to }) (Python and Rust: export_scores) works the same way for scores. from and to are a time range on the score’s time at. The lines come in no promised order, in the shape that writeScores takes. Backups and imports with the server: backup and import.

Delete and maintain

Delete users, drop old spans, free disk space.

Backup and import

Copy a store, move data between stores.