Repository navigation
Release 0.3.3
Highlights
Skip spans for expected outcomes
Nest applications answer "not found", "not allowed" and "invalid input" by throwing, and until now every one of those requests shipped the full tree of calls it made, each span a billed event. The new skipSpans option reports matching requests without their spans:
ObserveModule.forRoot({
// ...
skipSpans: [400, 401, 403, 404],
// or decide per operation:
// skipSpans: ({ statusCode, duration }) => statusCode === 404 && duration < 1000,
});- The request is still reported (route, status code, duration, user), and so is its error, stack included. Charts and the Errors page don't change.
- Only the span tree is dropped, before anything is serialized or sent. A skipped request costs its own event (plus its error's) and nothing for spans.
- What you give up for those requests: the waterfall shows the request with nothing inside it, and its calls are missing from per-method numbers.
- Microservice, gRPC and WebSocket handlers match by the status their exception gets (
NotFoundExceptionbecomes 404). Jobs always keep their spans. - The function form receives
protocol,operationId,method,statusCode,durationanderrorClass. If it throws, the spans are kept and the failure is logged once.
Details in the README.
BullMQ Pro support
Jobs run by BullMQ Pro are now traced. @taskforcesh/nestjs-bullmq-pro forked @nestjs/bullmq before the processor decorator the agent hooks into existed, so its jobs were never traced. The agent now instruments BullMQ Pro itself:
WorkerProjob runs are traced.- Jobs added with
QueuePro.add/addBulkcarry the trace id of the request that enqueued them, so both show up as one trace. - It works whether Pro is wired in through
@taskforcesh/nestjs-bullmq-pro, through@nestjs/bullmq(BullModule.workerClass = WorkerPro), or with workers you build yourself.
@taskforcesh/bullmq-pro (^7.0.0) is a new optional peer dependency.
Fixes
-
Kafka: failing messages are retried again (#9). The agent's processing hook dropped the handler's promise. With the agent installed, a failing Kafka handler therefore:
- had its offset committed and was never retried;
- let the next message on the partition start before it finished;
- surfaced as an unhandled rejection, which crashes the process under Node's default
--unhandled-rejections=throw.
Kafka services now behave as they do without the agent. This affected Nest 11.1.4 and later, where processing hooks exist. On other transports, a handler's rejection now reaches Nest's own error logging instead of going unhandled: Nest 12.0.2+ for RabbitMQ and TCP, 12.0.4+ for NATS, Redis and MQTT.
-
BullMQ: processors receive the lock token and abort signal (f5ec14e). The agent wrapped
@nestjs/bullmqprocessors as(job) => processor(job), which dropped the token and signal BullMQ passes after the job. A processor managing its own job (moveToDelayed,extendLock) gotundefinedfor the token. One watching the signal for cancellation never got the signal.
Upgrade notes
- Kafka: a message whose handler keeps failing used to be committed and skipped. It now holds up its partition, as it does without the agent: kafkajs retries it per its
retryoptions, then restarts the consumer. If you relied on the old behaviour to get past poison messages, catch the error in the handler.
New Contributors
Full Changelog: 0.3.2...0.3.3