trcprnt
TypeScript icon, indicating that this package has built-in type declarations

0.0.2 • Public • Published

trcprnt

npm add trcprnt makes traceparent's simple


Features

  • LightweightBrowser 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

Package Sidebar

Install

npm i trcprnt

Weekly Downloads

14

Version

0.0.2

License

MIT

Unpacked Size

7.83 kB

Total Files

9

Last publish

Collaborators

  • marais