v0.2.1
Blazing fast w3c Trace Contexts for any JS runtime
Attributes
Includes Deno configuration
Repository
Current version released
5 months ago
Dependencies
trace context
W3C Trace Context’s made simple
This is free to use software, but if you do like it, consider supporting me ❤️
⚙️ Install
npm add tctx
🚀 Usage
// producer
import * as traceparent from 'tctx/traceparent';
import * as tracestate from 'tctx/tracestate';
fetch('/api', {
headers: {
traceparent: traceparent.make(),
tracestate: tracestate.make({ key: 'value' }),
},
});
// consumer
import * as traceparent from 'tctx/traceparent';
import * as tracestate from 'tctx/tracestate';
const parent_key = traceparent.parse(request.headers.traceparent);
const parent_state = tracestate.parse(request.headers.tracestate);
parent_state.set('vendor', 'value');
fetch('/downstream', {
headers: {
traceparent: parent.child(),
tracestate: parent_state,
},
});
💨 Benchmark
via the
/bench
directory with deno 1.41.3
# make
✔ tctx ~ 1,666,269 ops/sec ± 0.04%
✔ traceparent ~ 156,468 ops/sec ± 0.07%
✔ trace-context ~ 691,817 ops/sec ± 0.02%
# parse
✔ tctx ~ 3,429,690 ops/sec ± 0.05%
✔ traceparent ~ 186,418 ops/sec ± 0.07%
✔ trace-context ~ 3,327,424 ops/sec ± 0.10%
# child
✔ tctx ~ 2,627,467 ops/sec ± 0.04%
✔ traceparent ~ 256,958 ops/sec ± 0.10%
✔ trace-context ~ 1,252,370 ops/sec ± 0.04%
License
MIT © Marais Rossouw