Module: Speedshop::Cloudwatch::Observations::Puma
- Defined in:
- lib/speedshop/cloudwatch/observations/puma.rb
Class Method Summary collapse
- .clustered_observations(stats) ⇒ Object
- .from_stats(stats) ⇒ Object
- .metric_name_for(symbol) ⇒ Object
- .single_mode_observations(stats) ⇒ Object
Class Method Details
.clustered_observations(stats) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/speedshop/cloudwatch/observations/puma.rb', line 17 def clustered_observations(stats) observations = %i[workers booted_workers old_workers].map do |metric| {metric: metric_name_for(metric), value: stats[metric] || 0} end stats[:worker_status].each do |worker_status| last_status = worker_status[:last_status] || {} %i[running backlog pool_capacity max_threads].each do |metric| next unless last_status.key?(metric) observations << {metric: metric_name_for(metric), value: last_status[metric]} end end observations end |
.from_stats(stats) ⇒ Object
9 10 11 12 13 14 15 |
# File 'lib/speedshop/cloudwatch/observations/puma.rb', line 9 def from_stats(stats) if stats[:worker_status] clustered_observations(stats) else single_mode_observations(stats) end end |
.metric_name_for(symbol) ⇒ Object
40 41 42 |
# File 'lib/speedshop/cloudwatch/observations/puma.rb', line 40 def metric_name_for(symbol) symbol.to_s.split("_").map(&:capitalize).join.to_sym end |
.single_mode_observations(stats) ⇒ Object
34 35 36 37 38 |
# File 'lib/speedshop/cloudwatch/observations/puma.rb', line 34 def single_mode_observations(stats) %i[running backlog pool_capacity max_threads].map do |metric| {metric: metric_name_for(metric), value: stats[metric] || 0} end end |