Class: Wurk::Stats::Snapshot
- Inherits:
-
Stats
- Object
- Stats
- Wurk::Stats::Snapshot
- Defined in:
- lib/wurk/stats.rb
Overview
Every Stats reading taken at one moment, in two round trips: the
counters with the queues, paused and processes members, then each
queue's LLEN + tail and each process's busy. A plain Stats re-reads the
queue set per method and pays seven round trips for what the dashboard's
landing payload asks of it. Internal reader for the dashboard and the
HTTP API: Stats keeps Sidekiq's per-method reads (ยง19.1).
consumers: true also reads each process's info and answers
#consumers, the per-queue subscriber count of QueueConsumers.counts.
Instance Attribute Summary collapse
-
#default_queue_latency ⇒ Object
readonly
Returns the value of attribute default_queue_latency.
-
#queue_summaries ⇒ Object
readonly
Returns the value of attribute queue_summaries.
-
#workers_size ⇒ Object
readonly
Returns the value of attribute workers_size.
Instance Method Summary collapse
-
#consumers ⇒ Hash{String=>Integer}
Queue โ live subscribers.
- #enqueued ⇒ Object
-
#initialize(consumers: false) ⇒ Snapshot
constructor
rubocop:disable Lint/MissingSuper.
- #queues ⇒ Object
Constructor Details
#initialize(consumers: false) ⇒ Snapshot
rubocop:disable Lint/MissingSuper
182 183 184 185 186 187 188 |
# File 'lib/wurk/stats.rb', line 182 def initialize(consumers: false) # rubocop:disable Lint/MissingSuper @with_consumers = consumers Wurk.redis(idempotent: true) do |conn| names, paused, identities = read_members(conn) read_gauges(conn, names, paused.to_set, identities) end end |
Instance Attribute Details
#default_queue_latency ⇒ Object (readonly)
Returns the value of attribute default_queue_latency.
180 181 182 |
# File 'lib/wurk/stats.rb', line 180 def default_queue_latency @default_queue_latency end |
#queue_summaries ⇒ Object (readonly)
Returns the value of attribute queue_summaries.
180 181 182 |
# File 'lib/wurk/stats.rb', line 180 def queue_summaries @queue_summaries end |
#workers_size ⇒ Object (readonly)
Returns the value of attribute workers_size.
180 181 182 |
# File 'lib/wurk/stats.rb', line 180 def workers_size @workers_size end |
Instance Method Details
#consumers ⇒ Hash{String=>Integer}
Returns queue โ live subscribers.
194 195 196 197 198 |
# File 'lib/wurk/stats.rb', line 194 def consumers raise ArgumentError, 'Snapshot read without consumers: true' unless @with_consumers @consumers end |
#enqueued ⇒ Object
190 |
# File 'lib/wurk/stats.rb', line 190 def enqueued = @queue_summaries.sum(&:size) |
#queues ⇒ Object
191 |
# File 'lib/wurk/stats.rb', line 191 def queues = @queue_summaries.to_h { |summary| [summary.name, summary.size] } |