Skip to content

Commit 968c118

Browse files
Merge pull request #2683 from newrelic/dev
Release 9.10.1
2 parents d4a9102 + 37045d1 commit 968c118

File tree

21 files changed

+194
-75
lines changed

21 files changed

+194
-75
lines changed

.github/workflows/ci_cron.yml

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
- name: Configure git
1717
run: 'git config --global init.defaultBranch main'
1818
- uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # tag v4.1.2
19-
- uses: ruby/setup-ruby@1198b074305f9356bd56dd4b311757cc0dab2f1c # tag v1.175.1
19+
- uses: ruby/setup-ruby@943103cae7d3f1bb1e4951d5fcc7928b40e4b742 # tag v1.177.1
2020
with:
2121
ruby-version: '3.3'
2222
- run: bundle
@@ -36,7 +36,7 @@ jobs:
3636
strategy:
3737
fail-fast: false
3838
matrix:
39-
ruby-version: [2.4.10, 2.5.9, 2.6.10, 2.7.8, 3.0.7, 3.1.5, 3.2.4, 3.3.1]
39+
ruby-version: [2.4.10, 2.5.9, 2.6.10, 2.7.8, 3.0.7, 3.1.5, 3.2.4, 3.3.1, 3.4.0-preview1]
4040

4141
steps:
4242
- name: Configure git
@@ -50,7 +50,7 @@ jobs:
5050
run: sudo apt-get update; sudo apt-get install -y --no-install-recommends libcurl4-nss-dev libsasl2-dev libxslt1-dev
5151

5252
- name: Install Ruby ${{ matrix.ruby-version }}
53-
uses: ruby/setup-ruby@1198b074305f9356bd56dd4b311757cc0dab2f1c # tag v1.175.1
53+
uses: ruby/setup-ruby@943103cae7d3f1bb1e4951d5fcc7928b40e4b742 # tag v1.177.1
5454
with:
5555
ruby-version: ${{ matrix.ruby-version }}
5656

@@ -83,6 +83,9 @@ jobs:
8383
},
8484
"3.3.1": {
8585
"rails": "norails,rails61,rails70"
86+
},
87+
"3.4.0-preview1": {
88+
"rails": "norails,rails61,rails70"
8689
}
8790
}
8891
@@ -200,7 +203,7 @@ jobs:
200203
fail-fast: false
201204
matrix:
202205
multiverse: [agent, ai, background, background_2, database, frameworks, httpclients, httpclients_2, rails, rest]
203-
ruby-version: [2.4.10, 2.5.9, 2.6.10, 2.7.8, 3.0.7, 3.1.5, 3.2.4, 3.3.1]
206+
ruby-version: [2.4.10, 2.5.9, 2.6.10, 2.7.8, 3.0.7, 3.1.5, 3.2.4, 3.3.1, 3.4.0-preview1]
204207
steps:
205208
- name: Configure git
206209
run: 'git config --global init.defaultBranch main'
@@ -213,7 +216,7 @@ jobs:
213216
run: sudo apt-get update; sudo apt-get install -y --no-install-recommends libcurl4-nss-dev libsasl2-dev libxslt1-dev
214217

215218
- name: Install Ruby ${{ matrix.ruby-version }}
216-
uses: ruby/setup-ruby@1198b074305f9356bd56dd4b311757cc0dab2f1c # tag v1.175.1
219+
uses: ruby/setup-ruby@943103cae7d3f1bb1e4951d5fcc7928b40e4b742 # tag v1.177.1
217220
with:
218221
ruby-version: ${{ matrix.ruby-version }}
219222

@@ -278,14 +281,14 @@ jobs:
278281
strategy:
279282
fail-fast: false
280283
matrix:
281-
ruby-version: [2.7.8, 3.0.7, 3.1.5, 3.2.4, 3.3.1]
284+
ruby-version: [2.7.8, 3.0.7, 3.1.5, 3.2.4, 3.3.1, 3.4.0-preview1]
282285
steps:
283286
- name: Configure git
284287
run: 'git config --global init.defaultBranch main'
285288
- uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # tag v4.1.2
286289

