Class: Honeybadger::PumaPlugin
Constant Summary
collapse
- STATS_KEYS =
%i[pool_capacity max_threads requests_count backlog running].freeze
Instance Method Summary
collapse
#decrement_counter, #extract_attributes, #extract_callable, #gauge, #histogram, #increment_counter, #metric_agent, #metric_attributes, #metric_instrumentation, #metric_source, #monotonic_timer, #time
Instance Method Details
#record ⇒ Object
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
# File 'lib/puma/plugin/honeybadger.rb', line 21
def record
metric_source "puma"
stats = begin
::Puma.stats
rescue
{}
end
stats = stats.is_a?(Hash) ? stats : JSON.parse(stats, symbolize_names: true)
if stats[:worker_status].is_a?(Array)
stats[:worker_status].each do |worker_data|
context = {worker: worker_data[:index]}
record_puma_stats(worker_data[:last_status], context)
end
else
record_puma_stats(stats)
end
end
|
#record_puma_stats(stats, context = {}) ⇒ Object
41
42
43
44
45
46
47
48
49
50
51
|
# File 'lib/puma/plugin/honeybadger.rb', line 41
def record_puma_stats(stats, context = {})
if Honeybadger.config.load_plugin_insights?(:puma, feature: :events)
Honeybadger.event("stats.puma", context.merge(stats))
end
if Honeybadger.config.load_plugin_insights?(:puma, feature: :metrics)
STATS_KEYS.each do |stat|
gauge stat, context, -> { stats[stat] } if stats[stat]
end
end
end
|