Built-in Enrichers
traceparentEnricher()
Parses the W3C traceparent header directly, with no OpenTelemetry SDK required. That is the difference from logixlysia/otel, which reads the ids of the currently active span and therefore needs the SDK installed and instrumenting your app.
trace_id / span_id naming matches what Sentry, HyperDX, and OTLP backends expect, so logs link to traces as soon as an upstream service propagates the header.
Malformed headers are ignored rather than partially parsed: the reserved
ff version, all-zero trace or span ids, and a version 00 header carrying extra fields all add nothing.
userAgentEnricher()
Turns user-agent into fields you can group by.
ua.device is one of desktop, mobile, tablet, or bot. This is a heuristic — user agents are not a parseable grammar — so treat it as a dashboard dimension, not as an access-control input.
geoEnricher()
Reads the geo headers your platform already attaches. Vercel, Cloudflare, and Netlify are recognized.
sizeEnricher()
Records payload sizes.
content-length, the only size available without buffering a body. A chunked or streamed response has no content-length, so responseBytes is omitted rather than guessed.
Writing Your Own
An enricher is either a bare function — treated as the request phase — or an object withrequest and response phases.
undefined to add nothing.
Phases
The response phase runs before the request’s final log line on both the success and the error path, so its fields are on the access log and on the error log alike. Request-phase fields, being merged at the start, also reach any
log.info() you make inside the handler.
Failure Handling
Enrichment is decoration and must never take a request down. A hook that throws is caught, reported, and skipped — the remaining enrichers still run and the request completes normally. Failures go toonError with sink: 'enricher', or to stderr (rate-limited) when no hook is configured.