newrelic_rpm 9.11.0 → 9.13.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (57) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +112 -0
  3. data/README.md +16 -20
  4. data/lib/new_relic/agent/agent_logger.rb +1 -0
  5. data/lib/new_relic/agent/configuration/default_source.rb +136 -5
  6. data/lib/new_relic/agent/configuration/manager.rb +8 -0
  7. data/lib/new_relic/agent/database/obfuscator.rb +1 -0
  8. data/lib/new_relic/agent/instrumentation/active_merchant.rb +0 -13
  9. data/lib/new_relic/agent/instrumentation/bunny/instrumentation.rb +14 -0
  10. data/lib/new_relic/agent/instrumentation/delayed_job_instrumentation.rb +0 -19
  11. data/lib/new_relic/agent/instrumentation/elasticsearch/instrumentation.rb +1 -1
  12. data/lib/new_relic/agent/instrumentation/excon.rb +0 -16
  13. data/lib/new_relic/agent/instrumentation/grape.rb +3 -1
  14. data/lib/new_relic/agent/instrumentation/logstasher/chain.rb +21 -0
  15. data/lib/new_relic/agent/instrumentation/logstasher/instrumentation.rb +24 -0
  16. data/lib/new_relic/agent/instrumentation/logstasher/prepend.rb +13 -0
  17. data/lib/new_relic/agent/instrumentation/logstasher.rb +27 -0
  18. data/lib/new_relic/agent/instrumentation/opensearch/chain.rb +21 -0
  19. data/lib/new_relic/agent/instrumentation/opensearch/instrumentation.rb +66 -0
  20. data/lib/new_relic/agent/instrumentation/opensearch/prepend.rb +13 -0
  21. data/lib/new_relic/agent/instrumentation/opensearch.rb +25 -0
  22. data/lib/new_relic/agent/instrumentation/rack/instrumentation.rb +3 -0
  23. data/lib/new_relic/agent/instrumentation/rails_notifications/action_controller.rb +9 -5
  24. data/lib/new_relic/agent/instrumentation/redis/cluster_middleware.rb +26 -0
  25. data/lib/new_relic/agent/instrumentation/redis/instrumentation.rb +14 -11
  26. data/lib/new_relic/agent/instrumentation/redis/middleware.rb +3 -0
  27. data/lib/new_relic/agent/instrumentation/redis.rb +11 -4
  28. data/lib/new_relic/agent/instrumentation/sidekiq.rb +0 -14
  29. data/lib/new_relic/agent/instrumentation/sinatra.rb +0 -13
  30. data/lib/new_relic/agent/local_log_decorator.rb +8 -1
  31. data/lib/new_relic/agent/log_event_aggregator.rb +91 -26
  32. data/lib/new_relic/agent/serverless_handler.rb +241 -12
  33. data/lib/new_relic/agent/serverless_handler_event_sources.json +155 -0
  34. data/lib/new_relic/agent/serverless_handler_event_sources.rb +49 -0
  35. data/lib/new_relic/agent/system_info.rb +14 -0
  36. data/lib/new_relic/agent/transaction/trace_context.rb +1 -1
  37. data/lib/new_relic/control/frameworks/grape.rb +14 -0
  38. data/lib/new_relic/control/frameworks/padrino.rb +14 -0
  39. data/lib/new_relic/control/frameworks/rails4.rb +4 -2
  40. data/lib/new_relic/control/instance_methods.rb +1 -0
  41. data/lib/new_relic/control/private_instance_methods.rb +4 -0
  42. data/lib/new_relic/control/security_interface.rb +57 -0
  43. data/lib/new_relic/control.rb +1 -1
  44. data/lib/new_relic/environment_report.rb +6 -2
  45. data/lib/new_relic/language_support.rb +7 -1
  46. data/lib/new_relic/local_environment.rb +1 -4
  47. data/lib/new_relic/rack/browser_monitoring.rb +11 -7
  48. data/lib/new_relic/version.rb +1 -1
  49. data/lib/tasks/config.rake +5 -2
  50. data/lib/tasks/helpers/config.html.erb +1 -1
  51. data/lib/tasks/helpers/format.rb +1 -1
  52. data/lib/tasks/helpers/newrelicyml.rb +76 -13
  53. data/lib/tasks/instrumentation_generator/instrumentation.thor +1 -0
  54. data/lib/tasks/instrumentation_generator/templates/dependency_detection.tt +3 -3
  55. data/newrelic.yml +209 -137
  56. data/test/agent_helper.rb +9 -0
  57. metadata +16 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: cc36449c6f2ea3322f353181809c05d3e84e28f85fb15544c82e088946384046
4
- data.tar.gz: f8fa907597f05f47c5dbe9c38a005cb1d09f971183aa7075664e6ade029186fc
3
+ metadata.gz: 4322e3b796a1a4656be8f68f98c18f79a4f6f86f3dd36ba1186def73a993c6db
4
+ data.tar.gz: e87b88f88a979bc1ff4259643081308670dd860750d12e21cfb6cd45fa3b6004
5
5
  SHA512:
