Class: Speedshop::Cloudwatch::Puma

Inherits:
Object
  • Object
show all
Defined in:
lib/speedshop/cloudwatch/puma.rb

Instance Method Summary collapse

Instance Method Details

#collectObject



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/speedshop/cloudwatch/puma.rb', line 6

def collect
  stats = ::Puma.stats_hash

  if stats[:worker_status]
    %i[workers booted_workers old_workers].each do |m|
      Reporter.instance.report(metric: metric_name_for(m), value: stats[m] || 0)
    end
    report_aggregate_worker_stats(stats)
  else
    # Single mode - report worker stats without dimensions
    %i[running backlog pool_capacity max_threads].each do |m|
      Reporter.instance.report(metric: metric_name_for(m), value: stats[m] || 0)
    end
  end
rescue => e
  Speedshop::Cloudwatch.log_error("Failed to collect Puma metrics: #{e.message}", e)
end