Skip to content

Commit

Permalink
Merge pull request #2795 from newrelic/falcon-detection
Browse files Browse the repository at this point in the history
Revert falcon detection changes
  • Loading branch information
kaylareopelle authored Aug 6, 2024
2 parents 587fcbb + b47141e commit 9f3b281
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 5 deletions.
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,16 @@

## dev

Version <dev> updates framework detection.
Version <dev> updates framework detection and fixes Falcon dispatcher detection.

- **Feature: Improve framework detection accuracy for Grape and Padrino**

Previously, applications using the Grape framework would set `ruby` as their framework within the Environment Report. Now, Grape applications will be set to `grape`. Similarly, applications using the Padrino framework would be set to `sinatra`. Now, they will be set to `padrino`. This will help the New Relic security agent compatibility checks. Thank you, [@prateeksen](https://github.com/prateeksen) for making this change. [Issue#2777](https://github.com/newrelic/newrelic-ruby-agent/issues/2777) [PR#2789](https://github.com/newrelic/newrelic-ruby-agent/pull/2789)

- **Bugfix: Fix Falcon dispatcher detection**

Previously, we tried to use the object space to determine whether the [Falcon web server](https://github.com/socketry/falcon) was in use. However, Falcon is not added to the object space until after the environment report is generated, resulting in a `nil` dispatcher. Now, we revert to an earlier strategy that discovered the dispatcher using `File.basename`. Thank you, [@prateeksen](https://github.com/prateeksen) for reporting this issue and researching the problem. [Issue#2778](https://github.com/newrelic/newrelic-ruby-agent/issues/2778) [PR#2795](https://github.com/newrelic/newrelic-ruby-agent/pull/2795)

## v9.12.0

Version 9.12.0 adds support for the `newrelic_security` agent, introduces instrumentation for the LogStasher gem, improves instrumentation for the `redis-clustering` gem, and updates the Elasticsearch instrumentation to only attempt to get the cluster name once per client, even if it fails.
Expand Down
5 changes: 1 addition & 4 deletions lib/new_relic/local_environment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -142,10 +142,7 @@ def check_for_puma
end

def check_for_falcon
return unless defined?(::Falcon::Server) &&
NewRelic::LanguageSupport.object_space_usable?

@discovered_dispatcher = :falcon if find_class_in_object_space(::Falcon::Server)
@discovered_dispatcher = :falcon if defined?(::Falcon::Server) && File.basename($PROGRAM_NAME) == 'falcon'
end

def check_for_delayed_job
Expand Down
17 changes: 17 additions & 0 deletions test/new_relic/local_environment_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,23 @@ def test_passenger
end
end

def test_falcon
falcon_file = File.expand_path('../../../../bin/falcon', __FILE__)
opn = $PROGRAM_NAME
$PROGRAM_NAME = falcon_file

with_constant_defined(:'::Falcon') do
with_constant_defined(:'::Falcon::Server') do
e = NewRelic::Agent.reset_config
e = NewRelic::LocalEnvironment.new

assert_equal :falcon, e.discovered_dispatcher
end
end
ensure
$PROGRAM_NAME = opn
end

def test_not_resque
combinations = [['notrake', 'resque:work', {'QUEUE' => '*'}],
['rake', 'notresque:work', {'QUEUE' => '*'}],
Expand Down

0 comments on commit 9f3b281

Please sign in to comment.