Trace context handling for express 4
npm install express-trace-contextW3C 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.
``shell`
npm i express-trace-context
See example at example/example.ts
Console 1:
`shell`
cd example
`shell`
npm install
`shell`
npx ts-node example.ts
``
Server started on port 3000
Console 2:
`shell`
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_.
`shell`
npm run clean
`shell`
npm install
`shell`
npm run lint
`shell`
npm run test
`shell`
npm run build
`shell``
npm push