Class: Sentry::BackpressureMonitor
- Inherits:
-
ThreadedPeriodicWorker
- Object
- ThreadedPeriodicWorker
- Sentry::BackpressureMonitor
- Defined in:
- lib/sentry/backpressure_monitor.rb
Constant Summary collapse
- DEFAULT_INTERVAL =
10
- MAX_DOWNSAMPLE_FACTOR =
10
Instance Method Summary collapse
- #check_health ⇒ Object
- #downsample_factor ⇒ Object
- #healthy? ⇒ Boolean
-
#initialize(configuration, client, interval: DEFAULT_INTERVAL) ⇒ BackpressureMonitor
constructor
A new instance of BackpressureMonitor.
- #run ⇒ Object
- #set_downsample_factor ⇒ Object
Methods inherited from ThreadedPeriodicWorker
Constructor Details
permalink #initialize(configuration, client, interval: DEFAULT_INTERVAL) ⇒ BackpressureMonitor
Returns a new instance of BackpressureMonitor.
8 9 10 11 12 13 14 |
# File 'lib/sentry/backpressure_monitor.rb', line 8 def initialize(configuration, client, interval: DEFAULT_INTERVAL) super(configuration.logger, interval) @client = client @healthy = true @downsample_factor = 0 end |
Instance Method Details
permalink #check_health ⇒ Object
[View source]
31 32 33 |
# File 'lib/sentry/backpressure_monitor.rb', line 31 def check_health @healthy = !(@client.transport.any_rate_limited? || Sentry.background_worker&.full?) end |
permalink #downsample_factor ⇒ Object
[View source]
21 22 23 24 |
# File 'lib/sentry/backpressure_monitor.rb', line 21 def downsample_factor ensure_thread @downsample_factor end |
permalink #healthy? ⇒ Boolean
16 17 18 19 |
# File 'lib/sentry/backpressure_monitor.rb', line 16 def healthy? ensure_thread @healthy end |
permalink #run ⇒ Object
[View source]
26 27 28 29 |
# File 'lib/sentry/backpressure_monitor.rb', line 26 def run check_health set_downsample_factor end |
permalink #set_downsample_factor ⇒ Object
[View source]
35 36 37 38 39 40 41 42 43 |
# File 'lib/sentry/backpressure_monitor.rb', line 35 def set_downsample_factor if @healthy log_debug("[BackpressureMonitor] health check positive, reverting to normal sampling") if @downsample_factor.positive? @downsample_factor = 0 else @downsample_factor += 1 if @downsample_factor < MAX_DOWNSAMPLE_FACTOR log_debug("[BackpressureMonitor] health check negative, downsampling with a factor of #{@downsample_factor}") end end |