Class: AppsignalPumaPlugin Private

Inherits:
Object show all
Defined in:
lib/puma/plugin/appsignal.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

AppsignalPumaPlugin

Class to handle the logic of translating the Puma stats to AppSignal metrics.

Defined Under Namespace

Classes: Statsd

Instance Method Summary collapse

Constructor Details

#initializeAppsignalPumaPlugin

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of AppsignalPumaPlugin.



81
82
83
84
# File 'lib/puma/plugin/appsignal.rb', line 81

def initialize
  @hostname = fetch_hostname
  @statsd = Statsd.new
end

Instance Method Details

#call(stats) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
# File 'lib/puma/plugin/appsignal.rb', line 86

def call(stats)
  counts = {}
  count_keys = [:backlog, :running, :pool_capacity, :max_threads]

  if stats[:worker_status] # Clustered mode - Multiple workers
    stats[:worker_status].each do |worker|
      stat = worker[:last_status]
      count_keys.each do |key|
        count_if_present counts, key, stat
      end
    end

    gauge(:workers, stats[:workers], :type => :count)
    gauge(:workers, stats[:booted_workers], :type => :booted)
    gauge(:workers, stats[:old_workers], :type => :old)
  else # Single mode - Single worker
    count_keys.each do |key|
      count_if_present counts, key, stats
    end
  end

  gauge(:connection_backlog, counts[:backlog]) if counts[:backlog]
  gauge(:pool_capacity, counts[:pool_capacity]) if counts[:pool_capacity]
  gauge(:threads, counts[:running], :type => :running) if counts[:running]
  gauge(:threads, counts[:max_threads], :type => :max) if counts[:max_threads]
end