Class: Tpt::Rails::PumaStatsCollector::PumaStats

Inherits:
Object
  • Object
show all
Defined in:
lib/tpt/rails/puma_stats_collector.rb

Instance Method Summary collapse

Constructor Details

#initialize(stats) ⇒ PumaStats

Returns a new instance of PumaStats.



3
4
5
# File 'lib/tpt/rails/puma_stats_collector.rb', line 3

def initialize(stats)
  @stats = JSON.parse(stats, symbolize_names: true)
end

Instance Method Details

#backlogObject



23
24
25
# File 'lib/tpt/rails/puma_stats_collector.rb', line 23

def backlog
  get_stat(:backlog)
end

#booted_workersObject



15
16
17
# File 'lib/tpt/rails/puma_stats_collector.rb', line 15

def booted_workers
  @stats.fetch(:booted_workers, 1)
end

#clustered?Boolean

Returns:

  • (Boolean)


7
8
9
# File 'lib/tpt/rails/puma_stats_collector.rb', line 7

def clustered?
  @stats.has_key?(:workers)
end

#max_threadsObject



31
32
33
# File 'lib/tpt/rails/puma_stats_collector.rb', line 31

def max_threads
  get_stat(:max_threads)
end

#pool_capacityObject



27
28
29
# File 'lib/tpt/rails/puma_stats_collector.rb', line 27

def pool_capacity
  get_stat(:pool_capacity)
end

#runningObject



19
20
21
# File 'lib/tpt/rails/puma_stats_collector.rb', line 19

def running
  get_stat(:running)
end

#to_sObject



35
36
37
38
39
40
41
42
43
44
# File 'lib/tpt/rails/puma_stats_collector.rb', line 35

def to_s
  {
    workers: workers,
    booted_workers: booted_workers,
    running: running,
    backlog: backlog,
    pool_capacity: pool_capacity,
    max_threads: max_threads
  }.to_json
end

#workersObject



11
12
13
# File 'lib/tpt/rails/puma_stats_collector.rb', line 11

def workers
  @stats.fetch(:workers, 1)
end