Skip to content

Commit

Permalink
Revert api change from #2086 introduce Puma.stats_hash api
Browse files Browse the repository at this point in the history
The change in #2086 is not backwards compatible with existing gems that parse the output of Puma.stats such as barnes.

Releasing a version of puma with this change would break anyone using the Barnes app and only in production. I'm proposing to keep the existing interface and instead add a new API. This buys us all the features of #2086 without causing any production facing downtime by customers due to API incompatibilities.

Unfortunately it requires that we serialize and the de-serialize the values. One prior benefit of returning json in a string was that it allowed an end user to de-serialize using a faster json algorithm such as `oj` via the "multi json" gem. But the performance penalty will be better than a stability break.
  • Loading branch information
schneems committed May 8, 2020
1 parent 6234e4b commit 5b21b2b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion History.md
Expand Up @@ -13,7 +13,7 @@
* New configuration option to set state file permissions (#2238)

* Deprecations, Removals and Breaking API Changes
* `Puma.stats` now returns a Hash instead of a JSON string (#2086)
* `Puma.stats_hash` returns a Hash version of the stats (#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
6 changes: 5 additions & 1 deletion lib/puma.rb
Expand Up @@ -20,7 +20,11 @@ def self.stats_object=(val)
end

def self.stats
@get_stats.stats
@get_stats.stats.to_json
end

def self.stats_hash
@get_stats.stats.to_json
end

# Thread name is new in Ruby 2.3
Expand Down

0 comments on commit 5b21b2b

Please sign in to comment.