trcprnt
v0.0.2
Published
Blazing fast w3c traceparent ids
Downloads
28
Maintainers
Readme
⚡ Features
Lightweight — Browser runtime has a single dep, otherwise slim see.
Efficient — Effective reuse of memory, and lazy.
Producer Friendly — Are you a browser?
make()
and go home.Quick — Get an id super performant.
⚙️ Install
npm add trcprnt
🚀 Usage
// producer
import { make } from 'trcprnt';
fetch('/api', {
headers: {
traceparent: make(),
},
});
// consumer
import { parse } from 'trcprnt';
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
WARN Unsupported engine: wanted: {"node":">=16"} (current: {"node":"v14.17.0","pnpm":"6.14.7"})
> trcprnt@0.0.1 bench /Users/marais.rossouw/dev/oss/traceparent
> node -r tsm bench/index.ts
Validation :: make
✔ trcprnt
✔ TraceParent
Benchmark :: make
trcprnt x 117,727 ops/sec ±1.65% (83 runs sampled)
TraceParent x 50,297 ops/sec ±3.65% (73 runs sampled)
Validation :: parse
✔ trcprnt
✔ TraceParent
Benchmark :: parse
trcprnt x 237,944 ops/sec ±0.56% (95 runs sampled)
TraceParent x 116,229 ops/sec ±4.15% (78 runs sampled)
Validation :: child
✔ trcprnt
✔ TraceParent
Benchmark :: child
trcprnt x 69,925 ops/sec ±2.35% (77 runs sampled)
TraceParent x 36,920 ops/sec ±3.45% (77 runs sampled)
License
MIT © Marais Rossouw