class PumaCloudwatch::Metrics::Parser
Constants
- METRICS
Public Class Methods
new(data)
click to toggle source
# File lib/puma_cloudwatch/metrics/parser.rb, line 5 def initialize(data) @data = data end
Public Instance Methods
call()
click to toggle source
# File lib/puma_cloudwatch/metrics/parser.rb, line 9 def call Array.new.tap { |result| parse(@data, result) } end
Private Instance Methods
parse(stats, result)
click to toggle source
Build this structure:
[{:backlog=>[0, 0], :running=>[0, 0], :pool_capacity=>[16, 16], :max_threads=>[16, 16]}]
# File lib/puma_cloudwatch/metrics/parser.rb, line 21 def parse(stats, result) item = Hash.new([]) clustered = stats.key?("worker_status") if clustered statuses = stats["worker_status"].map { |s| s["last_status"] } # last_status: Array with worker stats statuses.each do |status| METRICS.each do |metric| count = status[metric.to_s] item[metric] += [count] if count end end else # single mode METRICS.each do |metric| count = stats[metric.to_s] item[metric] += [count] if count end end result << item unless item.empty? result end