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
- #pool_capacity ⇒ Object
- #running ⇒ Object
- #workers ⇒ Object
Constructor Details
#initialize(stats) ⇒ PumaStats
38 39 40 |
# File 'lib/puma/plugin/statsd.rb', line 38 def initialize(stats) @stats = stats end |
Instance Method Details
#backlog ⇒ Object
62 63 64 65 66 67 68 |
# File 'lib/puma/plugin/statsd.rb', line 62 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
50 51 52 |
# File 'lib/puma/plugin/statsd.rb', line 50 def booted_workers @stats.fetch("booted_workers", 1) end |
#clustered? ⇒ Boolean
42 43 44 |
# File 'lib/puma/plugin/statsd.rb', line 42 def clustered? @stats.has_key? "workers" end |
#max_threads ⇒ Object
78 79 80 81 82 83 84 |
# File 'lib/puma/plugin/statsd.rb', line 78 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 |
#pool_capacity ⇒ Object
70 71 72 73 74 75 76 |
# File 'lib/puma/plugin/statsd.rb', line 70 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 |
#running ⇒ Object
54 55 56 57 58 59 60 |
# File 'lib/puma/plugin/statsd.rb', line 54 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
46 47 48 |
# File 'lib/puma/plugin/statsd.rb', line 46 def workers @stats.fetch("workers", 1) end |