⚡ Features
-
Lightweight — see.
-
Efficient — Effective reuse of memory between children see benchmarks.
-
Producer Friendly — Are you a browser?
make()
and go home.
⚙️ Install
npm add tctx
🚀 Usage
// producer
import { make } from 'tctx';
fetch('/api', {
headers: {
traceparent: make(),
},
});
// consumer
import { parse } from 'tctx';
const parent = parse(request.headers.traceparent);
const id = parent.child();
fetch('/downstream', {
headers: {
traceparent: id,
},
});
💨 Benchmark
via the
/bench
directory with Node v16.12.0
Validation :: make
✔ tctx
✔ TraceParent
Benchmark :: make
tctx x 226,914 ops/sec ±1.69% (82 runs sampled)
TraceParent x 52,308 ops/sec ±3.87% (78 runs sampled)
Validation :: parse
✔ tctx
✔ TraceParent
Benchmark :: parse
tctx x 3,923,503 ops/sec ±0.44% (94 runs sampled)
TraceParent x 120,083 ops/sec ±4.15% (76 runs sampled)
Validation :: child
✔ tctx
✔ TraceParent
Benchmark :: child
tctx x 123,069 ops/sec ±3.40% (69 runs sampled)
TraceParent x 39,435 ops/sec ±2.84% (79 runs sampled)
License
MIT © Marais Rossouw