Class: Upfluence::Instrumentation::PumaInstrumenter

Inherits:
PeriodicInstrumenter show all
Defined in:
lib/upfluence/instrumentation/puma_instrumenter.rb

Constant Summary collapse

KEYS =
i[backlog_thread running_thread pool_capacity requests_count].freeze

Instance Method Summary collapse

Methods inherited from PeriodicInstrumenter

#initialize, #start, #stop

Constructor Details

This class inherits a constructor from Upfluence::Instrumentation::PeriodicInstrumenter

Instance Method Details

#metricsObject



13
14
15
16
17
# File 'lib/upfluence/instrumentation/puma_instrumenter.rb', line 13

def metrics
  KEYS.reduce({}) do |acc, k|
    acc.merge(k => { docstring: "Gauge for #{k}" })
  end
end

#prefixObject



9
10
11
# File 'lib/upfluence/instrumentation/puma_instrumenter.rb', line 9

def prefix
  'puma'
end

#valuesObject



19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/upfluence/instrumentation/puma_instrumenter.rb', line 19

def values
  stats = Puma.stats_hash

  {
    requests_count: [{ value: stats[:requests_count] }],
    backlog_thread: [{ value: stats[:backlog] }],
    running_thread: [{ value: stats[:running] }],
    pool_capacity:  [{ value: stats[:pool_capacity] }]
  }
rescue NoMethodError
  {}
end