getsentry / sentry-ruby

Sentry SDK for Ruby
https://sentry.io/for/ruby
MIT License
926 stars 493 forks source link

Crons: add `sidekiq-scheduler` zero-config monitor check-ins #2172

Closed natikgadzhi closed 10 months ago

natikgadzhi commented 10 months ago

Summary

This pull request adds Crons support for sidekiq-scheduler jobs with zero configuration.

Changes

How this works

Similar to #2170, when SidekiqScheduler loads the jobs, we hook into it's new_job method, constantine the job class, and patch it with MonitorCheckIns module.

Open questions

codecov[bot] commented 10 months ago

Codecov Report

Merging #2172 (989c530) into master (78fb37a) will decrease coverage by 0.04%. The diff coverage is 91.30%.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #2172 +/- ## ========================================== - Coverage 97.34% 97.30% -0.04% ========================================== Files 98 99 +1 Lines 3657 3680 +23 ========================================== + Hits 3560 3581 +21 - Misses 97 99 +2 ``` | [Components](https://app.codecov.io/gh/getsentry/sentry-ruby/pull/2172/components?src=pr&el=components&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=getsentry) | Coverage Δ | | |---|---|---| | [sentry-ruby](https://app.codecov.io/gh/getsentry/sentry-ruby/pull/2172/components?src=pr&el=component&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=getsentry) | `98.02% <ø> (ø)` | | | [sentry-rails](https://app.codecov.io/gh/getsentry/sentry-ruby/pull/2172/components?src=pr&el=component&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=getsentry) | `94.98% <ø> (ø)` | | | [sentry-sidekiq](https://app.codecov.io/gh/getsentry/sentry-ruby/pull/2172/components?src=pr&el=component&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=getsentry) | `94.50% <91.30%> (-0.47%)` | :arrow_down: | | [sentry-resque](https://app.codecov.io/gh/getsentry/sentry-ruby/pull/2172/components?src=pr&el=component&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=getsentry) | `92.06% <ø> (ø)` | | | [sentry-delayed_job](https://app.codecov.io/gh/getsentry/sentry-ruby/pull/2172/components?src=pr&el=component&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=getsentry) | `94.36% <ø> (ø)` | | | [sentry-opentelemetry](https://app.codecov.io/gh/getsentry/sentry-ruby/pull/2172/components?src=pr&el=component&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=getsentry) | `100.00% <ø> (ø)` | | | [Files](https://app.codecov.io/gh/getsentry/sentry-ruby/pull/2172?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=getsentry) | Coverage Δ | | |---|---|---| | [sentry-sidekiq/lib/sentry-sidekiq.rb](https://app.codecov.io/gh/getsentry/sentry-ruby/pull/2172?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=getsentry#diff-c2VudHJ5LXNpZGVraXEvbGliL3NlbnRyeS1zaWRla2lxLnJi) | `85.18% <100.00%> (+0.56%)` | :arrow_up: | | [...-sidekiq/lib/sentry/sidekiq-scheduler/scheduler.rb](https://app.codecov.io/gh/getsentry/sentry-ruby/pull/2172?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=getsentry#diff-c2VudHJ5LXNpZGVraXEvbGliL3NlbnRyeS9zaWRla2lxLXNjaGVkdWxlci9zY2hlZHVsZXIucmI=) | `90.90% <90.90%> (ø)` | |
sl0thentr0py commented 10 months ago

thx @natikgadzhi

pls revert the renames, those are intentional and follow the namespacing of the gem we are patching Sidekiq::Cron::Job -> Sentry::Sidekiq::Cron::Job. In general if you want to do changes like that, please open a separate PR and keep features/bug fixes isolated.

I'll review the other stuff now.

sl0thentr0py commented 10 months ago

Is it okay to have both sidekiq-cron and sidekiq-scheduler in our Gemfile, and require both of them in spec_helper for sentry-sidekiq? I feel like folks could be surprised that Sentry tugs two extra dependencies, one of which they probably don't need at all.

these are our dependencies for testing, not for our users.

natikgadzhi commented 10 months ago

In general if you want to do changes like that, please open a separate PR and keep features/bug fixes isolated.

I even considered a separate PR first, but then settled on a separate commit for that exact reason. No problem, I'm a noob here, so TIL. Will revert.

I'll clean the rest of the feedback up in a bit and push up the fix, then work on documentation.

natikgadzhi commented 10 months ago

@sl0thentr0py thank you a LOT for your feedback! I'm learning as I go, and I'm grateful for your patience with me.

I've worked through your suggestions, so this should be ready for another pass. Also added the changelog line.

UPD: Hold up, I see a bunch of CI failures, let me try these locally and see if I can work around them. Fixed! Not proud of the code there, though.

natikgadzhi commented 10 months ago

@st0012 thank you for the review! I'll clean this up later tonight, should be ready tomorrow.

I also see the Coverage decline, I'll add the test.

natikgadzhi commented 10 months ago

@st0012 @sl0thentr0py welp. Next steps seem to be:

natikgadzhi commented 10 months ago

@sl0thentr0py @st0012 Fixed the Ruby 2.5 compatibility, now the CI is just trolling me.

sl0thentr0py commented 10 months ago

re-ran just timestamp flakiness