Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert api change from #2086 introduce Puma.stats_hash api #2253

Merged
merged 2 commits into from May 11, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion History.md
Expand Up @@ -11,9 +11,9 @@
* Force shutdown responses can be overridden by using the `lowlevel_error_handler` config (#2203)
* Faster phased restart and worker timeout (#2121)
* New configuration option to set state file permissions (#2238)
* `Puma.stats_hash` returns a stats in Hash instead of a JSON string (#2086, #2253)

* Deprecations, Removals and Breaking API Changes
* `Puma.stats` now returns a Hash instead of a JSON string (#2086)
* `--control` has been removed. Use `--control-url` (#1487)
* `worker_directory` has been removed. Use `directory`.
* min_threads now set by environment variables PUMA_MIN_THREADS and MIN_THREADS. (#2143)
Expand Down
4 changes: 4 additions & 0 deletions lib/puma.rb
Expand Up @@ -20,6 +20,10 @@ def self.stats_object=(val)
end

def self.stats
@get_stats.stats.to_json
end

def self.stats_hash
@get_stats.stats
end

Expand Down
4 changes: 2 additions & 2 deletions puma.gemspec
Expand Up @@ -18,7 +18,7 @@ Gem::Specification.new do |s|
s.files = `git ls-files -- bin docs ext lib tools`.split("\n") +
%w[History.md LICENSE README.md]
s.homepage = "http://puma.io"

if s.respond_to?(:metadata=)
s.metadata = {
"bug_tracker_uri" => "https://github.com/puma/puma/issues",
Expand All @@ -27,7 +27,7 @@ Gem::Specification.new do |s|
"source_code_uri" => "https://github.com/puma/puma"
}
end

s.license = "BSD-3-Clause"
s.required_ruby_version = Gem::Requirement.new(">= 2.2")
end
2 changes: 2 additions & 0 deletions test/test_cli.rb
Expand Up @@ -55,6 +55,8 @@ def test_control_for_tcp
body = s.read
s.close

assert_equal Puma.stats_hash, JSON.parse(Puma.stats, symbolize_names: true)

dmt = Puma::Configuration.new.default_max_threads
assert_match(/{"started_at":"\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}Z","backlog":0,"running":0,"pool_capacity":#{dmt},"max_threads":#{dmt},"requests_count":0}/, body.split(/\r?\n/).last)

Expand Down
4 changes: 1 addition & 3 deletions test/test_integration_cluster.rb
Expand Up @@ -162,9 +162,7 @@ def worker_timeout(timeout, iterations, config)

pids = []
Timeout.timeout(iterations * timeout + 1) do
while pids.size < WORKERS * iterations
(pids << @server.gets[/Terminating timed out worker: (\d+)/, 1]).compact!
end
(pids << @server.gets[/Terminating timed out worker: (\d+)/, 1]).compact! while pids.size < WORKERS * iterations
pids.map!(&:to_i)
end

Expand Down
4 changes: 2 additions & 2 deletions test/test_launcher.rb
Expand Up @@ -139,7 +139,7 @@ def test_puma_stats
launcher.events.on_booted {launcher.stop}
launcher.run
Puma::Server::STAT_METHODS.each do |stat|
assert_includes Puma.stats, stat
assert_includes Puma.stats_hash, stat
end
end

Expand All @@ -154,7 +154,7 @@ def test_puma_stats_clustered
launcher = launcher(conf)
Thread.new do
sleep Puma::Const::WORKER_CHECK_INTERVAL + 1
status = Puma.stats[:worker_status].first[:last_status]
status = Puma.stats_hash[:worker_status].first[:last_status]
Puma::Server::STAT_METHODS.each do |stat|
assert_includes status, stat
end
Expand Down