getsentry / sentry-ruby

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

Extract thread control logic into a new `ThreadedPeriodicWorker` class #2304

Closed st0012 closed 3 months ago

st0012 commented 3 months ago

Instead of letting BackpressureMonitor, SessionFlusher, and Metrics::Aggregator handle their own threading logic, we can extract that into a new class that can be reused by all of them.

Closes #2261

skip-changelog

codecov[bot] commented 3 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 98.73%. Comparing base (6cdb1fc) to head (309661e).

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #2304 +/- ## ========================================== + Coverage 98.72% 98.73% +0.01% ========================================== Files 202 203 +1 Lines 13301 13274 -27 ========================================== - Hits 13131 13106 -25 + Misses 170 168 -2 ``` | [Components](https://app.codecov.io/gh/getsentry/sentry-ruby/pull/2304/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/2304/components?src=pr&el=component&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=getsentry) | `99.12% <100.00%> (+0.01%)` | :arrow_up: | | [sentry-rails](https://app.codecov.io/gh/getsentry/sentry-ruby/pull/2304/components?src=pr&el=component&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=getsentry) | `97.37% <ø> (ø)` | | | [sentry-sidekiq](https://app.codecov.io/gh/getsentry/sentry-ruby/pull/2304/components?src=pr&el=component&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=getsentry) | `96.98% <ø> (ø)` | | | [sentry-resque](https://app.codecov.io/gh/getsentry/sentry-ruby/pull/2304/components?src=pr&el=component&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=getsentry) | `96.76% <ø> (ø)` | | | [sentry-delayed_job](https://app.codecov.io/gh/getsentry/sentry-ruby/pull/2304/components?src=pr&el=component&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=getsentry) | `98.91% <ø> (ø)` | | | [sentry-opentelemetry](https://app.codecov.io/gh/getsentry/sentry-ruby/pull/2304/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/2304?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=getsentry) | Coverage Δ | | |---|---|---| | [sentry-ruby/lib/sentry-ruby.rb](https://app.codecov.io/gh/getsentry/sentry-ruby/pull/2304?src=pr&el=tree&filepath=sentry-ruby%2Flib%2Fsentry-ruby.rb&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=getsentry#diff-c2VudHJ5LXJ1YnkvbGliL3NlbnRyeS1ydWJ5LnJi) | `96.58% <100.00%> (+0.01%)` | :arrow_up: | | [sentry-ruby/lib/sentry/backpressure\_monitor.rb](https://app.codecov.io/gh/getsentry/sentry-ruby/pull/2304?src=pr&el=tree&filepath=sentry-ruby%2Flib%2Fsentry%2Fbackpressure_monitor.rb&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=getsentry#diff-c2VudHJ5LXJ1YnkvbGliL3NlbnRyeS9iYWNrcHJlc3N1cmVfbW9uaXRvci5yYg==) | `100.00% <100.00%> (+2.27%)` | :arrow_up: | | [sentry-ruby/lib/sentry/metrics/aggregator.rb](https://app.codecov.io/gh/getsentry/sentry-ruby/pull/2304?src=pr&el=tree&filepath=sentry-ruby%2Flib%2Fsentry%2Fmetrics%2Faggregator.rb&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=getsentry#diff-c2VudHJ5LXJ1YnkvbGliL3NlbnRyeS9tZXRyaWNzL2FnZ3JlZ2F0b3IucmI=) | `100.00% <100.00%> (ø)` | | | [sentry-ruby/lib/sentry/session\_flusher.rb](https://app.codecov.io/gh/getsentry/sentry-ruby/pull/2304?src=pr&el=tree&filepath=sentry-ruby%2Flib%2Fsentry%2Fsession_flusher.rb&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=getsentry#diff-c2VudHJ5LXJ1YnkvbGliL3NlbnRyeS9zZXNzaW9uX2ZsdXNoZXIucmI=) | `100.00% <100.00%> (+2.00%)` | :arrow_up: | | [sentry-ruby/lib/sentry/threaded\_periodic\_worker.rb](https://app.codecov.io/gh/getsentry/sentry-ruby/pull/2304?src=pr&el=tree&filepath=sentry-ruby%2Flib%2Fsentry%2Fthreaded_periodic_worker.rb&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=getsentry#diff-c2VudHJ5LXJ1YnkvbGliL3NlbnRyeS90aHJlYWRlZF9wZXJpb2RpY193b3JrZXIucmI=) | `100.00% <100.00%> (ø)` | | | [...ntry-ruby/spec/sentry/backpressure\_monitor\_spec.rb](https://app.codecov.io/gh/getsentry/sentry-ruby/pull/2304?src=pr&el=tree&filepath=sentry-ruby%2Fspec%2Fsentry%2Fbackpressure_monitor_spec.rb&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=getsentry#diff-c2VudHJ5LXJ1Ynkvc3BlYy9zZW50cnkvYmFja3ByZXNzdXJlX21vbml0b3Jfc3BlYy5yYg==) | `100.00% <100.00%> (ø)` | | | [sentry-ruby/spec/sentry/metrics/aggregator\_spec.rb](https://app.codecov.io/gh/getsentry/sentry-ruby/pull/2304?src=pr&el=tree&filepath=sentry-ruby%2Fspec%2Fsentry%2Fmetrics%2Faggregator_spec.rb&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=getsentry#diff-c2VudHJ5LXJ1Ynkvc3BlYy9zZW50cnkvbWV0cmljcy9hZ2dyZWdhdG9yX3NwZWMucmI=) | `100.00% <100.00%> (ø)` | | | [sentry-ruby/spec/sentry/session\_flusher\_spec.rb](https://app.codecov.io/gh/getsentry/sentry-ruby/pull/2304?src=pr&el=tree&filepath=sentry-ruby%2Fspec%2Fsentry%2Fsession_flusher_spec.rb&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=getsentry#diff-c2VudHJ5LXJ1Ynkvc3BlYy9zZW50cnkvc2Vzc2lvbl9mbHVzaGVyX3NwZWMucmI=) | `100.00% <100.00%> (ø)` | |