@appsignal/opentelemetry-instrumentation-bullmq

中文文档
0.9.0发布于 2026/08/24Apache-2.0TypeScriptCommonJS近 30 天下载 33万

Auto-instrumentation for the BullMQ message framework

原始使用文档
文档目录8 节
  1. Installation
  2. Supported Versions
  3. Usage
  4. Configuration options
  5. Emitted spans
  6. Useful links
  7. License
  8. Contributing

OpenTelemetry Bullmq Instrumentation for Node.js

Node.js CI npm version

This module provides automatic tracing instrumentation for BullMQ.

Compatible with OpenTelemetry JS API and SDK 1.0+.

Installation

npm install --save @appsignal/opentelemetry-instrumentation-bullmq

Supported Versions

  • [2.x, 3.x, 4.x, 5.x]

It's likely that the instrumentation would support earlier versions of BullMQ, but I haven't tested it.

Usage

OpenTelemetry BullMQ Instrumentation allows the user to automatically collect trace data from BullMQ jobs and workers and export them to the backend of choice.

To load the instrumentation, specify it in the instrumentations list to registerInstrumentations. There is currently no configuration option.

const { NodeTracerProvider } = require("@opentelemetry/sdk-trace-node");
const { registerInstrumentations } = require("@opentelemetry/instrumentation");
const {
  BullMQInstrumentation,
} = require("@appsignal/opentelemetry-instrumentation-bullmq");

const provider = new NodeTracerProvider();
provider.register();

registerInstrumentations({
  instrumentations: [
    new BullMQInstrumentation({
      // configuration options, see below
    }),
  ],
});

Configuration options

NameTypeDefault valueDescription
emitCreateSpansForBulkbooleantrueWhether to emit a create span for each individual job enqueued by Queue.addBulk or FlowProducer.addBulk. The span representing the overall bulk operation is emitted regardless.
emitCreateSpansForFlowbooleantrueWhether to emit a create span for each individual job enqueued by FlowProducer.add or FlowProducer.addBulk. The span representing the overall flow operation is emitted regardless.
requireParentSpanForPublishbooleanfalseWhether to omit emitting a publish span (and the create child spans for it, for bulk and flow operations) when there is no parent span, meaning that the span created would be the root span of a new trace.
useProducerSpanAsConsumerParentbooleanfalseWhether to use the producer kind (create or publish) span as the parent for the consumer kind (process) span. When set to true, the consumer and producer spans will be part of the same trace. When set to false, the consumer span will be in a separate trace from the producer span, and it will contain a link to the producer span.

Emitted spans

The instrumentation aims to comply with the OpenTelemetry Semantic Convention for Messaging Spans. Whenever possible, attributes from the semantic convention are used in these spans.

NameSpan kindmessaging.bullmq.operation.name attribute [1]Description
{queueName} publishPRODUCERQueue.addA new job is added to the queue.
{queueName} publishINTERNAL [2]Queue.addBulkNew jobs are added to the queue in bulk.
{queueName} publishINTERNAL [3]FlowProducer.addA new job flow is added to a queue.
(bulk) publishINTERNAL [2] [3]FlowProducer.addBulkNew job flows are added to queues in bulk.
{queueName} createPRODUCERJob.addEach of the individual jobs added to a queue. Only emitted in bulk or flow operations. Child span of a publish span. [4]
{queueName} processCONSUMERWorker.runEach job execution by a worker. Linked to the corresponding producer span. [5]
  • [1]: Represents the BullMQ function that was called in the application in order to trigger this span to be emitted.
  • [2]: When the emitCreateSpansForBulk configuration option is set to false, it is a PRODUCER span.
  • [3]: When the emitCreateSpansForFlow configuration option is set to false, it is a PRODUCER span.
  • [4]: Will not be emitted for calls to Queue.addBulk and FlowProducer.addBulk when the emitCreateSpansForBulk configuration option is false, or for calls to FlowProducer.add and FlowProducer.addBulk when the emitCreateSpansForFlow configuration option is set to false.
  • [5]: The producer span may not have been emitted if the requireParentSpanForPublish is set to true. In this case, no link is established.

License

Apache 2.0 - See LICENSE for more information.

Contributing

Contributions are welcome. Feel free to open an issue or submit a PR. I would like to have this package included in opentelemetry-js-contrib at some point. Until then, it lives here.

BullMQ has a hard dependency on Redis, which means that Redis is (for now) a test dependency for the instrumentations. To run the tests, you should have a redis server running on localhost at the default port. If you have docker installed, you can just do docker-compose up and be ready to go.

版本与发布记录

@appsignal/opentelemetry-instrumentation-bullmq 共发布 7 个版本,首次发布于 2024/06/10;过去 12 个月发布了 2 个版本。

版本发布日期距今
0.9.0latest2026/08/242 个月前
0.8.02026/03/127 个月前
0.7.32024/10/082 年前
0.7.22024/10/012 年前
0.7.12024/06/132 年前
0.7.02024/06/112 年前

关于 @appsignal/opentelemetry-instrumentation-bullmq 的常见问题

@appsignal/opentelemetry-instrumentation-bullmq 是什么?

Auto-instrumentation for the BullMQ message framework

如何安装 @appsignal/opentelemetry-instrumentation-bullmq?

在项目目录运行 npm install @appsignal/opentelemetry-instrumentation-bullmq,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:@opentelemetry/api(^1.3.0)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@appsignal/opentelemetry-instrumentation-bullmq 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@appsignal/opentelemetry-instrumentation-bullmq 支持 ESM 还是 CommonJS?

以 CommonJS 形式发布,可以直接 require();在 ES Module 项目中也可以用 import 引入(Node.js 会把 module.exports 作为默认导出)。

@appsignal/opentelemetry-instrumentation-bullmq 可以商用吗?

@appsignal/opentelemetry-instrumentation-bullmq 使用 Apache-2.0 许可。宽松许可:允许商业使用、修改和再分发,并附带明确的专利授权;分发时需保留许可与 NOTICE 文件,修改过的文件要注明改动。以上为概括,不构成法律意见,请以许可原文为准。

@appsignal/opentelemetry-instrumentation-bullmq 的下载量有多少?

根据 npm 官方下载统计,@appsignal/opentelemetry-instrumentation-bullmq 在 2026/10/07 – 2026/11/05 这 30 天内被下载 329,657 次,日均约 10,989 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@appsignal/opentelemetry-instrumentation-bullmq 还在维护吗?

最新版本 0.9.0 发布于 2026/08/24(2 个月前);至今共发布 7 个版本,其中过去 12 个月发布了 2 个;首次发布于 2024/06/10。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。