Class: QueuePulse::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/queue_pulse/configuration.rb

Overview

Holds all tunable settings. Sensible defaults mean a user only has to add a notifier to get value. See docs/requirements.md (US-1, US-3).

Constant Summary collapse

ALL_CHECKS =

All checks shipped in Phase 1, in evaluation order.

%i[failures queue_latency queue_depth stuck_jobs worker_liveness].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/queue_pulse/configuration.rb', line 27

def initialize
  @enabled = true
  @poll_interval = 30                 # seconds (Railtie poller)
  @queue_latency_threshold = 300      # seconds a job may wait before alerting
  @queue_depth_threshold = 1_000      # ready jobs per queue before alerting
  @stuck_job_threshold = 600          # seconds a claimed job may run before alerting
  @worker_heartbeat_threshold = 120   # seconds before a process is "dead"
  @alert_cooldown = 900               # seconds to suppress duplicate state alerts
  @failure_burst_threshold = 25       # collapse into a summary above this many
  @check_timeout = 25                 # seconds; abort a slow pass
  @notifiers = []
  @enabled_checks = ALL_CHECKS.dup
  @environment_label = default_environment
  @include_arguments = false          # never send raw job arguments by default
  @logger = default_logger
  @cache = nil
end

Instance Attribute Details

#alert_cooldownObject

Returns the value of attribute alert_cooldown.



10
11
12
# File 'lib/queue_pulse/configuration.rb', line 10

def alert_cooldown
  @alert_cooldown
end

#cacheObject

Cache store for dedupe/cooldown state. Prefers Rails.cache, falls back to an in-process MemoryStore so the gem works even without a configured cache.



56
57
58
# File 'lib/queue_pulse/configuration.rb', line 56

def cache
  @cache ||= rails_cache || MemoryStore.new
end

#check_timeoutObject

Returns the value of attribute check_timeout.



10
11
12
# File 'lib/queue_pulse/configuration.rb', line 10

def check_timeout
  @check_timeout
end

#enabledObject

Returns the value of attribute enabled.



10
11
12
# File 'lib/queue_pulse/configuration.rb', line 10

def enabled
  @enabled
end

#enabled_checksObject

Returns the value of attribute enabled_checks.



10
11
12
# File 'lib/queue_pulse/configuration.rb', line 10

def enabled_checks
  @enabled_checks
end

#environment_labelObject

Returns the value of attribute environment_label.



10
11
12
# File 'lib/queue_pulse/configuration.rb', line 10

def environment_label
  @environment_label
end

#failure_burst_thresholdObject

Returns the value of attribute failure_burst_threshold.



10
11
12
# File 'lib/queue_pulse/configuration.rb', line 10

def failure_burst_threshold
  @failure_burst_threshold
end

#include_argumentsObject

Returns the value of attribute include_arguments.



10
11
12
# File 'lib/queue_pulse/configuration.rb', line 10

def include_arguments
  @include_arguments
end

#loggerObject

Returns the value of attribute logger.



10
11
12
# File 'lib/queue_pulse/configuration.rb', line 10

def logger
  @logger
end

#notifiersObject

Returns the value of attribute notifiers.



10
11
12
# File 'lib/queue_pulse/configuration.rb', line 10

def notifiers
  @notifiers
end

#poll_intervalObject

Returns the value of attribute poll_interval.



10
11
12
# File 'lib/queue_pulse/configuration.rb', line 10

def poll_interval
  @poll_interval
end

#queue_depth_thresholdObject

Returns the value of attribute queue_depth_threshold.



10
11
12
# File 'lib/queue_pulse/configuration.rb', line 10

def queue_depth_threshold
  @queue_depth_threshold
end

#queue_latency_thresholdObject

Returns the value of attribute queue_latency_threshold.



10
11
12
# File 'lib/queue_pulse/configuration.rb', line 10

def queue_latency_threshold
  @queue_latency_threshold
end

#stuck_job_thresholdObject

Returns the value of attribute stuck_job_threshold.



10
11
12
# File 'lib/queue_pulse/configuration.rb', line 10

def stuck_job_threshold
  @stuck_job_threshold
end

#worker_heartbeat_thresholdObject

Returns the value of attribute worker_heartbeat_threshold.



10
11
12
# File 'lib/queue_pulse/configuration.rb', line 10

def worker_heartbeat_threshold
  @worker_heartbeat_threshold
end

Instance Method Details

#add_notifier(notifier) ⇒ Object



45
46
47
48
# File 'lib/queue_pulse/configuration.rb', line 45

def add_notifier(notifier)
  @notifiers << notifier
  notifier
end

#check_enabled?(name) ⇒ Boolean

Returns:

  • (Boolean)


50
51
52
# File 'lib/queue_pulse/configuration.rb', line 50

def check_enabled?(name)
  @enabled_checks.include?(name)
end