287290
- name: Install Ruby ${{ matrix.ruby-version }}
288-
uses: ruby/setup-ruby@1198b074305f9356bd56dd4b311757cc0dab2f1c # tag v1.175.1
291+
uses: ruby/setup-ruby@943103cae7d3f1bb1e4951d5fcc7928b40e4b742 # tag v1.177.1
289292
with:
290293
ruby-version: ${{ matrix.ruby-version }}
291294

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# New Relic Ruby Agent Release Notes
22

3+
## v9.10.1
4+
5+
- **Bugfix: Incompatibility with Bootstrap**
6+
7+
Version 9.10.1 fixes an incompatibility between the agent and the [Bootstrap](https://github.com/twbs/bootstrap-rubygem) gem caused by agent v9.10.0's introduction of a `lib/bootstrap.rb` file. Thank you to [@dorner](https://github.com/dorner) for reporting the bug and identifying the 'bootstrap' name collision as the root cause. [BUG#2675](https://github.com/newrelic/newrelic-ruby-agent/issues/2675) [PR#2676](https://github.com/newrelic/newrelic-ruby-agent/pull/2676)
8+
39
## v9.10.0
410

511
Version 9.10.0 introduces instrumentation for DynamoDB, adds a new feature to automatically apply nonces from the Rails content security policy, fixes a bug that would cause an expected error to negatively impact a transaction's Apdex, and fixes the agent's autostart logic so that by default `rails runner` and `rails db` commands will not cause the agent to start.

lib/bootstrap.rb renamed to lib/boot/strap.rb

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
# - Next, use the "RUBYOPT" environment variable to require ("-r") this
2828
# file (note that the ".rb" extension is dropped):
2929
# ```
30-
# export RUBYOPT="-r /newrelic/lib/bootstrap"
30+
# export RUBYOPT="-r /newrelic/lib/boot/strap"
3131
# ```
3232
# - Add your New Relic license key as an environment variable.
3333
# ```
@@ -50,7 +50,7 @@ def require(*_groups)
5050
end
5151

5252
def require_newrelic
53-
lib = File.dirname(__FILE__)
53+
lib = File.expand_path('../..', __FILE__)
5454
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5555
Kernel.require NR_AGENT_GEM
5656
end
@@ -65,40 +65,36 @@ def self.patch
6565
check_for_rubyopt
6666
check_for_bundler
6767
Bundler::Runtime.prepend(NRBundlerPatch)
68+
rescue StandardError => e
69+
Kernel.warn "New Relic entrypoint at #{__FILE__} encountered an issue:\n #{e.message}"
6870
end
6971

7072
private
7173

7274
def self.check_for_require
73-
warn_and_exit "#{__FILE__} is meant to be required, not invoked directly" if $PROGRAM_NAME == __FILE__
75+
raise "#{__FILE__} is meant to be required, not invoked directly" if $PROGRAM_NAME == __FILE__
7476
end
7577

7678
def self.check_for_rubyopt
7779
unless ENV[RUBYOPT].to_s.match?("-r #{__FILE__.rpartition('.').first}")
78-
warn_and_exit "#{__FILE__} is meant to be required via the RUBYOPT env var"
80+
raise "#{__FILE__} is meant to be required via the RUBYOPT env var"
7981
end
8082
end
8183

8284
def self.check_for_bundler
8385
require_bundler
8486

85-
warn_and_exit 'Required Ruby Bundler class Bundler::Runtime not defined!' unless defined?(Bundler::Runtime)
87+
raise 'Required Ruby Bundler class Bundler::Runtime not defined!' unless defined?(Bundler::Runtime)
8688

8789
unless Bundler::Runtime.method_defined?(:require)
88-
warn_and_exit "The active Ruby Bundler instance doesn't offer Bundler::Runtime#require"
90+
raise "The active Ruby Bundler instance doesn't offer Bundler::Runtime#require"
8991
end
9092
end
9193

9294
def self.require_bundler
9395
require BUNDLER
9496
rescue LoadError => e
95-
warn_and_exit "Required Ruby library '#{BUNDLER}' could not be required - #{e}"
96-
end
97-
98-
def self.warn_and_exit(msg)
99-
warn "New Relic entrypoint at #{__FILE__} encountered an issue:\n\t#{msg}"
100-
101-
exit 1
97+
raise "Required Ruby library '#{BUNDLER}' could not be required - #{e}"
10298
end
10399
end
104100

lib/new_relic/agent/configuration/default_source.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -782,7 +782,7 @@ def self.enforce_fallback(allowed_values: nil, fallback: nil)
782782
# CSP nonce
783783
:'browser_monitoring.content_security_policy_nonce' => {
784784
:default => value_of(:'rum.enabled'),
785-
:documentation_default => false,
785+
:documentation_default => true,
786786
:public => true,
787787
:type => Boolean,
788788
:allowed_from_server => false,

lib/new_relic/agent/instrumentation/elasticsearch/instrumentation.rb

Lines changed: 51 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,54 @@ module NewRelic::Agent::Instrumentation
88
module Elasticsearch
99
PRODUCT_NAME = 'Elasticsearch'
1010
OPERATION = 'perform_request'
11+
12+
# Pattern to use with client caller location strings. Look for a location
13+
# that contains '/lib/elasticsearch/api/' and is NOT followed by the
14+
# string held in the OPERATION constant
15+
OPERATION_PATTERN = %r{/lib/elasticsearch/api/(?!.+#{OPERATION})}.freeze
16+
17+
# Use the OPERATION_PATTERN pattern to find the appropriate caller location
18+
# that will contain the client instance method (example: 'search') and
19+
# return that method name.
20+
#
21+
# A Ruby caller location matching the OPERATION_PATTERN will contain an
22+
# elasticsearch client instance method name (such as "search"), and that
23+
# method name will be used as the operation name.
24+
#
25+
# With Ruby < 3.4 the method name is listed as:
26+
#
27+
# `search'
28+
#
29+
# with an opening backtick and a closing single tick. And only the
30+
# method name itself is listed.
31+
#
32+
# With Ruby 3.4+ the method name is listed as:
33+
#
34+
# 'Elasticsearch::API::Actions#search'
35+
#
36+
# with opening and closing single ticks and the class defining the
37+
# instance method listed.
38+
#
39+
# (?:) = ?: prevents capturing
40+
# (?:`|') = allow ` or '
41+
# (?:.+#) = allow the class name and '#' prefix to exist but ignore it
42+
# ([^']+)' = after the opening ` or ', capturing everything up to the
43+
# closing '. [^']+ = one or more characters that are not '
44+
#
45+
# Example Ruby 3.3.1 input:
46+
#
47+
# /Users/fallwith/.rubies/ruby-3.3.1/lib/ruby/gems/3.3.0/gems/elasticsearch-api-7.17.10/lib/elasticsearch/api/actions/index.rb:74:in `index'
48+
#
49+
# Example Ruby 3.4.0-preview1 input:
50+
#
51+
# /Users/fallwith/.rubies/ruby-3.4.0-preview1/lib/ruby/gems/3.4.0+0/gems/elasticsearch-api-7.17.10/lib/elasticsearch/api/actions/index.rb:74:in 'Elasticsearch::API::Actions#index'
52+
#
53+
# Example output for both Rubies:
54+
#
55+
# index
56+
57+
INSTANCE_METHOD_PATTERN = /:in (?:`|')(?:.+#)?([^']+)'\z/.freeze
58+
1159
INSTRUMENTATION_NAME = NewRelic::Agent.base_name(name)
1260

1361
# We need the positional arguments `params` and `body`
@@ -40,13 +88,10 @@ def perform_request_with_tracing(_method, _path, params = {}, body = nil, _heade
4088
private
4189

4290
def nr_operation
43-
operation_index = caller_locations.index do |line|
44-
string = line.to_s
45-
string.include?('lib/elasticsearch/api') && !string.include?(OPERATION)
46-
end
47-
return nil unless operation_index
91+
location = caller_locations.detect { |loc| loc.to_s.match?(OPERATION_PATTERN) }
92+
return unless location && location.to_s =~ INSTANCE_METHOD_PATTERN
4893

49-
caller_locations[operation_index].to_s.split('`')[-1].gsub(/\W/, '')
94+
Regexp.last_match(1)
5095
end
5196

5297
def nr_reported_query(query)

lib/new_relic/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ module NewRelic
77
module VERSION # :nodoc:
88
MAJOR = 9
99
MINOR = 10
10-
TINY = 0
10+
TINY = 1
1111

1212
STRING = "#{MAJOR}.#{MINOR}.#{TINY}"
1313
end

lib/sequel/extensions/new_relic_instrumentation.rb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,9 @@ def notice_sql(sql)
7878
end
7979

8080
THREAD_SAFE_CONNECTION_POOL_CLASSES = [
81-
(defined?(::Sequel::ThreadedConnectionPool) && ::Sequel::ThreadedConnectionPool)
82-
].freeze
81+
(defined?(::Sequel::ThreadedConnectionPool) && ::Sequel::ThreadedConnectionPool),
82+
(defined?(::Sequel::TimedQueueConnectionPool) && RUBY_VERSION >= '3.4' && ::Sequel::TimedQueueConnectionPool)
83+
].compact.freeze
8384

8485
def explainer_for(sql)
8586
proc do |*|

newrelic.yml

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ common: &default_settings
4343
# The excluded attributes include:
4444
# * content from LlmChatCompletionMessage events
4545
# * input from LlmEmbedding events
46+
# This is an optional security setting to prevent recording sensitive data sent to
47+
# and received from your LLMs.
4648
# ai_monitoring.record_content.enabled: true
4749

4850
# If true, enables capture of all HTTP request headers for all destinations.
@@ -146,7 +148,7 @@ common: &default_settings
146148

147149
# If true, enables auto-injection of Content Security Policy Nonce in browser
148150
# monitoring scripts. For now, auto-injection only works with Rails 5.2+.
149-
# browser_monitoring.content_security_policy_nonce: false
151+
# browser_monitoring.content_security_policy_nonce: true
150152

151153
# Manual override for the path to your local CA bundle. This CA bundle will be
152154
# used to validate the SSL certificate presented by New Relic's data collection
@@ -358,8 +360,8 @@ common: &default_settings
358360
# embedded service within another framework and the agent is detecting the Sinatra
359361
# app and skipping the at_exit handler as a result. Sinatra classically runs the
360362
# entire application in an at_exit block and would otherwise misbehave if the
361-
# agent's at_exit handler was also installed in those circumstances. Note:
362-
# send_data_on_exit should also be set to true in tandem with this setting.
363+
# Agent's at_exit handler was also installed in those circumstances. Note:
364+
# send_data_on_exit should also be set to true in tandem with this setting."
363365
# force_install_exit_handler: false
364366

365367
# Ordinarily the agent reports dyno names with a trailing dot and process ID (for
@@ -420,15 +422,15 @@ common: &default_settings
420422
# instrumentation.delayed_job: auto
421423

422424
# Controls auto-instrumentation of the aws-sdk-dynamodb library at start-up. May
423-
# be one of [auto|prepend|chain|disabled].
425+
# be one of auto, prepend, chain, disabled.
424426
# instrumentation.dynamodb: auto
425427

426428
# Controls auto-instrumentation of the elasticsearch library at start-up. May be
427429
# one of: auto, prepend, chain, disabled.
428430
# instrumentation.elasticsearch: auto
429431

430-
# Controls auto-instrumentation of ethon at start up. May be one of
431-
# [auto|prepend|chain|disabled]
432+
# Controls auto-instrumentation of ethon at start up. May be one of auto, prepend,
433+
# chain, disabled
432434
# instrumentation.ethon: auto
433435

434436
# Controls auto-instrumentation of Excon at start-up. May be one of: enabled,
@@ -468,8 +470,8 @@ common: &default_settings
468470
# prepend, chain, disabled.
469471
# instrumentation.httprb: auto
470472

471-
# Controls auto-instrumentation of httpx at start up. May be one of
472-
# [auto|prepend|chain|disabled]
473+
# Controls auto-instrumentation of httpx at start up. May be one of auto, prepend,
474+
# chain, disabled
473475
# instrumentation.httpx: auto
474476

475477
# Controls auto-instrumentation of Ruby standard library Logger at start-up. May
@@ -531,7 +533,7 @@ common: &default_settings
531533
# instrumentation.roda: auto
532534

533535
# Controls auto-instrumentation of the ruby-openai gem at start-up. May be one of:
534-
# auto, prepend, chain, disabled.
536+
# auto, prepend, chain, disabled. Defaults to disabled in high security mode.
535537
# instrumentation.ruby_openai: auto
536538

537539
# Controls auto-instrumentation of Sinatra at start-up. May be one of: auto,
@@ -695,8 +697,10 @@ common: &default_settings
695697
# If true, enables span event sampling.
696698
# span_events.enabled: true
697699

698-
# Defines the maximum number of span events reported from a single harvest. Any
699-
# Integer between 1 and 10000 is valid.
700+
# * Defines the maximum number of span events reported from a single harvest. Any
701+
# Integer between 1 and 10000 is valid.'
702+
# * When configuring the agent for AI monitoring, set to max value 10000. This
703+
# ensures that the agent captures the maximum amount of distributed traces.
700704
# span_events.max_samples_stored: 2000
701705

702706
# Sets the maximum number of span events to buffer when streaming to the trace

test/agent_helper.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1039,3 +1039,7 @@ def first_call_for(subject)
10391039

10401040
items.first
10411041
end
1042+
1043+
def ruby_version_float
1044+
RUBY_VERSION.split('.')[0..1].join('.').to_f
1045+
end

test/environments/norails/Gemfile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,8 @@ gem 'simplecov' if ENV['VERBOSE_TEST_OUTPUT']
2222

2323
gem 'warning'
2424
gem 'loofah', '~> 2.20.0' if RUBY_VERSION >= '2.4.0' && RUBY_VERSION < '2.5.0'
25+
26+
if RUBY_VERSION.split('.')[0..1].join('.').to_f >= 3.4
27+
gem 'mutex_m'
28+
gem 'ostruct'
29+
end

test/environments/rails61/Gemfile

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,3 +39,10 @@ end
3939

4040
gem 'simplecov' if ENV['VERBOSE_TEST_OUTPUT']
4141
gem 'warning'
42+
43+
if RUBY_VERSION.split('.')[0..1].join('.').to_f >= 3.4
44+
gem 'base64'
45+
gem 'bigdecimal'
46+
gem 'mutex_m'
47+
gem 'ostruct'
48+
end

test/environments/rails70/Gemfile

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,10 @@ end
2525

2626
gem 'simplecov' if ENV['VERBOSE_TEST_OUTPUT']
2727
gem 'warning'
28+
29+
if RUBY_VERSION.split('.')[0..1].join('.').to_f >= 3.4
30+
gem 'base64'
31+
gem 'bigdecimal'
32+
gem 'mutex_m'
33+
gem 'ostruct'
34+
end

0 commit comments

Comments
 (0)