class Puma::Metrics::App
Public Class Methods
new(launcher)
click to toggle source
# File lib/puma/metrics/app.rb, line 10 def initialize(launcher) @launcher = launcher clustered = (@launcher.options[:workers] || 0) > 0 @parser = Parser.new(clustered: clustered) end
Public Instance Methods
call(_env)
click to toggle source
# File lib/puma/metrics/app.rb, line 16 def call(_env) retrieve_and_parse_stats! [ 200, { 'Content-Type' => 'text/plain' }, [Prometheus::Client::Formats::Text.marshal(Prometheus::Client.registry)] ] end
retrieve_and_parse_stats!()
click to toggle source
# File lib/puma/metrics/app.rb, line 25 def retrieve_and_parse_stats! puma_stats = @launcher.stats if puma_stats.is_a?(Hash) # Modern Puma outputs stats as a Symbol-keyed Hash @parser.parse(puma_stats) else @parser.parse(JSON.parse(puma_stats, symbolize_names: true)) end end