From ebc74b53c76dffa1b3d1ce3520807dde27c3c667 Mon Sep 17 00:00:00 2001 From: Hannah Ramadan Date: Tue, 19 Dec 2023 15:28:04 -0700 Subject: [PATCH 1/4] Add Falcon as recognized server --- lib/new_relic/agent/agent_helpers/special_startup.rb | 2 +- lib/new_relic/local_environment.rb | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/new_relic/agent/agent_helpers/special_startup.rb b/lib/new_relic/agent/agent_helpers/special_startup.rb index 08b5d4cf33..351967636e 100644 --- a/lib/new_relic/agent/agent_helpers/special_startup.rb +++ b/lib/new_relic/agent/agent_helpers/special_startup.rb @@ -10,7 +10,7 @@ module SpecialStartup # requests, we need to wait until the children are forked # before connecting, otherwise the parent process sends useless data def using_forking_dispatcher? - if [:puma, :passenger, :unicorn].include?(Agent.config[:dispatcher]) + if [:puma, :passenger, :unicorn, :falcon].include?(Agent.config[:dispatcher]) ::NewRelic::Agent.logger.info('Deferring startup of agent reporting thread because ' \ "#{Agent.config[:dispatcher]} may fork.") true diff --git a/lib/new_relic/local_environment.rb b/lib/new_relic/local_environment.rb index dff2d8343f..87d5f56fb9 100644 --- a/lib/new_relic/local_environment.rb +++ b/lib/new_relic/local_environment.rb @@ -74,6 +74,7 @@ def discover_dispatcher unicorn webrick fastcgi + falcon ] while dispatchers.any? && @discovered_dispatcher.nil? send('check_for_' + (dispatchers.shift)) @@ -138,6 +139,12 @@ def check_for_puma end end + def check_for_falcon + if defined?(::Falcon::Server) && File.basename($0) == 'falcon' + @discovered_dispatcher = :falcon + end + end + def check_for_delayed_job if $0 =~ /delayed_job$/ || (File.basename($0) == 'rake' && ARGV.include?('jobs:work')) @discovered_dispatcher = :delayed_job From ac8e70d8d60cb97dde8988825f398f64d166397f Mon Sep 17 00:00:00 2001 From: Hannah Ramadan Date: Tue, 2 Jan 2024 16:42:27 -0800 Subject: [PATCH 2/4] Add Falcon as a recognized webserver --- lib/new_relic/local_environment.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/new_relic/local_environment.rb b/lib/new_relic/local_environment.rb index 87d5f56fb9..bd195ac073 100644 --- a/lib/new_relic/local_environment.rb +++ b/lib/new_relic/local_environment.rb @@ -140,8 +140,9 @@ def check_for_puma end def check_for_falcon - if defined?(::Falcon::Server) && File.basename($0) == 'falcon' - @discovered_dispatcher = :falcon + if defined?(::Falcon::Server) && NewRelic::LanguageSupport.object_space_usable? + v = find_class_in_object_space(::Falcon::Server) + @discovered_dispatcher = :falcon if v end end From 4899dfdd809bffb22a066d983a735c14e7e73c1c Mon Sep 17 00:00:00 2001 From: Hannah Ramadan Date: Thu, 4 Jan 2024 15:10:04 -0800 Subject: [PATCH 3/4] Add CHANGELOG --- CHANGELOG.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1a5fd18eee..c9decccd4c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ ## v9.7.0 -Version 9.7.0 changes the endpoint used to access the cluster name for Elasticsearch instrumentation. +Version 9.7.0 changes the endpoint used to access the cluster name for Elasticsearch instrumentation and adds support for Falcon. - **Feature: Use root path to access Elasticsearch cluster name** @@ -18,6 +18,10 @@ Version 9.7.0 changes the endpoint used to access the cluster name for Elasticse Thank you, [@Earlopain](https://github.com/Earlopain), for submitting this change. [PR#2378](https://github.com/newrelic/newrelic-ruby-agent/pull/2378) +- **Feature: Add Falcon support** + + The agent now supports the web server [Falcon](https://socketry.github.io/falcon/). [PR#2383](https://github.com/newrelic/newrelic-ruby-agent/pull/2383) + ## v9.6.0 Version 9.6.0 adds instrumentation for Async::HTTP, Ethon, and HTTPX, adds the ability to ignore specific routes with Roda, gleans Docker container IDs from cgroups v2-based containers, records additional synthetics attributes, fixes an issue with Rails 7.1 that could cause duplicate log records to be sent to New Relic, fixes a deprecation warning for the Sidekiq error handler, adds additional attributes for OpenTelemetry compatibility, and resolves some technical debt, thanks to the community. From 5e2ff03db7c78f245013caff7bdcbea1f783a60d Mon Sep 17 00:00:00 2001 From: Hannah Ramadan <76922290+hannahramadan@users.noreply.github.com> Date: Thu, 4 Jan 2024 15:10:48 -0800 Subject: [PATCH 4/4] Code review improvment Co-authored-by: James Bunch --- lib/new_relic/local_environment.rb | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/new_relic/local_environment.rb b/lib/new_relic/local_environment.rb index bd195ac073..b01b0ed2a6 100644 --- a/lib/new_relic/local_environment.rb +++ b/lib/new_relic/local_environment.rb @@ -141,8 +141,7 @@ def check_for_puma def check_for_falcon if defined?(::Falcon::Server) && NewRelic::LanguageSupport.object_space_usable? - v = find_class_in_object_space(::Falcon::Server) - @discovered_dispatcher = :falcon if v + @discovered_dispatcher = :falcon if find_class_in_object_space(::Falcon::Server) end end