6
- metadata.gz: 622cdf275eb70aa1f57e027f2e73559855c17c4351741c80ec0db8ae45b773f2d7aa2831ae562e228b24a71a0532ae93dced167be3ecfdd3561886224d212070
7
- data.tar.gz: a68a148e494bfc0e5f9da3c369eb56f7170664e78ffd12cc178e77b7361da39edefbc967b5c71c2905b993b5d4075b2189abc3ec7692081d6b4dd422149902f3
6
+ metadata.gz: e53d1172e55be6cf3f66f12f3926361af7485361e1e8c2e097f725241148bbbc5cb59853ce6d255a7c34871f3530424466b621b5cab467383d9e654c0c8108d4
7
+ data.tar.gz: b61902a91a3909760b52797c74f7ef24e5b6f5c282ffd1bfb95451585b052004323fe6c3eb9843e208dcdfdd9382684d8f01a950051e8f7d082269d2ed7134e0
data/CHANGELOG.md CHANGED
@@ -1,5 +1,117 @@
1
1
  # New Relic Ruby Agent Release Notes
2
2
 
3
+ ## v9.13.0
4
+
5
+ Version 9.13.0 enhances support for AWS Lambda functions, adds experimental OpenSearch instrumentation, updates framework detection, silences a Bundler deprecation warning, fixes Falcon dispatcher detection, fixes a bug with Redis instrumentation installation, and addresses a JRuby-specific concurrency issue.
6
+
7
+ - **Feature: Enhance AWS Lambda function instrumentation**
8
+
9
+ When utilized via the latest [New Relic Ruby layer for AWS Lambda](https://layers.newrelic-external.com/), the agent now offers enhanced support for AWS Lambda function instrumentation.
10
+ * The agent's instrumentation for AWS Lambda functions now supports distributed tracing.
11
+ * Web-triggered invocations are now identified as being "web"-based when an API Gateway call is involved, with support for both API Gateway versions 1.0 and 2.0.
12
+ * Web-based calls have the HTTP method, URI, and status code recorded.
13
+ * The agent now recognizes and reports on 12 separate AWS resources that are capable of triggering a Lambda function invocation: ALB, API Gateway V1, API Gateway V2, CloudFront, CloudWatch Scheduler, DynamoStreams, Firehose, Kinesis, S3, SES, SNS, and SQS.
14
+ * The type of the triggering resource and its ARN will be recorded for each resource, and for many of them, extra resource-specific attributes will be recorded as well. For example, Lambda function invocations triggered by S3 bucket activity will now result in the S3 bucket name being recorded.
15
+ [PR#2811](https://github.com/newrelic/newrelic-ruby-agent/pull/2811)
16
+
17
+ - **Feature: Add experimental OpenSearch instrumentation**
18
+
19
+ The agent will now automatically instrument the `opensearch-ruby` gem. We're marking this instrumentation as experimental because more work is needed to fully test it. OpenSearch instrumentation provides telemetry similar to Elasticsearch. Thank you, [@Earlopain](https://github.com/Earlopain) for reporting the issue and [@praveen-ks](https://github.com/praveen-ks) for an initial draft of the instrumentation. [Issue#2228](https://github.com/newrelic/newrelic-ruby-agent/issues/2228) [PR#2796](https://github.com/newrelic/newrelic-ruby-agent/pull/2796)
20
+
21
+ - **Feature: Improve framework detection accuracy for Grape and Padrino**
22
+
23
+ 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)
24
+
25
+ - **Feature: Silence Bundler `all_specs` deprecation warning**
26
+
27
+ `Bundler.rubygems.all_specs` was deprecated in favor of `Bundler.rubygems.installed_specs` in Bundler versions 2+, causing the agent to emit deprecation warnings. The method has been updated when Bundler 2+ is detected and warnings are now silenced. Thanks to [@jcoyne](https://github.com/jcoyne) for reporting this issue. [Issue#2733](https://github.com/newrelic/newrelic-ruby-agent/issues/2733) [PR#2823](https://github.com/newrelic/newrelic-ruby-agent/pull/2823)
28
+
29
+ - **Bugfix: Fix Falcon dispatcher detection**
30
+
31
+ 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)
32
+
33
+ - **Bugfix: Fix for a Redis instrumentation error when Redis::Cluster::Client is present**
34
+
35
+ The Redis instrumentation previously contained a bug that would cause it to error out when `Redis::Cluster::Client` was present, owing to the use of a Ruby `return` outside of a method. Thanks very much to [@jdelStrother](https://github.com/jdelStrother) for not only reporting this bug but pointing us to the root cause as well. [Issue#2814](https://github.com/newrelic/newrelic-ruby-agent/issues/2814) [PR#2816](https://github.com/newrelic/newrelic-ruby-agent/pull/2816)
36
+
37
+ - **Bugfix: Address JRuby concurrency issue with config hash accessing**
38
+
39
+ The agent's internal configuration class maintains a hash that occassionally gets rebuilt. During the rebuild, certain previously dynamically determined instrumentation values are preserved for the benefit of the [New Relic Ruby security agent](https://github.com/newrelic/csec-ruby-agent). After reports from JRuby customers regarding concurrency issues related to the hash being accessed while being modified, two separate fixes went into the hash rebuild logic previously: a `Hash#dup` operation and a `synchronize do` block. But errors were still reported. We ourselves remain unable to reproduce these concurrency errors despite using the same exact versions of JRuby and all reported software. After confirming that the hash access code in question is only needed for the Ruby security agent (which operates only in non-production dedicated security testing environments), we have introduced a new fix for JRuby customers that will simply skip over the troublesome code when JRuby is in play but the security agent is not. [PR#2798](https://github.com/newrelic/newrelic-ruby-agent/pull/2798)
40
+
41
+ ## v9.12.0
42
+
43
+ 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.
44
+
45
+ - **Feature: Add support for the newrelic_security agent**
46
+
47
+ [New Relic Interactive Application Security Testing (IAST)](https://docs.newrelic.com/docs/iast/introduction/) can help you prevent cyberattacks and breaches on your applications by probing your running code for exploitable vulnerabilities.
48
+
49
+ The `newrelic_security` gem provides this feature for Ruby. It depends on `newrelic_rpm`. This is the first version of `newrelic_rpm` compatible with `newrelic_security`.
50
+
51
+ At this time, the security agent is intended for use only within a dedicated security testing environment with data that can tolerate modification or deletion. The security agent is available as a separate Ruby gem, `newrelic_security`. It is recommended that this separate gem only be introduced to a security testing environment by leveraging Bundler grouping like so:
52
+
53
+ ```ruby
54
+ # Gemfile
55
+ gem 'newrelic_rpm' # New Relic APM observability agent
56
+ gem 'newrelic-infinite_tracing' # New Relic Infinite Tracing
57
+
58
+ group :security do
59
+ gem 'newrelic_security', require: false # New Relic security agent
60
+ end
61
+ ```
62
+
63
+ In order to run the security agent, you need to update your configuration. At a minimum, `security.agent.enabled` and `security.enabled` must be set to `true`. They are `false` by default. Similar to the gem installation, we recommend you set these configurations for a special security testing environment only.
64
+
65
+ Here's an example using `newrelic.yml`:
66
+
67
+ ```yaml
68
+ common: &default_settings
69
+ license_key: <%= ENV['NEW_RELIC_LICENSE_KEY'] %>
70
+ app_name: "Example app"
71
+
72
+ development:
73
+ <<: *default_settings
74
+ app_name: <%= app_name %> (Development)
75
+
76
+ security:
77
+ <<: *default_settings
78
+ security.enabled: true
79
+ security.agent.enabled: true
80
+
81
+ production:
82
+ <<: *default_settings
83
+ ```
84
+
85
+ The following configuration relate to the `newrelic_security` gem:
86
+
87
+ | Configuration name | Default | Behavior |
88
+ | ------------------ | ------- |----------|
89
+ | security.agent.enabled | `false` | If `true`, the security agent is loaded (a Ruby 'require' is performed) |
90
+ | security.enabled | `false` | If `true`, the security agent is started (the agent runs in its event loop) |
91
+ | security.mode | `'IAST'` | Defines the mode for the security agent to operate in. Currently only 'IAST' is supported |
92
+ | security.validator_service_url | `'wss://csec.nr-data.net'` | Defines the endpoint URL for posting security related data |
93
+ | security.detection.rci.enabled | `true` | If `true`, enables RCI (remote code injection) detection |
94
+ | security.detection.rxss.enabled | `true` | If `true`, enables RXSS (reflected cross-site scripting) detection |
95
+ | security.detection.deserialization.enabled | `true` | If `true`, enables deserialization detection |
96
+ | security.application_info.port | `nil` | An Integer representing the port the application is listening on. This setting is mandatory for Passenger servers. Other servers should be detected by default. |
97
+
98
+ - **Feature: Add instrumentation for LogStasher**
99
+
100
+ The agent will now record logs generated by [LogStasher](https://github.com/shadabahmed/logstasher). Versions 1.0.0 and above of the LogStasher gem are supported. [PR#2559](https://github.com/newrelic/newrelic-ruby-agent/pull/2559)
101
+
102
+ - **Feature: Add instrumentation for redis-clustering**
103
+
104
+ Version 5.x of the `redis` gem moved cluster behavior into a different gem, `redis-clustering`. This gem can access instrumentation registered through `RedisClient::Middleware`. Previously, the agent only instrumented the `call_pipelined` method through this approach, but now users of the `redis-clustering` gem will also have instrumentation registered for `connect` and `call` methods. In addition, the way the `database_name` attribute is set for Redis datastore spans is now compatible with all versions of Redis supported by the New Relic Ruby agent. Thank you, [@praveen-ks](https://github.com/praveen-ks) for bringing this to our attention. [Issue#2444](https://github.com/newrelic/newrelic-ruby-agent/issues/2444) [PR#2720](https://github.com/newrelic/newrelic-ruby-agent/pull/2720)
105
+
106
+ - **Bugfix: Update Elasticsearch instrumentation to only attempt to get the cluster name once per client**
107
+
108
+ Previously, the agent would attempt to get the cluster name every time a call was made if it was not already captured. This could lead to a large number of failures if the cluster name could not be retrieved. Now, the agent will only attempt to get the cluster name once per client, even if it fails. Thank you, [@ascoppa](https://github.com/ascoppa) for bringing this to our attention. [Issue#2730](https://github.com/newrelic/newrelic-ruby-agent/issues/2730) [PR#2743](https://github.com/newrelic/newrelic-ruby-agent/pull/2743)
109
+
110
+ - **Feature: Produce metrics for 4 additional Action Controller Rails notifications**
111
+
112
+ Four additional Action Controller related Rails notifications are now subscribed to by the agent to produce telemetry. These 4 are `exist_fragment?`, `expire_fragment`, `read_fragment`, and `write_fragment`. As with instrumentation for Action Controller itself, these notifications are enabled by default and can be disabled by setting `:disable_action_controller` to `true` in the agent's `newrelic.yml` configuration file. [PR#2745](https://github.com/newrelic/newrelic-ruby-agent/pull/2745)
113
+
114
+
3
115
  ## v9.11.0
4
116
 
5
117
  Version 9.11.0 introduces instrumentation for the aws-sdk-sqs gem, fixes a bug related to expected errors not bearing a "true" value for the "expected" attribute if expected as a result of an HTTP status code match and changes the way Stripe instrumentation metrics are named to prevent high-cardinality issues.
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  <a href="https://opensource.newrelic.com/oss-category/#community-plus"><picture><source media="(prefers-color-scheme: dark)" srcset="https://github.com/newrelic/opensource-website/raw/main/src/images/categories/dark/Community_Plus.png"><source media="(prefers-color-scheme: light)" srcset="https://github.com/newrelic/opensource-website/raw/main/src/images/categories/Community_Plus.png"><img alt="New Relic Open Source community plus project banner." src="https://github.com/newrelic/opensource-website/raw/main/src/images/categories/Community_Plus.png"></picture></a>
2
2
 
3
- # New Relic Ruby Agent
3
+ # New Relic Ruby agent
4
4
 
5
5
  The New Relic Ruby agent monitors your applications to help you
6
6
  [identify and solve performance issues](https://docs.newrelic.com/docs/agents/ruby-agent/getting-started/introduction-new-relic-ruby#monitor-performance).
@@ -15,7 +15,7 @@ This code is actively maintained by New Relic engineering teams and delivered he
15
15
 
16
16
  [![Gem Version](https://badge.fury.io/rb/newrelic_rpm.svg)](https://badge.fury.io/rb/newrelic_rpm)
17
17
 
18
- ## Supported Environments
18
+ ## Supported environments
19
19
 
20
20
  An up-to-date list of Ruby versions and frameworks for the latest agent
21
21
  can be found on [our docs site](http://docs.newrelic.com/docs/ruby/supported-frameworks).
@@ -23,14 +23,11 @@ can be found on [our docs site](http://docs.newrelic.com/docs/ruby/supported-fra
23
23
  You can also monitor non-web applications. Refer to the "Other
24
24
  Environments" section below.
25
25
 
26
- We offer an AWS Lambda layer for instrumenting your serverless Ruby functions.
27
- Details can be found on our [getting started guide](https://docs.newrelic.com/docs/serverless-function-monitoring/aws-lambda-monitoring/get-started/monitoring-aws-lambda-serverless-monitoring/).
28
-
29
- ## Installing and Using
26
+ ## Installing and using
30
27
 
31
28
  The latest released gem for the Ruby agent can be found at [RubyGems.org](https://rubygems.org/gems/newrelic_rpm)
32
29
 
33
- ### Quick Start
30
+ ### Quick start
34
31
 
35
32
  #### With Bundler
36
33
 
@@ -56,7 +53,7 @@ and then require the New Relic Ruby agent in your Ruby start-up sequence:
56
53
  require 'newrelic_rpm'
57
54
  ```
58
55
 
59
- #### Other Environments
56
+ #### Other environments
60
57
 
61
58
  Assuming you have installed the agent per above, you may also need to tell the Ruby agent to start for some frameworks and non-framework environments. To do so, add the following to your Ruby start-up sequence start the agent:
62
59
 
@@ -64,29 +61,29 @@ Assuming you have installed the agent per above, you may also need to tell the R
64
61
  NewRelic::Agent.manual_start
65
62
  ```
66
63
 
67
- ### Complete Install Instructions
64
+ ### Complete install instructions
68
65
 
69
66
  For complete documentation on installing the New Relic Ruby agent, see the following links:
70
67
 
71
68
  * [Introduction](https://docs.newrelic.com/docs/agents/ruby-agent/getting-started/introduction-new-relic-ruby)
72
- * [Install the New Relic Ruby agent](https://docs.newrelic.com/docs/agents/ruby-agent/installation/install-new-relic-ruby-agent)
69
+ * [Install the New Relic Ruby agent](https://docs.newrelic.com/docs/agents/ruby-agent/installation/install-new-relic-ruby-agent). See also these docs that cover specific install scenarios:
70
+ * [Rails plugin installation](https://docs.newrelic.com/docs/agents/ruby-agent/installation/ruby-agent-installation-rails-plugin)
71
+ * [AWS Lambda](https://docs.newrelic.com/docs/serverless-function-monitoring/aws-lambda-monitoring/instrument-lambda-function/instrument-your-own/)
72
+ * [GAE Flexible Environment](https://docs.newrelic.com/docs/agents/ruby-agent/installation/install-new-relic-ruby-agent-gae-flexible-environment)
73
+ * [Pure Rack apps](http://docs.newrelic.com/docs/ruby/rack-middlewares)
74
+ * [Ruby agent and Heroku](https://docs.newrelic.com/docs/agents/ruby-agent/installation/ruby-agent-heroku)
75
+ * [Background jobs](https://docs.newrelic.com/docs/agents/ruby-agent/background-jobs/monitor-ruby-background-processes)
73
76
  * [Configure the agent](https://docs.newrelic.com/docs/agents/ruby-agent/configuration/ruby-agent-configuration)
74
77
  * [Update the agent](https://docs.newrelic.com/docs/agents/ruby-agent/installation/update-ruby-agent)
75
- * [Rails plugin installation](https://docs.newrelic.com/docs/agents/ruby-agent/installation/ruby-agent-installation-rails-plugin)
76
- * [GAE Flexible Environment](https://docs.newrelic.com/docs/agents/ruby-agent/installation/install-new-relic-ruby-agent-gae-flexible-environment)
77
- * [Pure Rack Apps](http://docs.newrelic.com/docs/ruby/rack-middlewares)
78
- * [Ruby agent and Heroku](https://docs.newrelic.com/docs/agents/ruby-agent/installation/ruby-agent-heroku)
79
- * [Background Jobs](https://docs.newrelic.com/docs/agents/ruby-agent/background-jobs/monitor-ruby-background-processes)
80
78
  * [Uninstall the Ruby agent](https://docs.newrelic.com/docs/agents/ruby-agent/installation/uninstall-ruby-agent)
81
79
 
82
- ### Recording Deploys
80
+ ### Recording deploys
83
81
 
84
82
  The Ruby agent supports recording deployments in New Relic via a command line
85
83
  tool or Capistrano recipes. For more information on these features, see
86
84
  [our deployment documentation](http://docs.newrelic.com/docs/ruby/recording-deployments-with-the-ruby-agent)
87
85
  for more information.
88
86
 
89
-
90
87
  ## Support
91
88
 
92
89
  Should you need assistance with New Relic products, you are in good hands with several support diagnostic tools and support channels.
@@ -97,11 +94,10 @@ New Relic offers NRDiag, [a client-side diagnostic utility](https://docs.newreli
97
94
 
98
95
  If the issue has been confirmed as a bug or is a Feature request, please file a GitHub issue.
99
96
 
100
- **Support Channels**
97
+ **Support channels**
101
98
 
102
99
  * [New Relic Documentation](https://docs.newrelic.com/docs/agents/ruby-agent): Comprehensive guidance for using our platform
103
100
  * [New Relic Community](https://forum.newrelic.com): The best place to engage in troubleshooting questions
104
- * [New Relic Developer](https://developer.newrelic.com/): Resources for building a custom observability applications
105
101
  * [New Relic University](https://learn.newrelic.com/): A range of online training for New Relic users of every level
106
102
  * [New Relic Technical Support](https://support.newrelic.com/) 24/7/365 ticketed support. Read more about our [Technical Support Offerings](https://docs.newrelic.com/docs/licenses/license-information/general-usage-licenses/support-plan).
107
103
 
@@ -135,7 +131,7 @@ As of version 6.12 (released July 16, 2020), the New Relic Ruby agent is license
135
131
 
136
132
  The New Relic Ruby agent may use source code from third-party libraries. When used, these libraries will be outlined in [THIRD_PARTY_NOTICES.md](THIRD_PARTY_NOTICES.md).
137
133
 
138
- ## Thank You
134
+ ## Thank you
139
135
 
140
136
  We always look forward to connecting with the community. We welcome [contributions](https://github.com/newrelic/newrelic-ruby-agent#contributing) to our source code and suggestions for improvements, and would love to hear about what you like and want to see in the future.
141
137
 
@@ -4,6 +4,7 @@
4
4
 
5
5
  require 'thread'
6
6
  require 'logger'
7
+ require 'singleton'
7
8
  require 'new_relic/agent/hostname'
8
9
  require 'new_relic/agent/log_once'
9
10
  require 'new_relic/agent/instrumentation/logger/instrumentation'
@@ -72,7 +72,7 @@ module NewRelic
72
72
  value_from_defaults(key, :transform)
73
73
  end
74
74
 
75
- def self.config_search_paths # rubocop:disable Metrics/AbcSize
75
+ def self.config_search_paths
76
76
  proc {
77
77
  yaml = 'newrelic.yml'
78
78
  config_yaml = File.join('config', yaml)
@@ -130,8 +130,10 @@ module NewRelic
130
130
  ::NewRelic::Agent.logger.warn("Detected untested Rails version #{Rails::VERSION::STRING}")
131
131
  :rails_notifications
132
132
  end
133
+ when defined?(::Padrino) && defined?(::Padrino::PathRouter::Router) then :padrino
133
134
  when defined?(::Sinatra) && defined?(::Sinatra::Base) then :sinatra
134
135
  when defined?(::Roda) then :roda
136
+ when defined?(::Grape) then :grape
135
137
  when defined?(::NewRelic::IA) then :external
136
138
  else :ruby
137
139
  end
@@ -1112,7 +1114,7 @@ module NewRelic
1112
1114
  :public => true,
1113
1115
  :type => Boolean,
1114
1116
  :allowed_from_server => true,
1115
- :description => "If `true`, the agent will report source code level metrics for traced methods.\nsee: " \
1117
+ :description => "If `true`, the agent will report source code level metrics for traced methods.\nSee: " \
1116
1118
  'https://docs.newrelic.com/docs/apm/agents/ruby-agent/features/ruby-codestream-integration/'
1117
1119
  },
1118
1120
  # Cross application tracer
@@ -1149,9 +1151,10 @@ module NewRelic
1149
1151
  :type => Integer,
1150
1152
  :allowed_from_server => true,
1151
1153
  :dynamic_name => true,
1154
+ # Keep the extra two-space indent before the second bullet to appease translation tool
1152
1155
  :description => <<~DESC
1153
- * Specify a maximum number of custom events to buffer in memory at a time.'
1154
- * When configuring the agent for [AI monitoring](/docs/ai-monitoring/intro-to-ai-monitoring), \
1156
+ * Specify a maximum number of custom events to buffer in memory at a time.
1157
+ * When configuring the agent for [AI monitoring](/docs/ai-monitoring/intro-to-ai-monitoring), \
1155
1158
  set to max value `100000`. This ensures the agent captures the maximum amount of LLM events.
1156
1159
  DESC
1157
1160
  },
@@ -1444,6 +1447,7 @@ module NewRelic
1444
1447
  },
1445
1448
  :'instrumentation.async_http' => {
1446
1449
  :default => 'auto',
1450
+ :documentation_default => 'auto',
1447
1451
  :public => true,
1448
1452
  :type => String,
1449
1453
  :dynamic_name => true,
@@ -1452,12 +1456,22 @@ module NewRelic
1452
1456
  },
1453
1457
  :'instrumentation.bunny' => {
1454
1458
  :default => 'auto',
1459
+ :documentation_default => 'auto',
1455
1460
  :public => true,
1456
1461
  :type => String,
1457
1462
  :dynamic_name => true,
1458
1463
  :allowed_from_server => false,
1459
1464
  :description => 'Controls auto-instrumentation of bunny at start-up. May be one of: `auto`, `prepend`, `chain`, `disabled`.'
1460
1465
  },
1466
+ :'instrumentation.opensearch' => {
1467
+ :default => 'auto',
1468
+ :documentation_default => 'auto',
1469
+ :public => true,
1470
+ :type => String,
1471
+ :dynamic_name => true,
1472
+ :allowed_from_server => false,
1473
+ :description => 'Controls auto-instrumentation of the opensearch-ruby library at start-up. May be one of `auto`, `prepend`, `chain`, `disabled`.'
1474
+ },
1461
1475
  :'instrumentation.aws_sqs' => {
1462
1476
  :default => 'auto',
1463
1477
  :public => true,
@@ -1468,6 +1482,7 @@ module NewRelic
1468
1482
  },
1469
1483
  :'instrumentation.dynamodb' => {
1470
1484
  :default => 'auto',
1485
+ :documentation_default => 'auto',
1471
1486
  :public => true,
1472
1487
  :type => String,
1473
1488
  :dynamic_name => true,
@@ -1476,6 +1491,7 @@ module NewRelic
1476
1491
  },
1477
1492
  :'instrumentation.fiber' => {
1478
1493
  :default => 'auto',
1494
+ :documentation_default => 'auto',
1479
1495
  :public => true,
1480
1496
  :type => String,
1481
1497
  :dynamic_name => true,
@@ -1484,6 +1500,7 @@ module NewRelic
1484
1500
  },
1485
1501
  :'instrumentation.concurrent_ruby' => {
1486
1502
  :default => 'auto',
1503
+ :documentation_default => 'auto',
1487
1504
  :public => true,
1488
1505
  :type => String,
1489
1506
  :dynamic_name => true,
@@ -1510,6 +1527,7 @@ module NewRelic
1510
1527
  },
1511
1528
  :'instrumentation.elasticsearch' => {
1512
1529
  :default => 'auto',
1530
+ :documentation_default => 'auto',
1513
1531
  :public => true,
1514
1532
  :type => String,
1515
1533
  :dynamic_name => true,
@@ -1518,6 +1536,7 @@ module NewRelic
1518
1536
  },
1519
1537
  :'instrumentation.ethon' => {
1520
1538
  :default => 'auto',
1539
+ :documentation_default => 'auto',
1521
1540
  :public => true,
1522
1541
  :type => String,
1523
1542
  :dynamic_name => true,
@@ -1535,6 +1554,7 @@ module NewRelic
1535
1554
  },
1536
1555
  :'instrumentation.grape' => {
1537
1556
  :default => 'auto',
1557
+ :documentation_default => 'auto',
1538
1558
  :public => true,
1539
1559
  :type => String,
1540
1560
  :dynamic_name => true,
@@ -1603,8 +1623,18 @@ module NewRelic
1603
1623
  :allowed_from_server => false,
1604
1624
  :description => 'Controls auto-instrumentation of Ruby standard library Logger at start-up. May be one of: `auto`, `prepend`, `chain`, `disabled`.'
1605
1625
  },
1626
+ :'instrumentation.logstasher' => {
1627
+ :default => instrumentation_value_from_boolean(:'application_logging.enabled'),
1628
+ :documentation_default => 'auto',
1629
+ :public => true,
1630
+ :type => String,
1631
+ :dynamic_name => true,
1632
+ :allowed_from_server => false,
1633
+ :description => 'Controls auto-instrumentation of the LogStasher library at start-up. May be one of: `auto`, `prepend`, `chain`, `disabled`.'
1634
+ },
1606
1635
  :'instrumentation.memcache' => {
1607
1636
  :default => 'auto',
1637
+ :documentation_default => 'auto',
1608
1638
  :public => true,
1609
1639
  :type => String,
1610
1640
  :dynamic_name => true,
@@ -1698,6 +1728,7 @@ module NewRelic
1698
1728
  },
1699
1729
  :'instrumentation.rake' => {
1700
1730
  :default => 'auto',
1731
+ :documentation_default => 'auto',
1701
1732
  :public => true,
1702
1733
  :type => String,
1703
1734
  :dynamic_name => true,
@@ -1706,6 +1737,7 @@ module NewRelic
1706
1737
  },
1707
1738
  :'instrumentation.redis' => {
1708
1739
  :default => 'auto',
1740
+ :documentation_default => 'auto',
1709
1741
  :public => true,
1710
1742
  :type => String,
1711
1743
  :dynamic_name => true,
@@ -1723,6 +1755,7 @@ module NewRelic
1723
1755
  },
1724
1756
  :'instrumentation.roda' => {
1725
1757
  :default => 'auto',
1758
+ :documentation_default => 'auto',
1726
1759
  :public => true,
1727
1760
  :type => String,
1728
1761
  :dynamic_name => true,
@@ -1731,6 +1764,7 @@ module NewRelic
1731
1764
  },
1732
1765
  :'instrumentation.sinatra' => {
1733
1766
  :default => 'auto',
1767
+ :documentation_default => 'auto',
1734
1768
  :public => true,
1735
1769
  :type => String,
1736
1770
  :dynamic_name => true,
@@ -1746,6 +1780,7 @@ module NewRelic
1746
1780
  },
1747
1781
  :'instrumentation.view_component' => {
1748
1782
  :default => 'auto',
1783
+ :documentation_default => 'auto',
1749
1784
  :public => true,
1750
1785
  :type => String,
1751
1786
  :dynamic_name => true,
@@ -1782,6 +1817,7 @@ module NewRelic
1782
1817
  },
1783
1818
  :'instrumentation.thread' => {
1784
1819
  :default => 'auto',
1820
+ :documentation_default => 'auto',
1785
1821
  :public => true,
1786
1822
  :type => String,
1787
1823
  :dynamic_name => true,
@@ -1804,6 +1840,7 @@ module NewRelic
1804
1840
  },
1805
1841
  :'instrumentation.tilt' => {
1806
1842
  :default => 'auto',
1843
+ :documentation_default => 'auto',
1807
1844
  :public => true,
1808
1845
  :type => String,
1809
1846
  :dynamic_name => true,
@@ -1842,6 +1879,21 @@ module NewRelic
1842
1879
  :allowed_from_server => true,
1843
1880
  :description => 'If `true`, the agent obfuscates Mongo queries in transaction traces.'
1844
1881
  },
1882
+ # OpenSearch
1883
+ :'opensearch.capture_queries' => {
1884
+ :default => true,
1885
+ :public => true,
1886
+ :type => Boolean,
1887
+ :allowed_from_server => true,
1888
+ :description => 'If `true`, the agent captures OpenSearch queries in transaction traces.'
1889
+ },
1890
+ :'opensearch.obfuscate_queries' => {
1891
+ :default => true,
1892
+ :public => true,
1893
+ :type => Boolean,
1894
+ :allowed_from_server => true,
1895
+ :description => 'If `true`, the agent obfuscates OpenSearch queries in transaction traces.'
1896
+ },
1845
1897
  # Process host
1846
1898
  :'process_host.display_name' => {
1847
1899
  :default => proc { NewRelic::Agent::Hostname.get },
@@ -1997,9 +2049,10 @@ module NewRelic
1997
2049
  :public => true,
1998
2050
  :type => Integer,
1999
2051
  :allowed_from_server => true,
2052
+ # Keep the extra two-space indent before the second bullet to appease translation tool
2000
2053
  :description => <<~DESC
2001
2054
  * Defines the maximum number of span events reported from a single harvest. Any Integer between `1` and `10000` is valid.'
2002
- * When configuring the agent for [AI monitoring](/docs/ai-monitoring/intro-to-ai-monitoring), set to max value `10000`.\
2055
+ * When configuring the agent for [AI monitoring](/docs/ai-monitoring/intro-to-ai-monitoring), set to max value `10000`.\
2003
2056
  This ensures the agent captures the maximum amount of distributed traces.
2004
2057
  DESC
2005
2058
  },
@@ -2514,6 +2567,84 @@ module NewRelic
2514
2567
  :type => Integer,
2515
2568
  :allowed_from_server => false,
2516
2569
  :description => 'This value represents the total amount of memory available to the host (not the process), in mebibytes (1024 squared or 1,048,576 bytes).'
2570
+ },
2571
+ # security agent
2572
+ :'security.agent.enabled' => {
2573
+ :default => false,
2574
+ :external => true,
2575
+ :public => true,
2576
+ :type => Boolean,
2577
+ :allowed_from_server => false,
2578
+ :description => "If `true`, the security agent is loaded (a Ruby 'require' is performed)"
2579
+ },
2580
+ :'security.enabled' => {
2581
+ :default => false,
2582
+ :external => true,
2583
+ :public => true,
2584
+ :type => Boolean,
2585
+ :allowed_from_server => false,
2586
+ :description => 'If `true`, the security agent is started (the agent runs in its event loop)'
2587
+ },
2588
+ :'security.mode' => {
2589
+ :default => 'IAST',
2590
+ :external => true,
2591
+ :public => true,
2592
+ :type => String,
2593
+ :allowed_from_server => true,
2594
+ :allowlist => %w[IAST RASP],
2595
+ :description => 'Defines the mode for the security agent to operate in. Currently only `IAST` is supported',
2596
+ :dynamic_name => true
2597
+ },
2598
+ :'security.validator_service_url' => {
2599
+ :default => 'wss://csec.nr-data.net',
2600
+ :external => true,
2601
+ :public => true,
2602
+ :type => String,
2603
+ :allowed_from_server => true,
2604
+ :description => 'Defines the endpoint URL for posting security-related data',
2605
+ :dynamic_name => true
2606
+ },
2607
+ :'security.detection.rci.enabled' => {
2608
+ :default => true,
2609
+ :external => true,
2610
+ :public => true,
2611
+ :type => Boolean,
2612
+ :allowed_from_server => false,
2613
+ :description => 'If `true`, enables RCI (remote code injection) detection'
2614
+ },
2615
+ :'security.detection.rxss.enabled' => {
2616
+ :default => true,
2617
+ :external => true,
2618
+ :public => true,
2619
+ :type => Boolean,
2620
+ :allowed_from_server => false,
2621
+ :description => 'If `true`, enables RXSS (reflected cross-site scripting) detection'
2622
+ },
2623
+ :'security.detection.deserialization.enabled' => {
2624
+ :default => true,
2625
+ :external => true,
2626
+ :public => true,
2627
+ :type => Boolean,
2628
+ :allowed_from_server => false,
2629
+ :description => 'If `true`, enables deserialization detection'
2630
+ },
2631
+ :'security.application_info.port' => {
2632
+ :default => nil,
2633
+ :allow_nil => true,
2634
+ :public => true,
2635
+ :type => Integer,
2636
+ :external => true,
2637
+ :allowed_from_server => false,
2638
+ :description => 'The port the application is listening on. This setting is mandatory for Passenger servers. Other servers should be detected by default.'
2639
+ },
2640
+ :'security.request.body_limit' => {
2641
+ :default => 300,
2642
+ :allow_nil => true,
2643
+ :public => true,
2644
+ :type => Integer,
2645
+ :external => true,
2646
+ :allowed_from_server => false,
2647
+ :description => 'Defines the request body limit to process in security events (in KB). The default value is 300, for 300KB.'
2517
2648
  }
2518
2649
  }.freeze
2519
2650
  # rubocop:enable Metrics/CollectionLiteralLength
@@ -382,6 +382,14 @@ module NewRelic
382
382
  def reset_cache
383
383
  return new_cache unless defined?(@cache) && @cache
384
384
 
385
+ # Modifying the @cache hash under JRuby - even with a `synchronize do`
386
+ # block and a `Hash#dup` operation - has been known to cause issues
387
+ # with JRuby for concurrent access of the hash while it is being
388
+ # modified. The hash really only needs to be modified for the benefit
389
+ # of the security agent, so if JRuby is in play and the security agent
390
+ # is not, don't attempt to modify the hash at all and return early.
391
+ return @cache if NewRelic::LanguageSupport.jruby? && !Agent.config[:'security.agent.enabled']
392
+
385
393
  @lock.synchronize do
386
394
  preserved = @cache.dup.select { |_k, v| DEPENDENCY_DETECTION_VALUES.include?(v) }
387
395
  new_cache
@@ -2,6 +2,7 @@
2
2
  # See https://github.com/newrelic/newrelic-ruby-agent/blob/main/LICENSE for complete details.
3
3
  # frozen_string_literal: true
4
4
 
5
+ require 'singleton'
5
6
  require 'new_relic/agent/database/obfuscation_helpers'
6
7
 
7
8
  module NewRelic
@@ -35,17 +35,4 @@ DependencyDetection.defer do
35
35
  end
36
36
  end
37
37
  end
38
-
39
- executes do
40
- next unless Gem::Version.new(ActiveMerchant::VERSION) < Gem::Version.new('1.65.0')
41
-
42
- deprecation_msg = 'The Ruby agent is dropping support for ActiveMerchant versions below 1.65.0 ' \
43
- 'in version 9.0.0. Please upgrade your ActiveMerchant version to continue receiving full support. ' \
44
-
45
- NewRelic::Agent.logger.log_once(
46
- :warn,
47
- :deprecated_active_merchant_version,
48
- deprecation_msg
49
- )
50
- end
51
38
  end
@@ -48,6 +48,12 @@ module NewRelic
48
48
  correlation_id: opts[:correlation_id],
49
49
  exchange_type: type
50
50
  )
51
+ if segment
52
+ segment.add_agent_attribute('server.address', channel&.connection&.hostname)
53
+ segment.add_agent_attribute('server.port', channel&.connection&.port)
54
+ segment.add_agent_attribute('messaging.destination.name', destination) # for produce, this is exchange name
55
+ segment.add_agent_attribute('messaging.rabbitmq.destination.routing_key', opts[:routing_key])
56
+ end
51
57
  rescue => e
52
58
  NewRelic::Agent.logger.error('Error starting message broker segment in Bunny::Exchange#publish', e)
53
59
  yield
@@ -94,6 +100,14 @@ module NewRelic
94
100
  queue_name: name,
95
101
  start_time: t0
96
102
  )
103
+ if segment
104
+ segment.add_agent_attribute('server.address', channel&.connection&.hostname)
105
+ segment.add_agent_attribute('server.port', channel&.connection&.port)
106
+ segment.add_agent_attribute('messaging.destination.name', name) # for consume, this is queue name
107
+ segment.add_agent_attribute('messaging.destination_publish.name', exch_name)
108
+ segment.add_agent_attribute('message.queueName', name)
109
+ segment.add_agent_attribute('messaging.rabbitmq.destination.routing_key', delivery_info&.routing_key)
110
+ end
97
111
  rescue => e
98
112
  NewRelic::Agent.logger.error('Error starting message broker segment in Bunny::Queue#pop', e)
99
113
  else
@@ -93,23 +93,4 @@ DependencyDetection.defer do
93
93
  chain_instrument NewRelic::Agent::Instrumentation::DelayedJob::Chain
94
94
  end
95
95
  end
96
-
97
- executes do
98
- next unless delayed_job_version < Gem::Version.new('4.1.0')
99
-
100
- deprecation_msg = 'Instrumentation for DelayedJob versions below 4.1.0 is deprecated.' \
101
- 'It will stop being monitored in version 9.0.0. ' \
102
- 'Please upgrade your DelayedJob version to continue receiving full support. ' \
103
-
104
- NewRelic::Agent.logger.log_once(
105
- :warn,
106
- :deprecated_delayed_job_version,
107
- deprecation_msg
108
- )
109
- end
110
-
111
- def delayed_job_version
112
- # the following line needs else branch coverage
113
- Gem.loaded_specs['delayed_job'].version if Gem.loaded_specs['delayed_job'] # rubocop:disable Style/SafeNavigation
114
- end
115
96
  end