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

Add Pitchfork/Raindrops middleware #66

Merged
merged 7 commits into from
Aug 20, 2024
Merged

Conversation

robertomiranda
Copy link
Collaborator

@robertomiranda robertomiranda commented Aug 16, 2024

Add Pitchfork/Raindrops middleware. This PR depends on the changes made in #63. However, it removes the Periodic Stats class introduced previously, considering the feedback on the previous PR. We can periodically collect metrics, relying on the health checks performed on the Rails application.

Note: I'm not testing the changes made to Railties because they are too complex and add little value. Instead, I'm proposing to ignore it

Promenade::Raindrops::Middleware

The Promenade::Raindrops::Middleware middleware collects and reports metrics fromPromenade::Raindrops::Stats. The Promenade::Raindrops::Stats exposes active workers and queued requests in servers like Rainbows, Unicorn, and Pitchfork using Prometheus gauges. It initializes by obtaining TCP listener stats from Raindrops::Linux, setting the listener address, and fetching active worker and queued request counts. The instrument method updates the Prometheus gauges with these values, and the class method self.instrument allows easy instrumentation with an optional listener address.

Promenade::Raindrops::Stats.instrument(listener_address: name)
end
  • rack_active_workers: Number of active workers in the Application Server
  • rack_queued_requests: Number of requests waiting to be processed by the Application Server

Promenade::Pitchfork::Middleware

The Promenade::Pitchfork::Middleware class collects and reports metrics using the Promenade::Pitchfork::Stats class. The Promenade::Pitchfork::Stats exports the Pitchfork worker processes using Prometheus gauges. It tracks the total, live, idle, and busy worker counts. The class retrieves these metrics using Pitchfork::Info and Raindrops::Stats, and updates the Prometheus gauges accordingly.

Promenade::Pitchfork::Stats.instrument
  • 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.

robertomiranda and others added 6 commits August 16, 2024 11:06
Add listener_address as Instance attributes of Promenade::Raindrops::Stats

Fix guard clauses

💇‍♀️

Update dev dependencies

Update Bundler version
I think the complexity in the setup method is unavoidable,
and trying to factor this logic into another method doesn't improve
anything.

The assignment in if conditions stuff is a bit suspect, but I don't
really mind it ...
Add listener_address as Instance attributes of Promenade::Raindrops::Stats

Fix guard clauses

💇‍♀️

Update dev dependencies

Update Bundler version
@robertomiranda robertomiranda force-pushed the r/pitchfork-middleware branch 4 times, most recently from 4037942 to 590395e Compare August 16, 2024 11:45
Remove Periodic Stats

Fix rebase

Ignore railties

add codecove yml path

Remove unused settings

Ignore Railtie from codecove

Update codecove

Add Codecov yml path

Ignore railtie with Simplecov
Repository owner deleted a comment from codecov bot Aug 19, 2024
Copy link

codecov bot commented Aug 19, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 100.00%. Comparing base (328463b) to head (426a6f3).
Report is 2 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff            @@
##            master       #66   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           34        37    +3     
  Lines          761       833   +72     
=========================================
+ Hits           761       833   +72     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@robertomiranda robertomiranda marked this pull request as ready for review August 19, 2024 14:38
@robertomiranda robertomiranda changed the base branch from r/pitchork-stats to master August 19, 2024 15:57
@robertomiranda robertomiranda merged commit d663938 into master Aug 20, 2024
5 checks passed
@robertomiranda robertomiranda deleted the r/pitchfork-middleware branch August 20, 2024 07:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants