Class: PumaStats
- Inherits:
-
Object
- Object
- PumaStats
- Defined in:
- lib/puma/plugin/statsd.rb
Overview
Wrap puma’s stats in a safe API
Instance Method Summary collapse
- #backlog ⇒ Object
- #booted_workers ⇒ Object
- #clustered? ⇒ Boolean
-
#initialize(stats) ⇒ PumaStats
constructor
A new instance of PumaStats.
- #max_threads ⇒ Object
- #old_workers ⇒ Object
- #pool_capacity ⇒ Object
- #requests_count ⇒ Object
- #running ⇒ Object
- #workers ⇒ Object
Constructor Details
#initialize(stats) ⇒ PumaStats
Returns a new instance of PumaStats.
39 40 41 |
# File 'lib/puma/plugin/statsd.rb', line 39 def initialize(stats) @stats = stats end |
Instance Method Details
#backlog ⇒ Object
67 68 69 70 71 72 73 |
# File 'lib/puma/plugin/statsd.rb', line 67 def backlog if clustered? @stats[:worker_status].map { |s| s[:last_status].fetch(:backlog, 0) }.inject(0, &:+) else @stats.fetch(:backlog, 0) end end |
#booted_workers ⇒ Object
51 52 53 |
# File 'lib/puma/plugin/statsd.rb', line 51 def booted_workers @stats.fetch(:booted_workers, 1) end |
#clustered? ⇒ Boolean
43 44 45 |
# File 'lib/puma/plugin/statsd.rb', line 43 def clustered? @stats.has_key?(:workers) end |
#max_threads ⇒ Object
83 84 85 86 87 88 89 |
# File 'lib/puma/plugin/statsd.rb', line 83 def max_threads if clustered? @stats[:worker_status].map { |s| s[:last_status].fetch(:max_threads, 0) }.inject(0, &:+) else @stats.fetch(:max_threads, 0) end end |
#old_workers ⇒ Object
55 56 57 |
# File 'lib/puma/plugin/statsd.rb', line 55 def old_workers @stats.fetch(:old_workers, 0) end |
#pool_capacity ⇒ Object
75 76 77 78 79 80 81 |
# File 'lib/puma/plugin/statsd.rb', line 75 def pool_capacity if clustered? @stats[:worker_status].map { |s| s[:last_status].fetch(:pool_capacity, 0) }.inject(0, &:+) else @stats.fetch(:pool_capacity, 0) end end |
#requests_count ⇒ Object
91 92 93 94 95 96 97 |
# File 'lib/puma/plugin/statsd.rb', line 91 def requests_count if clustered? @stats[:worker_status].map { |s| s[:last_status].fetch(:requests_count, 0) }.inject(0, &:+) else @stats.fetch(:requests_count, 0) end end |
#running ⇒ Object
59 60 61 62 63 64 65 |
# File 'lib/puma/plugin/statsd.rb', line 59 def running if clustered? @stats[:worker_status].map { |s| s[:last_status].fetch(:running, 0) }.inject(0, &:+) else @stats.fetch(:running, 0) end end |
#workers ⇒ Object
47 48 49 |
# File 'lib/puma/plugin/statsd.rb', line 47 def workers @stats.fetch(:workers, 1) end |