newrelic_rpm 9.12.0 → 9.13.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (33) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +38 -0
  3. data/README.md +16 -20
  4. data/lib/new_relic/agent/configuration/default_source.rb +30 -2
  5. data/lib/new_relic/agent/configuration/manager.rb +8 -0
  6. data/lib/new_relic/agent/instrumentation/active_merchant.rb +0 -13
  7. data/lib/new_relic/agent/instrumentation/delayed_job_instrumentation.rb +0 -19
  8. data/lib/new_relic/agent/instrumentation/excon.rb +0 -16
  9. data/lib/new_relic/agent/instrumentation/grape.rb +3 -1
  10. data/lib/new_relic/agent/instrumentation/opensearch/chain.rb +21 -0
  11. data/lib/new_relic/agent/instrumentation/opensearch/instrumentation.rb +66 -0
  12. data/lib/new_relic/agent/instrumentation/opensearch/prepend.rb +13 -0
  13. data/lib/new_relic/agent/instrumentation/opensearch.rb +25 -0
  14. data/lib/new_relic/agent/instrumentation/redis.rb +7 -5
  15. data/lib/new_relic/agent/instrumentation/sidekiq.rb +0 -14
  16. data/lib/new_relic/agent/instrumentation/sinatra.rb +0 -13
  17. data/lib/new_relic/agent/serverless_handler.rb +241 -12
  18. data/lib/new_relic/agent/serverless_handler_event_sources.json +155 -0
  19. data/lib/new_relic/agent/serverless_handler_event_sources.rb +49 -0
  20. data/lib/new_relic/agent/system_info.rb +14 -0
  21. data/lib/new_relic/agent/transaction/trace_context.rb +1 -1
  22. data/lib/new_relic/control/frameworks/grape.rb +14 -0
  23. data/lib/new_relic/control/frameworks/padrino.rb +14 -0
  24. data/lib/new_relic/control/frameworks/rails4.rb +4 -2
  25. data/lib/new_relic/environment_report.rb +6 -2
  26. data/lib/new_relic/language_support.rb +7 -1
  27. data/lib/new_relic/local_environment.rb +1 -4
  28. data/lib/new_relic/version.rb +1 -1
  29. data/lib/tasks/helpers/newrelicyml.rb +73 -11
  30. data/lib/tasks/instrumentation_generator/instrumentation.thor +1 -1
  31. data/lib/tasks/instrumentation_generator/templates/dependency_detection.tt +3 -3
  32. data/newrelic.yml +63 -54
  33. metadata +10 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3c551a88ec42cceb53ade85126fe41272598c367b11d70e5167d374556b6fe8d
4
- data.tar.gz: 912ff4f8d33e2ba318b4ec74fa8a3e0680c21fda3521a2382658855219ec81d6
3
+ metadata.gz: 4322e3b796a1a4656be8f68f98c18f79a4f6f86f3dd36ba1186def73a993c6db
4
+ data.tar.gz: e87b88f88a979bc1ff4259643081308670dd860750d12e21cfb6cd45fa3b6004
5
5
  SHA512:
6
- metadata.gz: 61472afe9cf52eea1a86e4394b613666372c6a0086ea1173c28d8341ff417cf980feb6fd7a25f23ec2e78bb02cc4a32efeb5102f1f42175300d0a0f8ba7eea1b
7
- data.tar.gz: e3de1701d6f580a18ceb05c1607d3eada9081012e6bc8edec503b2e945d7128312224c63604dd40debb8554fcc13621a731251f4e349dbcdef909cf09c60c867
6
+ metadata.gz: e53d1172e55be6cf3f66f12f3926361af7485361e1e8c2e097f725241148bbbc5cb59853ce6d255a7c34871f3530424466b621b5cab467383d9e654c0c8108d4
7
+ data.tar.gz: b61902a91a3909760b52797c74f7ef24e5b6f5c282ffd1bfb95451585b052004323fe6c3eb9843e208dcdfdd9382684d8f01a950051e8f7d082269d2ed7134e0
data/CHANGELOG.md CHANGED
@@ -1,5 +1,43 @@
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
+
3
41
  ## v9.12.0
