sentry-ruby icon indicating copy to clipboard operation
sentry-ruby copied to clipboard

Support `good_job`

Open renchap opened this issue 9 months ago • 8 comments

Describe the idea

good_job is a modern and feature-full ActiveJob backend based on PostgreSQL, by @bensheldon

If would be useful to have an integration for it, similar to the Sidekiq integration.

Why do you think it's beneficial to most of the users

You could add the instrumentation yourself to the app (there are examples in the doc for exception tracking), but it can get complex if you want a full integration with tracing support and so on. Having it built-in will ensure that users benefit from all Sentry's feature when using good_job

Possible implementation

There has been some discussion about this integration, with some code samples that add some of those features: https://github.com/bensheldon/good_job/issues/1558

renchap avatar Apr 03 '25 10:04 renchap

hey thanks for reporting this - sounds like a great addition, would you be interested in opening a PR with this integration? I'm happy to help.

solnic avatar Apr 03 '25 13:04 solnic

We are evaluating switching from Sidekiq to GoodJob right now, but did not make the switch yet, so I can not work on it at the moment. But in our exploration we noticed that this switch would make us loose those Sentry features that we really like, hence the issue.

Maybe @olivier-thatch who contributed the code in the linked issue would be interested?

renchap avatar Apr 04 '25 12:04 renchap

@solnic Hey! I am also interested in this, do you have any hints? Probably this might be already enough for the start: https://github.com/search?q=repo%3Agetsentry%2Fsentry-ruby%20sidekiq&type=code and https://github.com/bensheldon/good_job/issues/1558#issuecomment-2546936044

I realized that sentry-rails already has an ActiveJob integration that does some of this (https://github.com/getsentry/sentry-ruby/blob/master/sentry-rails/lib/sentry/rails/active_job.rb)

I was also wondering about this as it covers quite essential parts already.

amkisko avatar May 23 '25 12:05 amkisko

@solnic Hey! I am also interested in this, do you have any hints? Probably this might be already enough for the start: https://github.com/search?q=repo%3Agetsentry%2Fsentry-ruby%20sidekiq&type=code and bensheldon/good_job#1558 (comment)

I realized that sentry-rails already has an ActiveJob integration that does some of this (https://github.com/getsentry/sentry-ruby/blob/master/sentry-rails/lib/sentry/rails/active_job.rb)

I was also wondering about this as it covers quite essential parts already.

@amkisko hey! :) yes looking at sentry-sidekiq and taking some inspiration from it would be a good start. As I understand good_job is powerful enough to justify a dedicated integration, right?

solnic avatar May 27 '25 15:05 solnic

As I understand good_job is powerful enough to justify a dedicated integration, right?

I haven't had a chance to work on this in a while, but I don't think a dedicated integration is necessary: unlike Sidekiq which can be used on its own or as an ActiveJob backend, GoodJob is purely an ActiveJob backend, so the existing ActiveJob integration should be sufficient.

Rather than writing a new dedicated integration, I think the existing ActiveJob integration should be updated. Currently, it emits a queue.active_job operation when a job is performed. Ideally, the integration would:

  1. emit a queue.publish operation when a job is enqueued (this is currently missing)
  2. rename the queue.active_job operation to queue.process for clarity and consistency with the Sidekiq integration

I did write a simple but working integration here: https://gist.github.com/olivier-thatch/6baf7bf12b0f4862e53a4c333e3570d9, but it's probably missing some features from the existing ActiveJob integration, and I haven't tested it thoroughly (i.e. what happens when a job is performed inline with #perform_now, what happens when a job is retried, etc.).

olivier-thatch avatar May 28 '25 21:05 olivier-thatch

GoodJob is purely an ActiveJob backend

@olivier-thatch oh OK thanks! I missed/forgot about that. In this case we should just look into improving our existing ActiveJob integration just like you described above.

@amkisko is this something you'd be interested in doing?

solnic avatar May 29 '25 13:05 solnic

I've got preliminary working solution according to current features in Sentry, continuing testing it and let's see if it will get here. :)

amkisko avatar Oct 15 '25 08:10 amkisko

Main PR: https://github.com/getsentry/sentry-ruby/pull/2751

Would also prefer getting this one in the same time: https://github.com/getsentry/sentry-ruby/pull/2750

amkisko avatar Oct 16 '25 11:10 amkisko