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
|
# File 'lib/puma/plugin/honeybadger.rb', line 21
def record
metric_source 'puma'
stats = ::Puma.stats rescue {}
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
37
38
39
40
41
42
43
44
45
46
47
|
# File 'lib/puma/plugin/honeybadger.rb', line 37
def record_puma_stats(stats, context={})
if Honeybadger.config.load_plugin_insights_events?(:puma)
Honeybadger.event('stats.puma', context.merge(stats))
end
if Honeybadger.config.load_plugin_insights_metrics?(:puma)
STATS_KEYS.each do |stat|
gauge stat, context, ->{ stats[stat] } if stats[stat]
end
end
end
|