4
42
 
5
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.
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/instrument-lambda-function/instrument-your-own/).
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
 
@@ -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
@@ -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
1156
  * 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), \
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
  },
@@ -1460,6 +1463,15 @@ module NewRelic
1460
1463
  :allowed_from_server => false,
1461
1464
  :description => 'Controls auto-instrumentation of bunny at start-up. May be one of: `auto`, `prepend`, `chain`, `disabled`.'
1462
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
+ },
1463
1475
  :'instrumentation.aws_sqs' => {
1464
1476
  :default => 'auto',
1465
1477
  :public => true,
@@ -1867,6 +1879,21 @@ module NewRelic
1867
1879
  :allowed_from_server => true,
1868
1880
  :description => 'If `true`, the agent obfuscates Mongo queries in transaction traces.'
1869
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
+ },
1870
1897
  # Process host
1871
1898
  :'process_host.display_name' => {
1872
1899
  :default => proc { NewRelic::Agent::Hostname.get },
@@ -2022,9 +2049,10 @@ module NewRelic
2022
2049
  :public => true,
2023
2050
  :type => Integer,
2024
2051
  :allowed_from_server => true,
2052
+ # Keep the extra two-space indent before the second bullet to appease translation tool
2025
2053
  :description => <<~DESC
2026
2054
  * Defines the maximum number of span events reported from a single harvest. Any Integer between `1` and `10000` is valid.'
2027
- * 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`.\
2028
2056
  This ensures the agent captures the maximum amount of distributed traces.
2029
2057
  DESC
2030
2058
  },
@@ -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
@@ -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
@@ -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
@@ -33,22 +33,6 @@ DependencyDetection.defer do
33
33
  end
34
34
  end
35
35
 
36
- executes do
37
- next unless Gem::Version.new(Excon::VERSION) < Gem::Version.new('0.56.0')
38
-
39
- deprecation_msg = 'Instrumentation for Excon versions below 0.56.0 is deprecated.' \
40
- 'They will stop being monitored in version 9.0.0. ' \
41
- 'Please upgrade your Excon version to continue receiving full support. '
42
-
43
- NewRelic::Agent.logger.log_once(
44
- :warn,
45
- :deprecated_excon_version,
46
- deprecation_msg
47
- )
48
-
49
- NewRelic::Agent.record_metric('Supportability/Deprecated/Excon', 1)
50
- end
51
-
52
36
  def install_excon_instrumentation(excon_version)
53
37
  require 'new_relic/agent/distributed_tracing/cross_app_tracing'
54
38
  require 'new_relic/agent/http_clients/excon_wrappers'
@@ -19,7 +19,9 @@ DependencyDetection.defer do
19
19
 
20
20
  depends_on do
21
21
  begin
22
- if defined?(Bundler) && Bundler.rubygems.all_specs.map(&:name).include?('newrelic-grape')
22
+ if defined?(Bundler) &&
23
+ ((Gem::Version.new(Bundler::VERSION) >= Gem::Version.new('2.0.0') && Bundler.rubygems.installed_specs.map(&:name).include?('newrelic-grape')) ||
24
+ Bundler.rubygems.all_specs.map(&:name).include?('newrelic-grape'))
23
25
  NewRelic::Agent.logger.info('Not installing New Relic supported Grape instrumentation because the third party newrelic-grape gem is present')
24
26
  false
25
27
  else
@@ -0,0 +1,21 @@
1
+ # This file is distributed under New Relic's license terms.
2
+ # See https://github.com/newrelic/newrelic-ruby-agent/blob/main/LICENSE for complete details.
3
+ # frozen_string_literal: true
4
+
5
+ module NewRelic::Agent::Instrumentation
6
+ module OpenSearch::Chain
7
+ def self.instrument!
8
+ ::OpenSearch::Transport::Client.class_eval do
9
+ include NewRelic::Agent::Instrumentation::OpenSearch
10
+
11
+ alias_method(:perform_request_without_tracing, :perform_request)
12
+
13
+ def perform_request(*args)
14
+ perform_request_with_tracing(*args) do
15
+ perform_request_without_tracing(*args)
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,66 @@
1
+ # This file is distributed under New Relic's license terms.
2
+ # See https://github.com/newrelic/newrelic-ruby-agent/blob/main/LICENSE for complete details.
3
+ # frozen_string_literal: true
4
+
5
+ module NewRelic::Agent::Instrumentation
6
+ module OpenSearch
7
+ PRODUCT_NAME = 'OpenSearch'
8
+ OPERATION = 'perform_request'
9
+ OPERATION_PATTERN = %r{/lib/opensearch/api/(?!.+#{OPERATION})}
10
+ INSTANCE_METHOD_PATTERN = /:in (?:`|')(?:.+#)?([^']+)'\z/
11
+ INSTRUMENTATION_NAME = NewRelic::Agent.base_name(name)
12
+
13
+ def perform_request_with_tracing(_method, _path, params = NewRelic::EMPTY_HASH, body = nil, _headers = nil, _opts = nil, &_block)
14
+ return yield unless NewRelic::Agent::Tracer.tracing_enabled?
15
+
16
+ segment = NewRelic::Agent::Tracer.start_datastore_segment(
17
+ product: PRODUCT_NAME,
18
+ operation: nr_operation || OPERATION,
19
+ host: nr_hosts[:host],
20
+ port_path_or_id: nr_hosts[:port],
21
+ database_name: nr_cluster_name
22
+ )
23
+ begin
24
+ NewRelic::Agent::Tracer.capture_segment_error(segment) { yield }
25
+ ensure
26
+ if segment
27
+ segment.notice_nosql_statement(nr_reported_query(body || params))
28
+ segment.finish
29
+ end
30
+ end
31
+ end
32
+
33
+ private
34
+
35
+ # See Elasticsearch instrumentation for explanation on Ruby 3.4 changes to match instance method
36
+ def nr_operation
37
+ location = caller_locations.detect { |loc| loc.to_s.match?(OPERATION_PATTERN) }
38
+ return unless location && location.to_s =~ INSTANCE_METHOD_PATTERN
39
+
40
+ Regexp.last_match(1)
41
+ end
42
+
43
+ def nr_reported_query(query)
44
+ return unless NewRelic::Agent.config[:'opensearch.capture_queries']
45
+ return query unless NewRelic::Agent.config[:'opensearch.obfuscate_queries']
46
+
47
+ NewRelic::Agent::Datastores::NosqlObfuscator.obfuscate_statement(query)
48
+ end
49
+
50
+ def nr_cluster_name
51
+ return @nr_cluster_name if defined?(@nr_cluster_name)
52
+ return if nr_hosts.empty?
53
+
54
+ NewRelic::Agent.disable_all_tracing do
55
+ @nr_cluster_name ||= perform_request('GET', '/').body['cluster_name']
56
+ end
57
+ rescue StandardError => e
58
+ NewRelic::Agent.logger.error('Failed to get cluster name for OpenSearch', e)
59
+ nil
60
+ end
61
+
62
+ def nr_hosts
63
+ @nr_hosts ||= (transport.hosts.first || NewRelic::EMPTY_HASH)
64
+ end
65
+ end
66
+ end
@@ -0,0 +1,13 @@
1
+ # This file is distributed under New Relic's license terms.
2
+ # See https://github.com/newrelic/newrelic-ruby-agent/blob/main/LICENSE for complete details.
3
+ # frozen_string_literal: true
4
+
5
+ module NewRelic::Agent::Instrumentation
6
+ module OpenSearch::Prepend
7
+ include NewRelic::Agent::Instrumentation::OpenSearch
8
+
9
+ def perform_request(*args)
10
+ perform_request_with_tracing(*args) { super }
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,25 @@
1
+ # This file is distributed under New Relic's license terms.
2
+ # See https://github.com/newrelic/newrelic-ruby-agent/blob/main/LICENSE for complete details.
3
+ # frozen_string_literal: true
4
+
5
+ require_relative 'opensearch/instrumentation'
6
+ require_relative 'opensearch/chain'
7
+ require_relative 'opensearch/prepend'
8
+
9
+ DependencyDetection.defer do
10
+ named :opensearch
11
+
12
+ depends_on do
13
+ defined?(OpenSearch)
14
+ end
15
+
16
+ executes do
17
+ NewRelic::Agent.logger.info('Installing opensearch-ruby instrumentation')
18
+
19
+ if use_prepend?
20
+ prepend_instrument OpenSearch::Transport::Client, NewRelic::Agent::Instrumentation::OpenSearch::Prepend
21
+ else
22
+ chain_instrument NewRelic::Agent::Instrumentation::OpenSearch::Chain
23
+ end
24
+ end
25
+ end
@@ -36,14 +36,16 @@ DependencyDetection.defer do
36
36
  RedisClient.register(NewRelic::Agent::Instrumentation::RedisClient::Middleware)
