-
Notifications
You must be signed in to change notification settings - Fork 6
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
Fix gauge aggregation #6
Fix gauge aggregation #6
Conversation
In prometheus-client-mmap, Prometheus::Client::Registry#gauge has a fourth parameter "multiprocess_mode" which handles the aggregation. See * https://gitlab.com/gitlab-org/ruby/gems/prometheus-client-mmap/-/blob/v0.17.0/lib/prometheus/client/registry.rb#L43 * https://gitlab.com/gitlab-org/ruby/gems/prometheus-client-mmap/-/blob/v0.17.0/lib/prometheus/client/gauge.rb#L12
@Envek ? |
Hey, thanks a lot for the pull request and sorry for long reply. The problem I can see here is that Most probably we will need to map existing values ( |
@Envek use case for us is switching to https://github.com/Shopify/pitchfork (from Puma) and we need to provide our own stats: Yabeda.configure do
group :pitchfork do
gauge :workers, aggregation: :max, comment: 'Number of pitchfork workers'
gauge :active_workers, aggregation: :max, comment: 'Number of active pitchfork workers'
gauge :request_backlog, aggregation: :max, comment: 'Number of requests waiting to be processed by a pitchfork worker'
end
collect do
if defined?(Raindrops::Linux.tcp_listener_stats)
if listener_address = Pitchfork.listener_names.first
stats = Raindrops::Linux.tcp_listener_stats([listener_address])[listener_address]
pitchfork.active_workers.set({}, stats.active)
pitchfork.request_backlog.set({}, stats.queued)
end
pitchfork.workers.set({}, File.read("/proc/#{Process.ppid}/task/#{Process.ppid}/children").split.count - 1) if Process.ppid > 0
end
end
end Problem is this results in something like this:
So instead of just 29 we have 174 |
* master: Upgrade CI rubies, upgrade Rubocop and move it to separate CI job Enhance Compatibility with Rack 3 and Maintain Support for Rack 2 (yabeda-rb#8)
Sorry for the late reply and thanks for heads up. Merged and released in 0.4.0. Enjoy! |
I noticed that the
aggregation
-parameter for gauges did nothing in a multi-process setting (thepid
-attribute was still present). This PR should fix that.