Skip to content

option for silencing logging for heartbeats #389

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

jlvallelonga
Copy link

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

@rosa
Copy link
Member

rosa commented Nov 13, 2024

Thanks @jlvallelonga! However, I was hoping we could get #210 done instead of having a bunch of different options to silence different parts 😅

@jlvallelonga
Copy link
Author

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

@madhums
Copy link

madhums commented Apr 19, 2025

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

@jbescoyez
Copy link

jbescoyez commented Apr 21, 2025

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

And it woks like a charm with this logging config in development.rb:

logger = ActiveSupport::Logger.new(STDOUT)

config.logger = logger
config.solid_queue.logger = logger

Many tnx @jlvallelonga

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.

4 participants