Processor stats
Report job duration, throughput and outcomes from your existing workers.
Choose a processor integration#
@queuebert/nest accepts a processor implementing QueuebertProcessor. The @queuebert/bullmq package supplies BaseQueueProcessor, which extends Nest's WorkerHost and implements that contract.
It tracks job duration, success/failure counts, throughput, Redis connection status, and optional cache statistics. See the BullMQ package guide for installation and direct queue/worker wrappers.
Instrument your worker#
Override processJob() rather than process() so the base class records the job's outcome and timing.
import { Processor } from '@nestjs/bullmq';
import { BaseQueueProcessor } from '@queuebert/bullmq';
import type { Job } from 'bullmq';
@Processor('emails', { concurrency: 10 })
export class EmailProcessor extends BaseQueueProcessor {
constructor(private readonly emailService: EmailService) {
super({ queueName: 'emails' });
}
async processJob(job: Job<{ to: string; template: string }>) {
await this.emailService.send(job.data);
return true;
}
}EmailService is your application's service: import it and register it as you normally would. Do not create a second worker solely for monitoring.
Register the processor#
Add the processor class to your Nest module's providers and associate it with the queue in Queuebert:
QueuebertModule.forRoot({
queues: [{ name: 'emails', processor: EmailProcessor }],
});You can instead implement getProcessorStats(): QueuebertProcessorStats on your own class. The Nest package README documents the duration, jobs and throughput fields.
Send metrics to your existing stack#
For application-owned OpenTelemetry meters and exporters, see OpenTelemetry. Queuebert's metrics helpers do not start an SDK or choose an exporter.