-
Notifications
You must be signed in to change notification settings - Fork 22k
Silence healthcheck requests from the log #52789
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
Conversation
Thanks to @skipkayhil for reminding me of Propshaft::QuietAssets which does something very similar and does it just via env!
Co-authored-by: Hartley McGuire <skipkayhil@gmail.com>
@@ -196,10 +196,10 @@ def app | |||
assert_includes middleware, "ActionDispatch::AssumeSSL" | |||
end | |||
|
|||
test "ActionDispatch::SSL is present when force_ssl is set" do |
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.
@dhh did you mean to delete this test?
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.
I did not. Not sure what happened there. Please do PR to restore!
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.
Will this ship in Rails 8, or in an earlier point release? |
|
@dhh how do you feel abstracting this to a |
@cristianbica Are any of those examples you mention problems you've actually hit in production? At what intervals are those requests running? I don't want to blanket rule out making this more generic, but I find that you're better off with something specific, unless you've proven without a doubt the need for something generic. |
@dhh In our app we have an async request for red dot / badge counts that happens on most page loads. I recently wrote a very similar middleware to filter those out of the development logs as I got bored of scrolling back up the tail past the badge request to see details of the main request. Having something configurable like @cristianbica is suggesting, and being able to be different in different environments would certainly have been great for our real use case. |
@dhh on my current projects I do not have a valid use-case to prove the need to generalize this functionality. In the past projects I've implemented different solution to reduce logging (e.g. silencer gem for requests). The purpose was to reduce clutter in the logs and reduce costs. From what I remember:
Anyway, looking at the implementation in this PR, one could easy filter out logging for other paths by adding to config.middleware.insert_before ::Rails::Rack::Logger, :Rails::Rack::SilenceRequest, path: '/sidekiq_stats' |
* Add SilenceRequest middleware * Make config.silence_healthcheck a way to quiet "/up"
@dhh With thruster gem included by default, the "/up" requests are showing up in the logs anyway. Is there any way to silence that as well, as I don't see such possibility in thruster project yet? |
The default Rails health check is intended to be hit every second or so by Kamal to ensure that the application is still or has just become responsive. This clutters up the production logs and makes it hard to follow what's actually going on. This adds a new middleware called
Rails::Rack::SilenceRequest
that is used by a new configconfig.silence_healthcheck = path
to prevent that.