Skip to content

Insights: auto-Instrument BullMQ for Queue Insights #12956

Closed

Description

@bcoe

Problem Statement

Similar to Celery for Python, BullMQ seems like it would be a good choice to auto-instrument for queue insights, see: #10148, along with conversations on Twitter:

Screenshot 2024-07-17 at 10 53 00 AM Screenshot 2024-07-17 at 10 53 19 AM Screenshot 2024-07-17 at 10 53 11 AM

Solution Brainstorm

We should model an implementation after the implementation for Celery.

Activity

  1. AbhiPrasad commented on Jul 17, 2024

    @AbhiPrasad
    Contributor

    There is OTEL instrumentation we can leverage here: https://github.com/appsignal/opentelemetry-instrumentation-bullmq

  2. AbhiPrasad commented on Jul 17, 2024

    @AbhiPrasad
    Contributor

    In the time being, we can probably write some docs that uses the otel instrumentation manually with bullmq. So users would have to install opentelemetry-instrumentation-bullmq themselves and then call span.setAttribute themselves.

    @bcoe for an intermediate solution what do you think?

  3. iacobus commented on Aug 22, 2024

    @iacobus

    Hi! Our team is also interested in instrumenting our BullMQ workloads running inside of NestJS. I know close to nothing about OTEL or about how Sentry works, but I've been playing with the OTEL instrumentation package that you referenced, and got something, but not much.

    What I've done is basically trying to integrate the OTEL instrumentation with @sentry/node by looking at how other integrations work. The following snippet defines a BullMQ integration based off the PG tracing code:

    import { BullMQInstrumentation } from '@appsignal/opentelemetry-instrumentation-bullmq'
    import { defineIntegration } from '@sentry/core'
    import { generateInstrumentOnce } from '@sentry/node'
    import type { IntegrationFn } from '@sentry/types'
    
    const INTEGRATION_NAME = 'BullMQ'
    
    export const instrumentBullMQ = generateInstrumentOnce(
      INTEGRATION_NAME,
      () =>
        new BullMQInstrumentation({}),
    )
    
    const _bullmqIntegration = (() => {
      return {
        name: INTEGRATION_NAME,
        setupOnce() {
          instrumentBullMQ()
        },
      }
    }) satisfies IntegrationFn
    
    /**
     * BullMQ integration
     *
     * Capture tracing data for BullMQ.
     */
    export const bullmqIntegration = defineIntegration(_bullmqIntegration)

    With this snippet I can add the bullmqIntegration to my integrations array in Sentry.init (which also contains nodeProfilingIntegration()), so that when I trigger a Bull job, I see a transaction of type message under the Performance section of Sentry, with these relevant attributes:

    messaging.operation: process,
    messaging.system: bullmq,
    otel.kind: CONSUMER,
    sentry.op: message,
    sentry.origin: manual,
    

    However, this transaction is empty. Its duration is just a few milliseconds (shorter than the job duration), and it contains no spans at all, even though there are PG queries inside (PG queries are correctly reported in our regular application tracing). We also see no reference to the producing side of the job, nor we see anything under the Queues section of Sentry.

    Not sure if you were able to get started on those docs you mentioned, but if you have some tips that could unblock us, we'd appreciate it 🙏

  4. moved this to Waiting for: Product Owner in GitHub Issues with 👀 3on Aug 22, 2024
  5. andreiborza commented on Aug 23, 2024

    @andreiborza
    Member

    Hello, thanks for writing in. We are on company-wide hackweek and thus on limited support this week. We'll take a look at this next week.

  6. moved this from Waiting for: Product Owner to No status in GitHub Issues with 👀 3on Aug 23, 2024
  7. iacobus commented on Aug 23, 2024

    @iacobus

    Oh cool, have fun and thanks!

  8. 35 remaining items

  9. moved this from Waiting for: Product Owner to No status in GitHub Issues with 👀 3on Mar 21, 2025
  10. self-assigned this
    on Jun 25, 2026
  11. added a commit that references this issue on Oct 29, 2026
    b722d3c
  12. github-actions commented on Nov 5, 2026

    @github-actions
    Contributor

    A PR closing this issue has just been released 🚀

    This issue was referenced by PR #21777, which was included in the 11.11.0 release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions