-
Notifications
You must be signed in to change notification settings - Fork 5
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
Add Promenade::PeriodicStats for Periodical Stats Instrumentation #63
Conversation
cb491a5
to
54f74be
Compare
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #63 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 34 37 +3
Lines 761 855 +94
=========================================
+ Hits 761 855 +94 ☔ View full report in Codecov by Sentry. |
60affe2
to
eea9a95
Compare
073e180
to
813cc92
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems fine to me.
It's a bit of a weird design, but that is basically forced on us by the decision we took to have the exporter endpoint running in a separate sidecar process...
The downside of this is:
e.g. prometheus is scraping every 30 seconds, we have to decide how often to update the metrics in the PeriodicStats, if we choose 30s too, then the stats could be 29 seconds out of date ... and sometimes we could just scrape the same data twice if things line up wrongly, clearly every second is a bit wasteful (especially if the stats thing we are calling is expensive)
If the stats method we are calling is lightweight enough, we could just add it to rack.after_reply
like I did with the yjit instrumentation... https://github.com/errm/promenade/blob/master/lib/promenade/yjit/middleware.rb
- If pitchfork supports that 🤷
Add listener_address as Instance attributes of Promenade::Raindrops::Stats Fix guard clauses 💇♀️ Update dev dependencies Update Bundler version
closed by #66 |
Promenade::PeriodicStats
This PR introduces the use of Promenade::PeriodicStats to configure and start an infinite loop that periodically instruments statistical data. The configuration sets the frequency at which the stats are collected and logged, specifically for
Promenade::Pitchfork::Stats and Promenade::Raindrops::Stats
.Depends on #62
The
Promenade::PeriodicStats
is configured with a specified frequency (in seconds) and a logger (Rails.logger).This PR introduces instrumentation for preforking Rack servers like Unicorn and Pitchfork, and also introduces metrics for Pitchfork leveraging
Pitchfork::Info
.Promenade::Raindrops::Stats
The
Promenade::Raindrops::Stats
class collects and reports metrics on active workers and queued requests in servers like Rainbows, Unicorn, and Pitchfork using Prometheus gauges. It initializes by obtaining TCP listener stats fromRaindrops::Linux
, setting the listener address, and fetching active worker and queued request counts. Theinstrument
method updates the Prometheus gauges with these values, and the class methodself.instrument
allows easy instrumentation with an optional listener address.rack_active_workers
: Number of active workers in the Application Serverrack_queued_requests
: Number of requests waiting to be processed by the Application ServerPromenade::Pitchfork::Stats
The
Promenade::Pitchfork::Stats
class collects and reports metrics on Pitchfork worker processes using Prometheus gauges. It tracks the total, live, idle, and busy worker counts. The class retrieves these metrics usingPitchfork::Info
andRaindrops::Stats
, and updates the Prometheus gauges accordingly.pitchfork_workers_count
: Total number of configured workers.pitchfork_live_workers_count
: Number of live (booted) workers.pitchfork_capacity
: Number of idle workers.pitchfork_busy_percent
: Percentage of busy workers.