solid_queue icon indicating copy to clipboard operation
solid_queue copied to clipboard

option for silencing logging for heartbeats

Open jlvallelonga opened this issue 1 year ago • 5 comments

In development, and possible other environments, it's sometimes nice to not see the heartbeat logging. This adds an option to silence the logging for heartbeats. It's very similar to the "silence_polling" option.

Usage:

  config.solid_queue.silence_heartbeats = true

jlvallelonga avatar Oct 18 '24 05:10 jlvallelonga

Thanks @jlvallelonga! However, I was hoping we could get https://github.com/rails/solid_queue/issues/210 done instead of having a bunch of different options to silence different parts 😅

rosa avatar Nov 13 '24 15:11 rosa

Yeah I was thinking about that a bit when I was doing this. Makes sense :)

jlvallelonga avatar Nov 15 '24 00:11 jlvallelonga

For me, silence_polling and silence_heartbeat_logging address different concerns. In that sense, we can keep them as two separate settings. Any chance we can merge this? @rosa

madhums avatar Apr 19 '25 09:04 madhums

In the meantime, I've monkeypatched this PR:

# /config/initializers/solid_queue.rb

module SilenceHeartbeat
  def heartbeat
    ActiveRecord::Base.logger.silence do
      # Clear any previous changes before locking, for example, in case a previous heartbeat
      # failed because of a DB issue (with SQLite depending on configuration, a BusyException
      # is not rare) and we still have the unpersisted value
      restore_attributes
      with_lock { touch(:last_heartbeat_at) }
    end
  end
end

Rails.application.config.to_prepare do
  SolidQueue::Process.prepend(SilenceHeartbeat) unless Rails.env.production?
end

Many tnx @jlvallelonga

jbescoyez avatar Apr 21 '25 06:04 jbescoyez

That work's great Jean-Baptiste to silence the heartbeat logging that happens every minute.

You can also significantly reduce the 5-minute "Prune dead processes" logs by adding to config/environments/development.rb something like

config.solid_queue.process_alive_threshold = 1.day

But I've found that bad things happen if you try to get rid if the 10-minute "Unblock jobs" logging by any setting of concurrency_maintenance_interval in config/queue.yml.

mrj avatar Apr 30 '25 21:04 mrj