how to use sentry with node's kue?

819 Views Asked by At

I would like to connect sentry monitoring to my kue app. How should it be done? I see in docs how to do it for plain node.js:

var client = new raven.Client(...);
client.captureError(new Error('Uh oh!!'));

But I would like to have the express style:

app.use(raven.middleware.express(...));

So that sentry will catch errors for me, instead of calling client.captureError manually. Maybe it is simple, I am using kue for the first time, will appreciate any help.

Thanks.

1

There are 1 best solutions below

0
On

You cannot use the express style middleware for catching kue errors because errors that occur via a kue job do not get passed through your express app.

Like you mentioned you could call client.captureError when handling a specific job.

If you want to catch all errors from queue you could register an error handler that can call captureError

queue.on( 'error', function( err ) {
  console.log( 'kue error', err );
  client.captureError(err);
});

You could also capture other events from kue such as when a job fails

queue.on('job failed', function(...) {
    ...
}