Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions lib/puma/app/status.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
require 'json'

module Puma
module App
class Status
Expand Down Expand Up @@ -60,8 +62,7 @@ def call(env)
return rack_response(200, OK_STATUS)

when /\/gc-stats$/
json = "{" + GC.stat.map { |k, v| "\"#{k}\": #{v}" }.join(",") + "}"
return rack_response(200, json)
return rack_response(200, GC.stat.to_json)

when /\/stats$/
return rack_response(200, @cli.stats)
Expand Down
8 changes: 2 additions & 6 deletions test/test_cli.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
require_relative "helper"

require "puma/cli"
require "json"

class TestCLI < Minitest::Test
def setup
Expand Down Expand Up @@ -195,12 +196,7 @@ def control_gc_stats(uri, cntl)

lines = body.split("\r\n")
json_line = lines.detect { |l| l[0] == "{" }
pairs = json_line.scan(/\"[^\"]+\": [^,]+/)
gc_stats = {}
pairs.each do |p|
p =~ /\"([^\"]+)\": ([^,]+)/ || raise("Can't parse #{p.inspect}!")
gc_stats[$1] = $2
end
gc_stats = JSON.parse(json_line)
gc_count_after = gc_stats["count"].to_i

# Hitting the /gc route should increment the count by 1
Expand Down