Module: Puma::Plugin::TelemetryToo::CommonData

Included in:
ClusteredData, WorkerData
Defined in:
lib/puma/plugin/telemetry_too/data.rb

Overview

Helper for working with Puma stats

Constant Summary collapse

TELEMETRY_TO_METHODS =
{
  'workers.booted' => :workers_booted,
  'workers.total' => :workers_total,
  'workers.spawned_threads' => :workers_spawned_threads,
  'workers.max_threads' => :workers_max_threads,
  'workers.requests_count' => :workers_requests_count,
  'queue.backlog' => :queue_backlog,
  'queue.backlog_max' => :queue_backlog_max,
  'queue.reactor_max' => :queue_reactor_max,
  'queue.capacity' => :queue_capacity
}.freeze

Instance Method Summary collapse

Instance Method Details

#initialize(stats) ⇒ Object



20
21
22
# File 'lib/puma/plugin/telemetry_too/data.rb', line 20

def initialize(stats)
  @stats = stats
end

#metrics(selected) ⇒ Object



32
33
34
35
36
37
38
# File 'lib/puma/plugin/telemetry_too/data.rb', line 32

def metrics(selected)
  selected.each_with_object({}) do |metric, obj|
    next unless TELEMETRY_TO_METHODS.key?(metric)

    obj[metric] = public_send(TELEMETRY_TO_METHODS[metric])
  end
end

#workers_bootedObject



24
25
26
# File 'lib/puma/plugin/telemetry_too/data.rb', line 24

def workers_booted
  @stats.fetch(:booted_workers, 1)
end

#workers_totalObject



28
29
30
# File 'lib/puma/plugin/telemetry_too/data.rb', line 28

def workers_total
  @stats.fetch(:workers, 1)
end