IF Commons GitHub

host/query

Written to: 2 requirements: 2 proved, 0 partly, 0 failing, 0 with no test recorded. 0002-telemetry-query FR-004, 0002-telemetry-query FR-005

The journal of signals, read for a question (commons telemetry 0002-telemetry-query FR-004, FR-005): each line of the journal files is one OTLP/JSON export request (resourceSpans, resourceLogs or resourceMetrics), decoded as the exporter encoded it, and a line that does not decode is counted and left out. main is the command line [--limit N] [--json] FILE... -- "SELECT ...": the answer as a table or JSON; it writes nothing.

bun tools/query.ts ~/.cache/app/telemetry.jsonl -- "SELECT name, duration_ms FROM spans ORDER BY duration_ms DESC LIMIT 5"

Source: commons/telemetry/src/host/query.ts

3 of 5 exports are imported by a test of the run. A test that imports an export may not call it or check what it returns.

Journaltypeno test imports it
type Journal = { readonly signals: Signals; readonly skipped: number };

What a journal gave: the signals, and how many lines did not decode.

parseJournalfunction
function parseJournal(texts: readonly string[]): Journal

The signals of the text of journal files: a line of each kind decodes with its own decoder; a blank line is nothing, and any other line is skipped.

Imported by 3 tests of the run (3 passed, 0 failed): the library's results

readJournalfunction
function readJournal(paths: readonly string[]): Promise<Journal>

The signals of journal files, read in the order given (a file that is not there is empty).

Imported by 3 tests of the run (3 passed, 0 failed): the library's results

tableTextfunctionno test imports it
function tableText(answer: Answer): string

The rows as aligned text: a header, then a row for each.

mainfunction
function main(argv: readonly string[]): Promise<{ readonly code: 0 | 1 | 2; readonly lines: readonly string[]; }>

The command line: the exit status (0 an answer, 1 a refused question, 2 a line that does not fit) and what to print.

Imported by 3 tests of the run (3 passed, 0 failed): the library's results

Titles, headings, exports, tables, columns and requirements. Esc closes.