Class: Amigo::Autoscaler::Handlers::Sentry
- Inherits:
-
Amigo::Autoscaler::Handler
- Object
- Amigo::Autoscaler::Handler
- Amigo::Autoscaler::Handlers::Sentry
- Defined in:
- lib/amigo/autoscaler/handlers/sentry.rb
Instance Method Summary collapse
-
#initialize(interval: 300, message: "Some queues have a high latency", level: :warn) ⇒ Sentry
constructor
A new instance of Sentry.
- #scale_down ⇒ Object
- #scale_up(high_latencies:, depth:, duration:, pool_usage:) ⇒ Object
Constructor Details
#initialize(interval: 300, message: "Some queues have a high latency", level: :warn) ⇒ Sentry
Returns a new instance of Sentry.
15 16 17 18 19 20 21 |
# File 'lib/amigo/autoscaler/handlers/sentry.rb', line 15 def initialize(interval: 300, message: "Some queues have a high latency", level: :warn) @interval = interval @message = @level = level @last_alerted = Time.at(0) super() end |
Instance Method Details
#scale_down ⇒ Object
34 |
# File 'lib/amigo/autoscaler/handlers/sentry.rb', line 34 def scale_down(**) = nil |
#scale_up(high_latencies:, depth:, duration:, pool_usage:) ⇒ Object
23 24 25 26 27 28 29 30 31 32 |
# File 'lib/amigo/autoscaler/handlers/sentry.rb', line 23 def scale_up(high_latencies:, depth:, duration:, pool_usage:, **) now = Time.now call_sentry = @last_alerted < (now - @interval) return unless call_sentry ::Sentry.with_scope do |scope| scope&.set_extras(high_latencies:, depth:, duration:, pool_usage:) ::Sentry.(@message, level: @level) end @last_alerted = now end |