diff --git a/README.md b/README.md index 9a93005..837acd0 100644 --- a/README.md +++ b/README.md @@ -19,6 +19,7 @@ Segmented by the worker (index of the worker): - `puma_running` - the number of running threads (spawned threads) for any puma worker - `puma_max_threads` - preconfigured maximum number of worker threads - `puma_backlog` - the number of backlog threads, the number of connections in that worker's "todo" set waiting for a worker thread. + - `puma_requests_count` - the number of requests a worker has served since starting. ## Installation diff --git a/lib/puma/plugin/yabeda.rb b/lib/puma/plugin/yabeda.rb index 97eef6a..0f00494 100644 --- a/lib/puma/plugin/yabeda.rb +++ b/lib/puma/plugin/yabeda.rb @@ -19,6 +19,7 @@ def start(launcher) gauge :running, tags: %i[index], comment: 'Number of running worker threads', aggregation: :most_recent gauge :pool_capacity, tags: %i[index], comment: 'Number of allocatable worker threads', aggregation: :most_recent gauge :max_threads, tags: %i[index], comment: 'Maximum number of worker threads', aggregation: :most_recent + gauge :requests_count, tags: %i[index], comment: 'Number of requests this worker has served since starting', aggregation: :most_recent if clustered gauge :workers, comment: 'Number of configured workers', aggregation: :most_recent @@ -37,4 +38,3 @@ def start(launcher) end end end - diff --git a/lib/yabeda/puma/plugin/statistics.rb b/lib/yabeda/puma/plugin/statistics.rb index ef8d505..bdc24e7 100644 --- a/lib/yabeda/puma/plugin/statistics.rb +++ b/lib/yabeda/puma/plugin/statistics.rb @@ -2,7 +2,7 @@ module Yabeda module Puma module Plugin module Statistics - METRICS = [:backlog, :running, :pool_capacity, :max_threads] + METRICS = [:backlog, :running, :pool_capacity, :max_threads, :requests_count] CLUSTERED_METRICS = [:booted_workers, :old_workers, :workers] end end diff --git a/spec/yabeda/puma/plugin/statistics/parser_spec.rb b/spec/yabeda/puma/plugin/statistics/parser_spec.rb index 9000b68..7be10c0 100644 --- a/spec/yabeda/puma/plugin/statistics/parser_spec.rb +++ b/spec/yabeda/puma/plugin/statistics/parser_spec.rb @@ -14,11 +14,11 @@ "worker_status"=>[ {"pid"=>13, "index"=>0, "phase"=>0, "booted"=>true, "last_checkin"=>"2019-03-31T13:04:28Z", "last_status"=>{ - "backlog"=>0, "running"=>5, "pool_capacity"=>5, "max_threads"=>5 + "backlog"=>0, "running"=>5, "pool_capacity"=>5, "max_threads"=>5, "requests_count" => 5, }}, {"pid"=>17, "index"=>1, "phase"=>0, "booted"=>true, "last_checkin"=>"2019-03-31T13:04:28Z", "last_status"=>{ - "backlog"=>0, "running"=>5, "pool_capacity"=>5, "max_threads"=>5 + "backlog"=>0, "running"=>5, "pool_capacity"=>5, "max_threads"=>5, "requests_count" => 5, } } ] @@ -36,11 +36,13 @@ { name: 'running', labels: {index: 0}, value: 5 }, { name: 'pool_capacity', labels: {index: 0}, value: 5 }, { name: 'max_threads', labels: {index: 0}, value: 5 }, + { name: 'requests_count', labels: {index: 0}, value: 5}, { name: 'backlog', labels: {index: 1}, value: 0 }, { name: 'running', labels: {index: 1}, value: 5 }, { name: 'pool_capacity', labels: {index: 1}, value: 5 }, - { name: 'max_threads', labels: {index: 1}, value: 5 } + { name: 'max_threads', labels: {index: 1}, value: 5 }, + { name: 'requests_count', labels: {index: 1}, value: 5}, ] ) end