Skip to content

Commit

Permalink
fix: Gracefully fail when JUDOSCALE_URL is a blank string
Browse files Browse the repository at this point in the history
  • Loading branch information
adamlogic committed Oct 12, 2023
1 parent 050e7b7 commit ca565d3
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion judoscale-ruby/lib/judoscale/reporter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def self.start(config = Config.instance, adapters = Judoscale.adapters)
def start!(config, adapters)
@pid = Process.pid

if !config.api_base_url
if config.api_base_url.nil? || config.api_base_url.strip.empty?
logger.debug "Set api_base_url to enable metrics reporting"
return
end
Expand Down
10 changes: 10 additions & 0 deletions judoscale-ruby/test/reporter_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,16 @@ def stub_reporter_loop
_(log_string).must_include "Set api_base_url to enable metrics reporting"
end

it "does not run the reporter thread when the API url is a blank string" do
Judoscale.configure { |config| config.api_base_url = " " }

Reporter.instance.stub(:run_loop, ->(*) { raise "SHOULD NOT BE CALLED" }) {
Reporter.instance.start!(Config.instance, Judoscale.adapters)
}

_(log_string).must_include "Set api_base_url to enable metrics reporting"
end

it "does not run the reporter thread when there are no metrics collectors" do
Reporter.instance.stub(:run_loop, ->(*) { raise "SHOULD NOT BE CALLED" }) {
Reporter.instance.start!(Config.instance, Judoscale.adapters.select { |a| a.metrics_collector.nil? })
Expand Down

0 comments on commit ca565d3

Please sign in to comment.