newrelic_rpm 9.8.0 → 9.10.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +46 -2
- data/README.md +3 -0
- data/Rakefile +1 -1
- data/lib/bootstrap.rb +105 -0
- data/lib/new_relic/agent/agent.rb +4 -1
- data/lib/new_relic/agent/agent_helpers/connect.rb +10 -8
- data/lib/new_relic/agent/agent_helpers/start_worker_thread.rb +1 -1
- data/lib/new_relic/agent/agent_helpers/startup.rb +2 -1
- data/lib/new_relic/agent/agent_logger.rb +2 -1
- data/lib/new_relic/agent/aws.rb +56 -0
- data/lib/new_relic/agent/configuration/default_source.rb +65 -15
- data/lib/new_relic/agent/configuration/environment_source.rb +9 -1
- data/lib/new_relic/agent/configuration/manager.rb +22 -5
- data/lib/new_relic/agent/configuration/yaml_source.rb +2 -0
- data/lib/new_relic/agent/connect/request_builder.rb +1 -1
- data/lib/new_relic/agent/distributed_tracing/distributed_trace_payload.rb +1 -5
- data/lib/new_relic/agent/error_collector.rb +23 -0
- data/lib/new_relic/agent/harvester.rb +1 -1
- data/lib/new_relic/agent/instrumentation/dynamodb/chain.rb +27 -0
- data/lib/new_relic/agent/instrumentation/dynamodb/instrumentation.rb +58 -0
- data/lib/new_relic/agent/instrumentation/dynamodb/prepend.rb +19 -0
- data/lib/new_relic/agent/instrumentation/dynamodb.rb +25 -0
- data/lib/new_relic/agent/instrumentation/elasticsearch/instrumentation.rb +6 -1
- data/lib/new_relic/agent/instrumentation/grpc/client/instrumentation.rb +0 -1
- data/lib/new_relic/agent/instrumentation/ruby_openai/instrumentation.rb +1 -2
- data/lib/new_relic/agent/log_event_aggregator.rb +1 -16
- data/lib/new_relic/agent/new_relic_service.rb +12 -2
- data/lib/new_relic/agent/serverless_handler.rb +171 -0
- data/lib/new_relic/agent/span_event_primitive.rb +4 -8
- data/lib/new_relic/agent/transaction/external_request_segment.rb +0 -10
- data/lib/new_relic/agent/transaction.rb +2 -6
- data/lib/new_relic/agent/transaction_error_primitive.rb +23 -19
- data/lib/new_relic/agent.rb +12 -8
- data/lib/new_relic/constants.rb +2 -0
- data/lib/new_relic/control/instance_methods.rb +7 -0
- data/lib/new_relic/local_environment.rb +13 -6
- data/lib/new_relic/rack/browser_monitoring.rb +9 -1
- data/lib/new_relic/version.rb +1 -1
- data/lib/tasks/config.rake +5 -3
- data/lib/tasks/helpers/config.html.erb +3 -2
- data/lib/tasks/helpers/format.rb +1 -1
- data/newrelic.yml +15 -1
- data/test/agent_helper.rb +3 -1
- metadata +10 -3
data/lib/new_relic/constants.rb
CHANGED
@@ -76,6 +76,7 @@ module NewRelic
|
|
76
76
|
end
|
77
77
|
|
78
78
|
def determine_env(options)
|
79
|
+
options[:env] = :serverless if local_env.discovered_dispatcher == :serverless
|
79
80
|
env = options[:env] || self.env
|
80
81
|
env = env.to_s
|
81
82
|
|
@@ -95,6 +96,12 @@ module NewRelic
|
|
95
96
|
def configure_agent(env, options)
|
96
97
|
manual = Agent::Configuration::ManualSource.new(options)
|
97
98
|
Agent.config.replace_or_add_config(manual)
|
99
|
+
|
100
|
+
# if manual config sees serverless mode enabled, then the proc
|
101
|
+
# must have returned 'true'. don't bother with YAML and high security
|
102
|
+
# in a serverless context
|
103
|
+
return if Agent.config[:'serverless_mode.enabled']
|
104
|
+
|
98
105
|
yaml_source = Agent::Configuration::YamlSource.new(config_file_path, env)
|
99
106
|
log_yaml_source_failures(yaml_source) if yaml_source.failed?
|
100
107
|
Agent.config.replace_or_add_config(yaml_source)
|
@@ -60,21 +60,22 @@ module NewRelic
|
|
60
60
|
|
61
61
|
def discover_dispatcher
|
62
62
|
dispatchers = %w[
|
63
|
+
serverless
|
64
|
+
puma
|
65
|
+
sidekiq
|
66
|
+
falcon
|
67
|
+
delayed_job
|
68
|
+
unicorn
|
63
69
|
passenger
|
70
|
+
resque
|
64
71
|
torquebox
|
65
72
|
trinidad
|
66
73
|
glassfish
|
67
|
-
resque
|
68
|
-
sidekiq
|
69
|
-
delayed_job
|
70
|
-
puma
|
71
74
|
thin
|
72
75
|
mongrel
|
73
76
|
litespeed
|
74
|
-
unicorn
|
75
77
|
webrick
|
76
78
|
fastcgi
|
77
|
-
falcon
|
78
79
|
]
|
79
80
|
while dispatchers.any? && @discovered_dispatcher.nil?
|
80
81
|
send('check_for_' + (dispatchers.shift))
|
@@ -198,6 +199,12 @@ module NewRelic
|
|
198
199
|
@discovered_dispatcher = :passenger
|
199
200
|
end
|
200
201
|
|
202
|
+
def check_for_serverless
|
203
|
+
return unless NewRelic::Agent.config[:'serverless_mode.enabled']
|
204
|
+
|
205
|
+
@discovered_dispatcher = :serverless
|
206
|
+
end
|
207
|
+
|
201
208
|
public
|
202
209
|
|
203
210
|
# outputs a human-readable description
|
@@ -38,7 +38,7 @@ module NewRelic
|
|
38
38
|
result = @app.call(env)
|
39
39
|
(status, headers, response) = result
|
40
40
|
|
41
|
-
js_to_inject = NewRelic::Agent.browser_timing_header
|
41
|
+
js_to_inject = NewRelic::Agent.browser_timing_header(nonce(env))
|
42
42
|
if (js_to_inject != NewRelic::EMPTY_STR) && should_instrument?(env, status, headers)
|
43
43
|
response_string = autoinstrument_source(response, js_to_inject)
|
44
44
|
if headers.key?(CONTENT_LENGTH)
|
@@ -58,6 +58,14 @@ module NewRelic
|
|
58
58
|
end
|
59
59
|
end
|
60
60
|
|
61
|
+
def nonce(env)
|
62
|
+
return unless NewRelic::Agent.config[:'browser_monitoring.content_security_policy_nonce']
|
63
|
+
return unless NewRelic::Agent.config[:framework] == :rails_notifications
|
64
|
+
return unless defined?(ActionDispatch::ContentSecurityPolicy::Request)
|
65
|
+
|
66
|
+
env[ActionDispatch::ContentSecurityPolicy::Request::NONCE]
|
67
|
+
end
|
68
|
+
|
61
69
|
def should_instrument?(env, status, headers)
|
62
70
|
NewRelic::Agent.config[:'browser_monitoring.auto_instrument'] &&
|
63
71
|
status == 200 &&
|
data/lib/new_relic/version.rb
CHANGED
data/lib/tasks/config.rake
CHANGED
@@ -20,14 +20,16 @@ namespace :newrelic do
|
|
20
20
|
ATTRIBUTES => '[Attributes](/docs/features/agent-attributes) are key-value pairs containing information that determines the properties of an event or transaction. These key-value pairs can be viewed within transaction traces in APM, traced errors in APM, transaction events in dashboards, and page views in dashboards. You can customize exactly which attributes will be sent to each of these destinations',
|
21
21
|
'transaction_tracer' => 'The [transaction traces](/docs/apm/traces/transaction-traces/transaction-traces) feature collects detailed information from a selection of transactions, including a summary of the calling sequence, a breakdown of time spent, and a list of SQL queries and their query plans (on mysql and postgresql). Available features depend on your New Relic subscription level.',
|
22
22
|
'error_collector' => "The agent collects and reports all uncaught exceptions by default. These configuration options allow you to customize the error collection.\n\nFor information on ignored and expected errors, [see this page on Error Analytics in APM](/docs/agents/manage-apm-agents/agent-data/manage-errors-apm-collect-ignore-or-mark-expected/). To set expected errors via the `NewRelic::Agent.notice_error` Ruby method, [consult the Ruby agent API](/docs/agents/ruby-agent/api-guides/sending-handled-errors-new-relic/).",
|
23
|
-
'browser_monitoring' => "The browser
|
23
|
+
'browser_monitoring' => "The <InlinePopover type='browser' /> [page load timing](/docs/browser/new-relic-browser/page-load-timing/page-load-timing-process) feature (sometimes referred to as real user monitoring or RUM) gives you insight into the performance real users are experiencing with your website. This is accomplished by measuring the time it takes for your users' browsers to download and render your web pages by injecting a small amount of JavaScript code into the header and footer of each page.",
|
24
24
|
'application_logging' => "The Ruby agent supports [APM logs in context](/docs/apm/new-relic-apm/getting-started/get-started-logs-context). For some tips on configuring logs for the Ruby agent, see [Configure Ruby logs in context](/docs/logs/logs-context/configure-logs-context-ruby).\n\nAvailable logging-related config options include:",
|
25
|
-
'analytics_events' => '[New Relic dashboards](/docs/query-your-data/explore-query-data/dashboards/introduction-new-relic-one-dashboards) is a resource to gather and visualize data about your software and what it says about your business. With it you can quickly and easily create real-time dashboards to get immediate answers about end-user experiences, clickstreams, mobile activities, and server transactions.'
|
25
|
+
'analytics_events' => '[New Relic dashboards](/docs/query-your-data/explore-query-data/dashboards/introduction-new-relic-one-dashboards) is a resource to gather and visualize data about your software and what it says about your business. With it you can quickly and easily create real-time dashboards to get immediate answers about end-user experiences, clickstreams, mobile activities, and server transactions.',
|
26
|
+
'ai_monitoring' => "This section includes Ruby agent configurations for setting up AI monitoring.\n\n<Callout variant='important'>You need to enable distributed tracing to capture trace and feedback data. It is turned on by default in Ruby agents 8.0.0 and higher.</Callout>"
|
26
27
|
}
|
27
28
|
|
28
29
|
NAME_OVERRIDES = {
|
29
30
|
'slow_sql' => 'Slow SQL [#slow-sql]',
|
30
|
-
'custom_insights_events' => 'Custom Events [#custom-events]'
|
31
|
+
'custom_insights_events' => 'Custom Events [#custom-events]',
|
32
|
+
'ai_monitoring' => 'AI Monitoring [#ai-monitoring]'
|
31
33
|
}
|
32
34
|
|
33
35
|
desc 'Describe available New Relic configuration settings'
|
@@ -10,6 +10,7 @@ redirects:
|
|
10
10
|
- /docs/ruby/ruby-agent-configuration
|
11
11
|
- /docs/agents/ruby-agent/installation-and-configuration/ruby-agent-configuration
|
12
12
|
- /docs/agents/ruby-agent/installation-configuration/ruby-agent-configuration
|
13
|
+
freshnessValidatedDate: never
|
13
14
|
---
|
14
15
|
|
15
16
|
<CONTRIBUTOR_NOTE>
|
@@ -70,12 +71,12 @@ The Ruby agent looks for the following environment variables, in this order, to
|
|
70
71
|
|
71
72
|
If the Ruby agent doesn't detect values for any of those environment variables, it will default the application environment to `development` and read from the `development` section of the `newrelic.yml` config file.
|
72
73
|
|
73
|
-
When running the Ruby agent in a Rails app, the agent first looks for the `NEW_RELIC_ENV` environment variable to
|
74
|
+
When running the Ruby agent in a Rails app, the agent first looks for the `NEW_RELIC_ENV` environment variable to find the application environment and which section of the `newrelic.yml` to use. If `NEW_RELIC_ENV` is not present, the agent uses the Rails environment (`RAILS_ENV`).
|
74
75
|
|
75
76
|
When you edit the config file, be sure to:
|
76
77
|
|
77
78
|
* Indent only with two spaces.
|
78
|
-
* Indent only where relevant, in
|
79
|
+
* Indent only where relevant, in sections such as <DoNotTranslate>**`error_collector`**</DoNotTranslate>.
|
79
80
|
|
80
81
|
If you do not indent correctly, the agent may throw an `Unable to parse configuration file` error on startup.
|
81
82
|
|
data/lib/tasks/helpers/format.rb
CHANGED
@@ -69,7 +69,7 @@ module Format
|
|
69
69
|
|
70
70
|
def format_description(value)
|
71
71
|
description = ''
|
72
|
-
description += '
|
72
|
+
description += '<DoNotTranslate>**DEPRECATED**</DoNotTranslate>' if value[:deprecated]
|
73
73
|
description += value[:description]
|
74
74
|
description
|
75
75
|
end
|
data/newrelic.yml
CHANGED
@@ -114,7 +114,7 @@ common: &default_settings
|
|
114
114
|
# Specify a list of constants that should prevent the agent from starting
|
115
115
|
# automatically. Separate individual constants with a comma ,. For example,
|
116
116
|
# "Rails::Console,UninstrumentedBackgroundJob".
|
117
|
-
# autostart.denylisted_constants: Rails::Command::ConsoleCommand,Rails::Command::CredentialsCommand,Rails::Command::Db::System::ChangeCommand,Rails::Command::DbConsoleCommand,Rails::Command::DestroyCommand,Rails::Command::DevCommand,Rails::Command::EncryptedCommand,Rails::Command::GenerateCommand,Rails::Command::InitializersCommand,Rails::Command::NotesCommand,Rails::Command::RoutesCommand,Rails::Command::SecretsCommand,Rails::Console,Rails::DBConsole
|
117
|
+
# autostart.denylisted_constants: Rails::Command::ConsoleCommand,Rails::Command::CredentialsCommand,Rails::Command::Db::System::ChangeCommand,Rails::Command::DbConsoleCommand,Rails::Command::DestroyCommand,Rails::Command::DevCommand,Rails::Command::EncryptedCommand,Rails::Command::GenerateCommand,Rails::Command::InitializersCommand,Rails::Command::NotesCommand,Rails::Command::RakeCommand,Rails::Command::RoutesCommand,Rails::Command::RunnerCommand,Rails::Command::SecretsCommand,Rails::Console,Rails::DBConsole
|
118
118
|
|
119
119
|
# Defines a comma-delimited list of executables that the agent should not
|
120
120
|
# instrument. For example, "rake,my_ruby_script.rb".
|
@@ -144,6 +144,10 @@ common: &default_settings
|
|
144
144
|
# (sometimes referred to as real user monitoring or RUM).
|
145
145
|
# browser_monitoring.auto_instrument: true
|
146
146
|
|
147
|
+
# If true, enables auto-injection of Content Security Policy Nonce in browser
|
148
|
+
# monitoring scripts. For now, auto-injection only works with Rails 5.2+.
|
149
|
+
# browser_monitoring.content_security_policy_nonce: false
|
150
|
+
|
147
151
|
# Manual override for the path to your local CA bundle. This CA bundle will be
|
148
152
|
# used to validate the SSL certificate presented by New Relic's data collection
|
149
153
|
# service.
|
@@ -415,6 +419,10 @@ common: &default_settings
|
|
415
419
|
# prepend, chain, disabled.
|
416
420
|
# instrumentation.delayed_job: auto
|
417
421
|
|
422
|
+
# Controls auto-instrumentation of the aws-sdk-dynamodb library at start-up. May
|
423
|
+
# be one of [auto|prepend|chain|disabled].
|
424
|
+
# instrumentation.dynamodb: auto
|
425
|
+
|
418
426
|
# Controls auto-instrumentation of the elasticsearch library at start-up. May be
|
419
427
|
# one of: auto, prepend, chain, disabled.
|
420
428
|
# instrumentation.elasticsearch: auto
|
@@ -629,6 +637,12 @@ common: &default_settings
|
|
629
637
|
# before shutting down.
|
630
638
|
# send_data_on_exit: true
|
631
639
|
|
640
|
+
# If true, the agent will operate in a streamlined mode suitable for use with
|
641
|
+
# short-lived serverless functions. NOTE: Only AWS Lambda functions are supported
|
642
|
+
# currently and this option is not intended for use without New Relic's Ruby
|
643
|
+
# Lambda layer offering.
|
644
|
+
# serverless_mode.enabled: false
|
645
|
+
|
632
646
|
# An array of strings that will collectively serve as a denylist for filtering
|
633
647
|
# which Sidekiq job arguments get reported to New Relic. To capture any Sidekiq
|
634
648
|
# arguments, 'job.sidekiq.args.*' must be added to the separate
|
data/test/agent_helper.rb
CHANGED
@@ -228,7 +228,9 @@ def assert_metrics_recorded(expected)
|
|
228
228
|
expected.each do |specish, expected_attrs|
|
229
229
|
expected_spec = metric_spec_from_specish(specish)
|
230
230
|
actual_stats = NewRelic::Agent.instance.stats_engine.to_h[expected_spec]
|
231
|
-
if
|
231
|
+
if actual_stats
|
232
|
+
assert(actual_stats)
|
233
|
+
else
|
232
234
|
all_specs = NewRelic::Agent.instance.stats_engine.to_h.keys.sort
|
233
235
|
matches = all_specs.select { |spec| spec.name == expected_spec.name }
|
234
236
|
matches.map! { |m| " #{m.inspect}" }
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: newrelic_rpm
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 9.
|
4
|
+
version: 9.10.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tanna McClure
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date: 2024-
|
14
|
+
date: 2024-05-29 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: bundler
|
@@ -243,6 +243,7 @@ files:
|
|
243
243
|
- bin/nrdebug
|
244
244
|
- init.rb
|
245
245
|
- install.rb
|
246
|
+
- lib/bootstrap.rb
|
246
247
|
- lib/new_relic/agent.rb
|
247
248
|
- lib/new_relic/agent/adaptive_sampler.rb
|
248
249
|
- lib/new_relic/agent/agent.rb
|
@@ -260,6 +261,7 @@ files:
|
|
260
261
|
- lib/new_relic/agent/attributes.rb
|
261
262
|
- lib/new_relic/agent/audit_logger.rb
|
262
263
|
- lib/new_relic/agent/autostart.rb
|
264
|
+
- lib/new_relic/agent/aws.rb
|
263
265
|
- lib/new_relic/agent/chained_call.rb
|
264
266
|
- lib/new_relic/agent/commands/agent_command.rb
|
265
267
|
- lib/new_relic/agent/commands/agent_command_router.rb
|
@@ -381,6 +383,10 @@ files:
|
|
381
383
|
- lib/new_relic/agent/instrumentation/delayed_job/instrumentation.rb
|
382
384
|
- lib/new_relic/agent/instrumentation/delayed_job/prepend.rb
|
383
385
|
- lib/new_relic/agent/instrumentation/delayed_job_instrumentation.rb
|
386
|
+
- lib/new_relic/agent/instrumentation/dynamodb.rb
|
387
|
+
- lib/new_relic/agent/instrumentation/dynamodb/chain.rb
|
388
|
+
- lib/new_relic/agent/instrumentation/dynamodb/instrumentation.rb
|
389
|
+
- lib/new_relic/agent/instrumentation/dynamodb/prepend.rb
|
384
390
|
- lib/new_relic/agent/instrumentation/elasticsearch.rb
|
385
391
|
- lib/new_relic/agent/instrumentation/elasticsearch/chain.rb
|
386
392
|
- lib/new_relic/agent/instrumentation/elasticsearch/instrumentation.rb
|
@@ -562,6 +568,7 @@ files:
|
|
562
568
|
- lib/new_relic/agent/samplers/memory_sampler.rb
|
563
569
|
- lib/new_relic/agent/samplers/object_sampler.rb
|
564
570
|
- lib/new_relic/agent/samplers/vm_sampler.rb
|
571
|
+
- lib/new_relic/agent/serverless_handler.rb
|
565
572
|
- lib/new_relic/agent/span_event_aggregator.rb
|
566
573
|
- lib/new_relic/agent/span_event_primitive.rb
|
567
574
|
- lib/new_relic/agent/sql_sampler.rb
|
@@ -716,7 +723,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
716
723
|
- !ruby/object:Gem::Version
|
717
724
|
version: 1.3.1
|
718
725
|
requirements: []
|
719
|
-
rubygems_version: 3.
|
726
|
+
rubygems_version: 3.5.9
|
720
727
|
signing_key:
|
721
728
|
specification_version: 4
|
722
729
|
summary: New Relic Ruby Agent
|