-
Notifications
You must be signed in to change notification settings - Fork 225
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Question] Support bullmq #4037
Comments
@lzj960515 bullmq is based on the redis implementation, so it should be normal to collect the redis command stack here, right? |
Hi @lzj960515, My guess, from your screenshot, is that you have one seemingly random transaction that is getting the Redis spans for every I'm not sure I can explain the "different context" well. Can you show a small working example? That would help me dig into what is going on. |
I looked at bullmq worker.js a little more.
|
Thank you for your response. So, how can I remove the BZPOPMIN call chain? I started a transaction before callProcessJob and ended it after, theoretically there shouldn’t be BZPOPMIN calls within my transaction context. |
I'm not sure from your screenshot that the BZPOPMIN and EVALSHA spans are part of a transaction created by your As a quick and poor hack, There is an internal If there was a small reproducible example using bullmq I could play a bit to possibly find a solution. |
Hi @trentm , I wrote a sample code. Could you please take another look at it? Thank you very much. |
Hi @lzj960515, I believe you are hitting an issue that is a limitation in the workaroundA workaround described there is to add /* eslint-disable @typescript-eslint/no-var-requires */
const apm = require('elastic-apm-node/start');
const shimmer = require('elastic-apm-node/lib/instrumentation/shimmer');
const { Worker } = require('bullmq');
shimmer.wrap(Worker.prototype, 'callProcessJob', function (original) {
return async function callProcessJob(job, token) {
await Promise.resolve(); // <------------ add this workaround
const transName = `${job.queueName}[${job.name}]`;
const trans = apm.startTransaction(transName, 'queue');
... and that seems to work for me now. detailsThe issue with the What the In a perfect world there would be a better API from the APM agent -- something like However, at this point looking at using OpenTelemetry (and perhaps our OpenTelemetry distribution for Node.js -- https://github.com/elastic/elastic-otel-node/tree/main/packages/opentelemetry-node -- currently in alpha) will be a better long term bet as we are focusing more of our efforts on good compatibility with OpenTelemetry. The OTel API includes an equivalent of this better Note that switching to OpenTelemetry, especially when doing custom/manual instrumentation as you are, does mean relearning a number of concepts. |
I am using bullmq as a queue on Node, and I have integrated it into apm using a custom method, but I have encountered some issues. Here is my code.
Although I have called the trans.end() method, the apm still collected the methods called in bullmq to redis, which should not have happened. What should I do to avoid this situation?
Thank you for your help.
The text was updated successfully, but these errors were encountered: