npm.io
0.5.1 • Published yesterday

@redthreadlabs/tracelog-schema

Licence
BSD-2-Clause
Version
0.5.1
Deps
0
Size
28 kB
Vulns
0
Weekly
0

@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) plus intervalSpan, overlapsRange, dedupeCurrents, normalizeHost. The layout {channel}/{interval}/{host}[_{seq}][_current].jsonl[.gz] is fixed.
  • Metadata sidecar (sidecar.ts) — the SidecarMeta shape written at <logkey>.meta.json, plus the MetaAccumulator that derives it from a file's bytes (uncompressed size, record count, and an hourly interval×kind histogram).
  • Wire format (wire.ts) — the POST /logs ingest 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

Keywords