Skip to content

Commit

Permalink
fix: Allow customizing the rake task regex to avoid starting the repo…
Browse files Browse the repository at this point in the history
…rter
  • Loading branch information
adamlogic committed Oct 10, 2024
1 parent 111830b commit 8f36030
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion judoscale-rails/lib/judoscale/rails/railtie.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def judoscale_config
config.after_initialize do
if in_rails_console_or_runner?
logger.debug "No reporting since we're in a Rails console or runner process"
elsif in_rake_task?(/assets:|db:/)
elsif in_rake_task?(judoscale_config.rake_task_ignore_regex)
logger.debug "No reporting since we're in a build process"
elsif judoscale_config.start_reporter_after_initialize
Reporter.start
Expand Down
3 changes: 2 additions & 1 deletion judoscale-ruby/lib/judoscale/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def self.expose_adapter_config(config_instance)
end
end

attr_accessor :api_base_url, :report_interval_seconds,
attr_accessor :api_base_url, :report_interval_seconds, :rake_task_ignore_regex,
:max_request_size_bytes, :logger, :log_tag, :current_runtime_container
attr_reader :log_level

Expand All @@ -87,6 +87,7 @@ def reset
@log_tag = "Judoscale"
@max_request_size_bytes = 100_000 # ignore request payloads over 100k since they skew the queue times
@report_interval_seconds = 10
@rake_task_ignore_regex = /assets:|db:/

self.log_level = ENV["JUDOSCALE_LOG_LEVEL"] || ENV["RAILS_AUTOSCALE_LOG_LEVEL"]
@logger = ::Logger.new($stdout)
Expand Down
1 change: 1 addition & 0 deletions sample-apps/rails-sample/config/initializers/judoscale.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@
Judoscale.configure do |config|
# Open https://judoscale-adapter-mock.requestcatcher.com in a browser to monitor requests
config.api_base_url = ENV["JUDOSCALE_URL"] || "https://judoscale-adapter-mock.requestcatcher.com"
config.rake_task_ignore_regex = /assets:|db:|middleware/
# config.start_reporter_after_initialize = false
end

0 comments on commit 8f36030

Please sign in to comment.