@redthreadlabs/tracelog-schema
v0.5.0
Published
Shared contract for the tracelog suite: record kinds, S3 key layout, metadata sidecar, and the /logs wire format
Readme
@redthreadlabs/tracelog-schema
The shared contract for the tracelog suite — one dependency-free, isomorphic source of truth so the agent (writer), the client SDK, the server, and the viewer (reader) never drift.
It contains only the contract: types and pure functions, no I/O.
- Record kinds (
kinds.ts) — the top-level kinds of each NDJSON line (transaction,span,error,event,metricset). - S3 key layout (
keys.ts) —buildKey/parseKey(exact inverses) plusintervalSpan,overlapsRange,dedupeCurrents,normalizeHost. The layout{channel}/{interval}/{host}[_{seq}][_current].jsonl[.gz]is fixed. - Metadata sidecar (
sidecar.ts) — theSidecarMetashape written at<logkey>.meta.json, plus theMetaAccumulatorthat derives it from a file's bytes (uncompressed size, record count, and an hourly interval×kind histogram). - Wire format (
wire.ts) — thePOST /logsingest types (LogBatch,LogEventItem,TimerItem,ClientInfo).
Usage
import { parseKey, MetaAccumulator, RECORD_KINDS, type LogEventItem } from '@redthreadlabs/tracelog-schema';Build / test
Plain tsc to CommonJS dist/; tests run against the compiled output.
npm run build
npm test