Class: Puma::Metrics::App
- Inherits:
-
Object
- Object
- Puma::Metrics::App
- Defined in:
- lib/puma/metrics/app.rb
Instance Method Summary collapse
- #call(_env) ⇒ Object
-
#initialize(launcher) ⇒ App
constructor
A new instance of App.
- #retrieve_and_parse_stats! ⇒ Object
Constructor Details
Instance Method Details
#call(_env) ⇒ Object
16 17 18 19 20 21 22 23 |
# 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! ⇒ Object
25 26 27 28 29 30 31 32 |
# 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 |