Skip to content
On this page
  1. Install
  2. Framework-independent metrics
  3. NestJS integration
  4. Metrics and cardinality

OpenTelemetry

Feed queue metrics into your application-owned telemetry stack with @queuebert/otel.

Install#

bash
npm install @queuebert/otel @opentelemetry/api@^1.9

Queuebert records through an OpenTelemetry Meter. It does not start an SDK, choose an exporter, serve a Prometheus endpoint, or automatically instrument BullMQ workers. Configure your SDK before importing application code and record events from your processing lifecycle.

Framework-independent metrics#

typescript
import { metrics } from '@opentelemetry/api';
import { createResourceAttributes, MetricsRegistry } from '@queuebert/otel';

const registry = new MetricsRegistry(
  {
    durationBuckets: [10, 50, 100, 500, 1000, 5000],
    perJobNameMetrics: true,
    maxJobNames: 100,
  },
  metrics.getMeter('email-worker.queuebert', '1.0.0'),
  createResourceAttributes({
    serviceName: 'email-worker',
    deploymentEnvironment: 'production',
  }),
);

registry.recordJobCompleted('emails', 'welcome', 82);
registry.recordJobFailed('emails', 'digest', 410);
registry.updateQueueCounts('emails', {
  waiting: 12,
  active: 2,
  completed: 240,
  failed: 4,
  delayed: 1,
});

const snapshot = registry.getSnapshot();
const queuebertStats = registry.transformToQueuebertStats('emails');

// During shutdown, unregister observable callbacks:
registry.destroy();

Durations above are milliseconds. Replace the illustrative numbers with measured job outcomes and live BullMQ counts. If you omit the meter, the global API meter is used; without a configured SDK/exporter, recording does not deliver metrics to a backend.

NestJS integration#

Install the Nest peers in addition to the API package:

bash
npm install @queuebert/nest @nestjs/bullmq@^11 @nestjs/common@^11 @nestjs/core@^11 bullmq@^5
typescript
import { Module } from '@nestjs/common';
import { QueuebertOTelModule } from '@queuebert/otel/nest';

@Module({
  imports: [
    QueuebertOTelModule.forRoot({
      instrumentationName: 'email-worker.queuebert',
      instrumentationVersion: '1.0.0',
      resource: {
        serviceName: 'email-worker',
        deploymentEnvironment: 'production',
      },
    }),
  ],
})
export class TelemetryModule {}

Inject QueuebertOTelService to record completed/failed jobs, update queue counts, and obtain snapshots. QUEUEBERT_OTEL_METER and QUEUEBERT_OTEL_TRACER expose the configured instances. Async configuration is available through forRootAsync().

The Nest import path is @queuebert/otel/nest, not @queuebert/nest/otel.

Metrics and cardinality#

The METRIC_NAMES export defines the stable names:

MetricSignal
queuebert.job.completedCompleted-job counter
queuebert.job.failedFailed-job counter
queuebert.job.durationProcessing-duration histogram
queuebert.job.waitingObservable waiting-job gauge
queuebert.job.activeObservable active-job gauge
queuebert.job.delayedObservable delayed-job gauge
queuebert.queue.throughputQueue throughput

maxJobNames bounds job-name cardinality; overflow names are aggregated under __other__. Use stable operation names instead of customer IDs or job IDs. Queuebert snapshot failure and success rates are fractions between 0 and 1, not percentages.

Queuebert

© 2026 Queuebert