newrelic / newrelic-ruby-agent

New Relic RPM Ruby Agent
https://docs.newrelic.com/docs/apm/agents/ruby-agent/getting-started/introduction-new-relic-ruby/
Apache License 2.0
1.2k stars 598 forks source link

Quieten "Agent unavailable as it hasn't been started" warnings #2972

Closed jdelStrother closed 2 days ago

jdelStrother commented 4 days ago

Is your feature request related to a problem? Please describe.

We have NewRelic::Agent.ignore_error_filter(...) in config/initializers/newrelic.rb . This results in a noisy warning from newrelic:

** [NewRelic][2024-11-25 16:41:07 +0000 M1MBP.local (18228)] WARN : Agent unavailable as it hasn't been started.
** [NewRelic][2024-11-25 16:41:07 +0000 M1MBP.local (18228)] WARN : /Users/jon/Developer/web/vendor/bundle/nix-bundle/ruby/3.2.0/gems/newrelic_rpm-9.16.0/lib/new_relic/supportability_helper.rb:68:in `record_api_supportability_metric'
/Users/jon/Developer/web/vendor/bundle/nix-bundle/ruby/3.2.0/gems/newrelic_rpm-9.16.0/lib/new_relic/agent.rb:366:in `ignore_error_filter'
/Users/jon/Developer/web/config/initializers/newrelic.rb:14:in `<main>'
/Users/jon/Developer/web/vendor/bundle/nix-bundle/ruby/3.2.0/gems/railties-7.2.2/lib/rails/engine.rb:689:in `load'
/Users/jon/Developer/web/vendor/bundle/nix-bundle/ruby/3.2.0/gems/railties-7.2.2/lib/rails/engine.rb:689:in `block in load_config_initializer'
/Users/jon/Developer/web/vendor/bundle/nix-bundle/ruby/3.2.0/gems/activesupport-7.2.2/lib/active_support/notifications.rb:212:in `instrument'
/Users/jon/Developer/web/vendor/bundle/nix-bundle/ruby/3.2.0/gems/railties-7.2.2/lib/rails/engine.rb:688:in `load_config_initializer'
/Users/jon/Developer/web/vendor/bundle/nix-bundle/ruby/3.2.0/gems/railties-7.2.2/lib/rails/engine.rb:642:in `block (2 levels) in <class:Engine>'
/Users/jon/Developer/web/vendor/bundle/nix-bundle/ruby/3.2.0/gems/railties-7.2.2/lib/rails/engine.rb:641:in `each'
/Users/jon/Developer/web/vendor/bundle/nix-bundle/ruby/3.2.0/gems/railties-7.2.2/lib/rails/engine.rb:641:in `block in <class:Engine>'
/Users/jon/Developer/web/vendor/bundle/nix-bundle/ruby/3.2.0/gems/railties-7.2.2/lib/rails/initializable.rb:32:in `instance_exec'
/Users/jon/Developer/web/vendor/bundle/nix-bundle/ruby/3.2.0/gems/railties-7.2.2/lib/rails/initializable.rb:32:in `run'
/Users/jon/Developer/web/vendor/bundle/nix-bundle/ruby/3.2.0/gems/railties-7.2.2/lib/rails/initializable.rb:61:in `block in run_initializers'
/nix/store/wcdl8mkaas5c5xdp7rw1pi0mhi2jgqfg-ruby-3.2.4/lib/ruby/3.2.0/tsort.rb:228:in `block in tsort_each'
/nix/store/wcdl8mkaas5c5xdp7rw1pi0mhi2jgqfg-ruby-3.2.4/lib/ruby/3.2.0/tsort.rb:350:in `block (2 levels) in each_strongly_connected_component'
/nix/store/wcdl8mkaas5c5xdp7rw1pi0mhi2jgqfg-ruby-3.2.4/lib/ruby/3.2.0/tsort.rb:422:in `block (2 levels) in each_strongly_connected_component_from'
/nix/store/wcdl8mkaas5c5xdp7rw1pi0mhi2jgqfg-ruby-3.2.4/lib/ruby/3.2.0/tsort.rb:431:in `each_strongly_connected_component_from'
/nix/store/wcdl8mkaas5c5xdp7rw1pi0mhi2jgqfg-ruby-3.2.4/lib/ruby/3.2.0/tsort.rb:421:in `block in each_strongly_connected_component_from'
/Users/jon/Developer/web/vendor/bundle/nix-bundle/ruby/3.2.0/gems/railties-7.2.2/lib/rails/initializable.rb:50:in `each'
/Users/jon/Developer/web/vendor/bundle/nix-bundle/ruby/3.2.0/gems/railties-7.2.2/lib/rails/initializable.rb:50:in `tsort_each_child'
/nix/store/wcdl8mkaas5c5xdp7rw1pi0mhi2jgqfg-ruby-3.2.4/lib/ruby/3.2.0/tsort.rb:415:in `call'
/nix/store/wcdl8mkaas5c5xdp7rw1pi0mhi2jgqfg-ruby-3.2.4/lib/ruby/3.2.0/tsort.rb:415:in `each_strongly_connected_component_from'
/nix/store/wcdl8mkaas5c5xdp7rw1pi0mhi2jgqfg-ruby-3.2.4/lib/ruby/3.2.0/tsort.rb:349:in `block in each_strongly_connected_component'
/nix/store/wcdl8mkaas5c5xdp7rw1pi0mhi2jgqfg-ruby-3.2.4/lib/ruby/3.2.0/tsort.rb:347:in `each'
/nix/store/wcdl8mkaas5c5xdp7rw1pi0mhi2jgqfg-ruby-3.2.4/lib/ruby/3.2.0/tsort.rb:347:in `call'
/nix/store/wcdl8mkaas5c5xdp7rw1pi0mhi2jgqfg-ruby-3.2.4/lib/ruby/3.2.0/tsort.rb:347:in `each_strongly_connected_component'
/nix/store/wcdl8mkaas5c5xdp7rw1pi0mhi2jgqfg-ruby-3.2.4/lib/ruby/3.2.0/tsort.rb:226:in `tsort_each'
/nix/store/wcdl8mkaas5c5xdp7rw1pi0mhi2jgqfg-ruby-3.2.4/lib/ruby/3.2.0/tsort.rb:205:in `tsort_each'
/Users/jon/Developer/web/vendor/bundle/nix-bundle/ruby/3.2.0/gems/railties-7.2.2/lib/rails/initializable.rb:60:in `run_initializers'
/Users/jon/Developer/web/vendor/bundle/nix-bundle/ruby/3.2.0/gems/railties-7.2.2/lib/rails/application.rb:435:in `initialize!'
/Users/jon/Developer/web/config/environment.rb:7:in `<top (required)>'
config.ru:4:in `require_relative'
config.ru:4:in `block (2 levels) in <top (required)>'
/Users/jon/Developer/web/vendor/bundle/nix-bundle/ruby/3.2.0/gems/rack-3.1.8/lib/rack/builder.rb:108:in `eval'
/Users/jon/Developer/web/vendor/bundle/nix-bundle/ruby/3.2.0/gems/rack-3.1.8/lib/rack/builder.rb:108:in `new_from_string'
/Users/jon/Developer/web/vendor/bundle/nix-bundle/ruby/3.2.0/gems/rack-3.1.8/lib/rack/builder.rb:97:in `load_file'
/Users/jon/Developer/web/vendor/bundle/nix-bundle/ruby/3.2.0/gems/rack-3.1.8/lib/rack/builder.rb:67:in `parse_file'
/Users/jon/Developer/web/vendor/bundle/nix-bundle/ruby/3.2.0/gems/puma-6.5.0/lib/puma/configuration.rb:384:in `load_rackup'
/Users/jon/Developer/web/vendor/bundle/nix-bundle/ruby/3.2.0/gems/puma-6.5.0/lib/puma/configuration.rb:297:in `app'
/Users/jon/Developer/web/vendor/bundle/nix-bundle/ruby/3.2.0/gems/puma-6.5.0/lib/puma/runner.rb:166:in `load_and_bind'
/Users/jon/Developer/web/vendor/bundle/nix-bundle/ruby/3.2.0/gems/puma-6.5.0/lib/puma/single.rb:44:in `run'
/Users/jon/Developer/web/vendor/bundle/nix-bundle/ruby/3.2.0/gems/puma-6.5.0/lib/puma/launcher.rb:196:in `run'
/Users/jon/Developer/web/vendor/bundle/nix-bundle/ruby/3.2.0/gems/puma-6.5.0/lib/puma/cli.rb:75:in `run'
/Users/jon/Developer/web/vendor/bundle/nix-bundle/ruby/3.2.0/gems/puma-6.5.0/bin/puma:10:in `<top (required)>'
bin/puma:29:in `load'
bin/puma:29:in `<main>'

which is especially annoying if you're using NewRelic's log_file_path=STDOUT.

Feature Description

record_api_supportability_metric looks like it half-expects agent to be nil. Maybe it could pass a dont_warn_if_unavailable flag or something?

Priority

Nice to have

workato-integration[bot] commented 4 days ago

https://new-relic.atlassian.net/browse/NR-343719

hannahramadan commented 2 days ago

Hi @jdelStrother - thanks for submitting this issue. We're thinking these logs shouldn't need to be WARN level, but might be better suited as DEBUG. That would help quiet logs as you would only see them running the agent in DEBUG mode. Would that work for you?

jdelStrother commented 2 days ago

Yep, sounds good to me - I very rarely run the NewRelic logs at debug level

hannahramadan commented 2 days ago

Thank you so much @jdelStrother! We appreciate you sharing this and will be much quieter with our next release. Updated this log output to DEBUG in https://github.com/newrelic/newrelic-ruby-agent/pull/2975