harmjanblok / puma-metrics Goto Github PK
View Code? Open in Web Editor NEWPuma plugin to export puma stats as prometheus metrics
License: MIT License
Puma plugin to export puma stats as prometheus metrics
License: MIT License
Hello
First of all, thanks for the great gem.
There seem to be compatibility issues with the latest version of the gem (1.2.5) and the latest version of puma (6.0.0).
Gemfile.lock:
puma (6.0.0)
nio4r (~> 2.0)
puma-metrics (1.2.5)
prometheus-client (>= 0.10)
puma (>= 5.0)
config/puma.rb:
...
# Allow puma to be restarted by `bin/rails restart` command.
plugin :tmp_restart
plugin 'metrics'
Attempt to start the rails server / puma (rails s
):
severin@ws:~/dev/HelloWorld$ rails s
=> Booting Puma
=> Rails 7.0.4 application starting in development
=> Run `bin/rails server --help` for more startup options
Exiting
/home/severin/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/puma-metrics-1.2.5/lib/puma/plugin/metrics.rb:16:in `start': undefined method `min_threads=' for #<Puma::Server:0x00007feb3ee15c40...
metrics.min_threads = 0
^^^^^^^^^^^^^^
Did you mean? min_threads
max_threads
from /home/severin/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/puma-6.0.0/lib/puma/plugin.rb:24:in `block in fire_starts'
from /home/severin/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/puma-6.0.0/lib/puma/plugin.rb:22:in `each'
from /home/severin/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/puma-6.0.0/lib/puma/plugin.rb:22:in `fire_starts'
from /home/severin/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/puma-6.0.0/lib/puma/launcher.rb:179:in `run'
from /home/severin/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/puma-6.0.0/lib/rack/handler/puma.rb:72:in `run'
from /home/severin/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/rack-2.2.4/lib/rack/server.rb:327:in `start'
from /home/severin/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/railties-7.0.4/lib/rails/commands/server/server_command.rb:38:in `start'
from /home/severin/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/railties-7.0.4/lib/rails/commands/server/server_command.rb:143:in `block in perform'
from <internal:kernel>:90:in `tap'
from /home/severin/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/railties-7.0.4/lib/rails/commands/server/server_command.rb:134:in `perform'
from /home/severin/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/thor-1.2.1/lib/thor/command.rb:27:in `run'
from /home/severin/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/thor-1.2.1/lib/thor/invocation.rb:127:in `invoke_command'
from /home/severin/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/thor-1.2.1/lib/thor.rb:392:in `dispatch'
from /home/severin/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/railties-7.0.4/lib/rails/command/base.rb:87:in `perform'
from /home/severin/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/railties-7.0.4/lib/rails/command.rb:48:in `invoke'
from /home/severin/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/railties-7.0.4/lib/rails/commands.rb:18:in `<main>'
from /home/severin/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/bootsnap-1.13.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require'
from /home/severin/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/bootsnap-1.13.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require'
from bin/rails:4:in `<main>'
See details about the Puma 6 upgrade: https://github.com/puma/puma/blob/master/6.0-Upgrade.md#upgrade
- We've removed the following public methods on Puma::Server: Puma::Server#min_threads, Puma::Server#max_threads. Instead, you can pass in configuration as an option to Puma::Server#new. This might make certain gems break (capybara for example).
Why is the request count metric a gauge? Shouldn't it be a counter? I don't understand how a sum of all the requests over time is useful?
Thanks for building this gem BTW! I found it frustrating that the prometheus-client
couldn't listen on a different port, this gem hits that itch!
I'm trying to use puma-metrics
in an app where I'm already using prometheus-client 1.0.0
, but it's currently not possible, due to the dependency:
spec.add_runtime_dependency 'prometheus-client', '~> 0.10'
Can that dependency be relaxed?
This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.
These updates have all been created already. Click a checkbox below to force a retry/rebase of any.
Gemfile
bundler '>= 2.0.0'
minitest undefined
overcommit undefined
rake undefined
rubocop undefined
.github/workflows/workflow.yml
Puma 5 is our and a few changes are made relevant to this gem:
requests_count
that would be nice to expose as a Prometheus metric.Hey, thanks for this very useful plugin.
We are experiencing a bug during deployments. It appears that metrics endpoint is served earlier than the rest of the application. This leads to:
NoMethodError: undefined method `stats' for nil:NilClass` exception.
Software versions: puma (6.3.1), puma-metrics (1.3.0)
Stacktrace:
NoMethodError: undefined method `stats' for nil:NilClass (NoMethodError)
}.merge(@server.stats).merge(super)
^^^^^^
from puma/single.rb:20:in `stats'
from puma/launcher.rb:115:in `stats'
from puma/metrics/app.rb:26:in `retrieve_and_parse_stats!'
from puma/metrics/app.rb:17:in `call'
from puma/request.rb:100:in `block in handle_request'
from puma/thread_pool.rb:344:in `with_force_shutdown'
from puma/request.rb:99:in `handle_request'
from puma/server.rb:443:in `process_client'
from puma/server.rb:245:in `block in run'
from puma/thread_pool.rb:151:in `block in spawn_thread'
I am not exactly sure how this can be fixed, should Puma check if @server
is nil
before invoking merge
:
class Single < Runner
# @!attribute [r] stats
def stats
{
started_at: utc_iso8601(@started_at)
}.merge(@server.stats).merge(super)
end
or should the metrics plugin check some status on @launcher
before invoking stats
.
def retrieve_and_parse_stats!
puma_stats = @launcher.stats
Related code:
Prometheus support authentication of the metrics endpoint, is this something this gem could support?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.