npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@appsignal/opentelemetry-instrumentation-bullmq

v0.7.3

Published

Auto-instrumentation for the BullMQ message framework

Downloads

75,690

Readme

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

| Name | Type | Default value | Description | | --------------------------------- | --------- | ------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | emitCreateSpansForBulk | boolean | true | Whether 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. | | emitCreateSpansForFlow | boolean | true | Whether 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. | | requireParentSpanForPublish | boolean | false | Whether 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. | | useProducerSpanAsConsumerParent | boolean | false | Whether 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.

| Name | Span kind | messaging.bullmq.operation.name attribute [1] | Description | | --------------------- | ------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | | {queueName} publish | PRODUCER | Queue.add | A new job is added to the queue. | | {queueName} publish | INTERNAL [2] | Queue.addBulk | New jobs are added to the queue in bulk. | | {queueName} publish | INTERNAL [3] | FlowProducer.add | A new job flow is added to a queue. | | (bulk) publish | INTERNAL [2] [3] | FlowProducer.addBulk | New job flows are added to queues in bulk. | | {queueName} create | PRODUCER | Job.add | Each of the individual jobs added to a queue. Only emitted in bulk or flow operations. Child span of a publish span. [4] | | {queueName} process | CONSUMER | Worker.run | Each 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.

Useful links

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.