Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert falcon detection changes #2795

Merged
merged 6 commits into from
Aug 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading