New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

opentelemetry-instrumentation-bullmq

Package Overview
Dependencies
Maintainers
0
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

opentelemetry-instrumentation-bullmq

Auto-instrumentation for the BullMQ message framework

  • 0.7.15
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
0
Created
Source

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.

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.

Keywords

FAQs

Package last updated on 28 Aug 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc