Repository navigation
Release 0.3.0
What's new?
Database queries and outbound HTTP, with no code changes
- Queries made through
pg,mysql2andmongodbare recorded as spans under the provider method that ran them. The drivers are instrumented rather than the ORMs, so anything built on them is covered: TypeORM, Drizzle, MikroORM and Mongoose are tested in this repository, and Knex and Sequelize go through the same calls. Spans are named after the verb and table (SELECT users) and carry the statement with every literal removed. Bound parameters are never read. - Outbound calls made with
fetch/undiciornode:http/https(so Axios too) are recorded asPOST api.stripe.com, with sensitive query parameters masked. - The current trace id is forwarded as
x-request-id, so a downstream service running the agent continues the same trace. A header you set yourself is never overwritten. - Query and outbound-HTTP spans are not billed as events. Turn them off with
outgoing: false, or one side withoutgoing: { database: false }oroutgoing: { http: false }.
WebSocket gateways
- Each message handled by a
@SubscribeMessage()method is reported as an operation (GatewayClass:pattern), on both thewsand socket.io adapters. - New
wsoptions:ignore,tags,setAttributes,getUserId. @nestjs/websocketsis an optional peer.
One trace across queues and services
- A BullMQ or Bull job enqueued while handling a request carries that request's trace id, so the request and its job show up as one trace. Repeatable jobs start their own.
- Legacy Bull (
@nestjs/bullandbull) is now supported alongside BullMQ, as an optional peer. - Microservice handlers adopt the
x-request-idthe calling service attached to the packet metadata. It is validated the same way as the HTTP header.
Capture for failed and slow requests
http.capturerecords the inputs of a request that failed, or one slower thanslowerThanMs. It never records ordinary traffic.- By default it records a short allow-list of headers that neither authenticate nor identify the caller, and no body.
body: trueadds the body, capped at 2 KB (configurable up to 16 KB).- Everything recorded goes through redaction first.
capture: falseturns the feature off.
Security
- Source context: forged stack frames.
- An error message containing a newline followed by a frame-shaped line was read as a real stack frame.
- A request parameter interpolated into a validation or driver error could therefore choose which application file had its source attached to the error.
- Frames are now read only from the lines that follow the error's own message.
- Code-frame lines now go through the redactor before they are sent.
- Source context: event-loop blocking. The frame-matching pattern was quadratic on a crafted line: a 100 KB line took about 3 s. It is replaced with a linear parser, and line length and frame count are capped.
- The source-map cache is now bounded.
- Symlinks are resolved before the containment check, so a symlink under the app root can no longer point the reader at a file outside it.
- Redaction: credential key names.
- Credential keys are now matched by what the name ends in, so
resetToken,client_secret,X-Amz-Signature,x-api-keyandjwtare masked in URLs, log attributes, and captured headers and bodies. - One shared list replaces two that had drifted apart.
redaction.keysnow applies to URL query strings as well.
- Credential keys are now matched by what the name ends in, so
- GraphQL number literals are blanked from the recorded document the same way string literals already were.
If you run with sourceContext enabled (the default), upgrading is recommended.
Behaviour changes to be aware of
- Recorded GraphQL documents now show
_in place of inline numbers, soorders(first: 10)andorders(first: 20)group as one shape. Existing groupings for such queries will shift once. - More URL parameters are masked than before. Any key ending in
token,secret,signatureand similar is masked, which includes pagination params such aspageToken. - An error whose
messageis reassigned after construction no longer gets code frames.
Full Changelog: 0.2.3...0.3.0