Skip to content

'traceheader' based trace context propagation for express 4

License

Notifications You must be signed in to change notification settings

jojczykp/express-trace-context

Repository files navigation

Express Trace Context

W3C Trace Context handling for express.js, based on traceheader and tracestate.

Can be easily integrated with loggers:

  • Call .use(traceMiddleware) in server setup.
  • Call getTraceContext() in your logging method.

Usage

npm i express-trace-context

See example at example/example.ts

Example

Console 1:

cd example
npm install
npx ts-node example.ts
Server started on port 3000

Console 2:

curl -s http://localhost:3000 -H 'traceparent: 00-11223344556677889900aabbccddeeff-1234567890abcdef-01' -H 'tracestate: congo=ucfJifl5GOE,rojo=00f067aa0ba902b7' -H 'Content-Type: application/json' -d '{ "some": "json body" }' | jq .
{
  "traceContext": {
... (details from request propagated here) ...

Also note logs in Console 1.

Develop

npm run clean
npm install
npm run lint
npm run test
npm run build
npm push

References

TODOs

  • Implement remaining of specification details once stable

About

'traceheader' based trace context propagation for express 4

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published