37
37
 
38
38
  if defined?(Redis::Cluster::Client)
39
- return RedisClient.register(NewRelic::Agent::Instrumentation::RedisClient::ClusterMiddleware)
39
+ RedisClient.register(NewRelic::Agent::Instrumentation::RedisClient::ClusterMiddleware)
40
40
  end
41
41
  end
42
42
 
43
- if use_prepend?
44
- prepend_instrument Redis::Client, NewRelic::Agent::Instrumentation::Redis::Prepend
45
- else
46
- chain_instrument NewRelic::Agent::Instrumentation::Redis::Chain
43
+ unless defined?(Redis::Cluster::Client)
44
+ if use_prepend?
45
+ prepend_instrument Redis::Client, NewRelic::Agent::Instrumentation::Redis::Prepend
46
+ else
47
+ chain_instrument NewRelic::Agent::Instrumentation::Redis::Chain
48
+ end
47
49
  end
48
50
  end
49
51
  end
@@ -41,18 +41,4 @@ DependencyDetection.defer do
41
41
  end
42
42
  end
43
43
  end
44
-
45
- executes do
46
- next unless Gem::Version.new(Sidekiq::VERSION) < Gem::Version.new('5.0.0')
47
-
48
- deprecation_msg = 'Instrumentation for Sidekiq versions below 5.0.0 is deprecated ' \
49
- 'and will be dropped entirely in a future major New Relic Ruby agent release.' \
50
- 'Please upgrade your Sidekiq version to continue receiving full support. '
51
-
52
- NewRelic::Agent.logger.log_once(
53
- :warn,
54
- :deprecated_sidekiq_version,
55
- deprecation_msg
56
- )
57
- end
58
44
  end
@@ -42,17 +42,4 @@ DependencyDetection.defer do
42
42
  chain_instrument NewRelic::Agent::Instrumentation::Sinatra::Build::Chain
43
43
  end
44
44
  end
45
-
46
- executes do
47
- next unless Gem::Version.new(Sinatra::VERSION) < Gem::Version.new('2.0.0')
48
-
49
- deprecation_msg = 'The Ruby agent is dropping support for Sinatra versions below 2.0.0 ' \
50
- 'in version 9.0.0. Please upgrade your Sinatra version to continue receiving full compatibility. ' \
51
-
52
- NewRelic::Agent.logger.log_once(
53
- :warn,
54
- :deprecated_sinatra_version,
55
- deprecation_msg
56
- )
57
- end
58
45
  end