newrelic_rpm 8.16.0 → 9.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (62) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +0 -28
  3. data/.rubocop_todo.yml +41 -3
  4. data/CHANGELOG.md +126 -0
  5. data/CONTRIBUTING.md +1 -1
  6. data/README.md +3 -1
  7. data/bin/nrdebug +16 -16
  8. data/lib/new_relic/agent/agent_helpers/connect.rb +1 -1
  9. data/lib/new_relic/agent/agent_helpers/special_startup.rb +1 -2
  10. data/lib/new_relic/agent/attribute_filter.rb +0 -2
  11. data/lib/new_relic/agent/commands/thread_profiler_session.rb +3 -3
  12. data/lib/new_relic/agent/configuration/default_source.rb +98 -474
  13. data/lib/new_relic/agent/configuration/high_security_source.rb +0 -2
  14. data/lib/new_relic/agent/configuration/security_policy_source.rb +0 -16
  15. data/lib/new_relic/agent/database.rb +0 -14
  16. data/lib/new_relic/agent/distributed_tracing/cross_app_tracing.rb +1 -2
  17. data/lib/new_relic/agent/error_collector.rb +1 -1
  18. data/lib/new_relic/agent/error_filter.rb +3 -3
  19. data/lib/new_relic/agent/instrumentation/active_job.rb +1 -1
  20. data/lib/new_relic/agent/instrumentation/controller_instrumentation.rb +1 -1
  21. data/lib/new_relic/agent/instrumentation/fiber/chain.rb +20 -0
  22. data/lib/new_relic/agent/instrumentation/fiber/instrumentation.rb +24 -0
  23. data/lib/new_relic/agent/instrumentation/fiber/prepend.rb +18 -0
  24. data/lib/new_relic/agent/instrumentation/fiber.rb +25 -0
  25. data/lib/new_relic/agent/instrumentation/grape.rb +1 -1
  26. data/lib/new_relic/agent/instrumentation/memcache.rb +2 -2
  27. data/lib/new_relic/agent/instrumentation/net_http.rb +1 -1
  28. data/lib/new_relic/agent/instrumentation/rake/instrumentation.rb +1 -8
  29. data/lib/new_relic/agent/instrumentation/rake.rb +1 -1
  30. data/lib/new_relic/agent/instrumentation/redis.rb +1 -1
  31. data/lib/new_relic/agent/instrumentation/resque.rb +1 -1
  32. data/lib/new_relic/agent/instrumentation/sequel.rb +4 -5
  33. data/lib/new_relic/agent/instrumentation/thread/instrumentation.rb +3 -7
  34. data/lib/new_relic/agent/monitors/cross_app_monitor.rb +0 -1
  35. data/lib/new_relic/agent/new_relic_service/security_policy_settings.rb +0 -1
  36. data/lib/new_relic/agent/new_relic_service.rb +1 -1
  37. data/lib/new_relic/agent/rules_engine/segment_terms_rule.rb +0 -1
  38. data/lib/new_relic/agent/samplers/delayed_job_sampler.rb +1 -1
  39. data/lib/new_relic/agent/tracer.rb +10 -1
  40. data/lib/new_relic/agent/transaction/abstract_segment.rb +2 -2
  41. data/lib/new_relic/agent/transaction/tracing.rb +2 -2
  42. data/lib/new_relic/agent/transaction.rb +17 -16
  43. data/lib/new_relic/agent.rb +1 -19
  44. data/lib/new_relic/cli/commands/install.rb +9 -9
  45. data/lib/new_relic/control/instance_methods.rb +1 -1
  46. data/lib/new_relic/local_environment.rb +0 -10
  47. data/lib/new_relic/supportability_helper.rb +0 -1
  48. data/lib/new_relic/version.rb +2 -2
  49. data/lib/newrelic_rpm.rb +1 -1
  50. data/lib/sequel/extensions/{newrelic_instrumentation.rb → new_relic_instrumentation.rb} +3 -3
  51. data/lib/sequel/plugins/{newrelic_instrumentation.rb → new_relic_instrumentation.rb} +3 -3
  52. data/lib/tasks/helpers/format.rb +1 -1
  53. data/lib/tasks/instrumentation_generator/instrumentation.thor +7 -10
  54. data/lib/tasks/instrumentation_generator/templates/Envfile.tt +1 -1
  55. data/newrelic.yml +5 -8
  56. data/newrelic_rpm.gemspec +16 -13
  57. metadata +13 -14
  58. data/lib/new_relic/agent/instrumentation/acts_as_solr.rb +0 -83
  59. data/lib/new_relic/agent/instrumentation/authlogic.rb +0 -33
  60. data/lib/new_relic/agent/instrumentation/data_mapper.rb +0 -215
  61. data/lib/new_relic/agent/instrumentation/rainbows_instrumentation.rb +0 -36
  62. data/lib/new_relic/agent/instrumentation/sunspot.rb +0 -41
@@ -21,7 +21,6 @@ module NewRelic
21
21
  :browser_timing_header,
22
22
  :disable_all_tracing,
23
23
  :disable_sql_recording,
24
- :disable_transaction_tracing,
25
24
  :drop_buffered_data,
26
25
  :get_request_metadata,
27
26
  :get_response_metadata,
@@ -5,8 +5,8 @@
5
5
 
6
6
  module NewRelic
7
7
  module VERSION # :nodoc:
8
- MAJOR = 8
9
- MINOR = 16
8
+ MAJOR = 9
9
+ MINOR = 0
10
10
  TINY = 0
11
11
 
12
12
  STRING = "#{MAJOR}.#{MINOR}.#{TINY}"
data/lib/newrelic_rpm.rb CHANGED
@@ -20,7 +20,7 @@ require 'new_relic/control'
20
20
  if defined?(Rails::VERSION)
21
21
  module NewRelic
22
22
  class Railtie < Rails::Railtie
23
- if NewRelic::Agent.config[:defer_rails_initialization]
23
+ if ENV['NEW_RELIC_DEFER_RAILS_INITIALIZATION']
24
24
  initializer "newrelic_rpm.include_method_tracers", before: :load_config_initializers do |app|
25
25
  Module.send(:include, NewRelic::Agent::MethodTracer::ClassMethods)
26
26
  Module.send(:include, NewRelic::Agent::MethodTracer)
@@ -17,7 +17,7 @@ module Sequel
17
17
  # instrumentation is loaded:
18
18
  #
19
19
  # db = Sequel.connect( ... )
20
- # db.extension :newrelic_instrumentation
20
+ # db.extension :new_relic_instrumentation
21
21
  #
22
22
  # Versions 3.47.0 and later use `Database.extension` to automatically
23
23
  # install the extension for new connections.
@@ -93,6 +93,6 @@ module Sequel
93
93
  end
94
94
  end # module NewRelicInstrumentation
95
95
 
96
- NewRelic::Agent.logger.debug("Registering the :newrelic_instrumentation extension.")
97
- Database.register_extension(:newrelic_instrumentation, NewRelicInstrumentation)
96
+ NewRelic::Agent.logger.debug("Registering the :new_relic_instrumentation extension.")
97
+ Database.register_extension(:new_relic_instrumentation, NewRelicInstrumentation)
98
98
  end # module Sequel
@@ -11,7 +11,7 @@ require 'new_relic/agent/datastores/metric_helper'
11
11
  module Sequel
12
12
  module Plugins
13
13
  # Sequel::Model instrumentation for the New Relic agent.
14
- module NewrelicInstrumentation
14
+ module NewRelicInstrumentation
15
15
  # Meta-programming for creating method tracers for the Sequel::Model plugin.
16
16
  module MethodWrapping
17
17
  # Install a method named +method_name+ that will trace execution
@@ -38,7 +38,7 @@ module Sequel
38
38
 
39
39
  # Methods to be added to Sequel::Model instances.
40
40
  module InstanceMethods
41
- extend Sequel::Plugins::NewrelicInstrumentation::MethodWrapping
41
+ extend Sequel::Plugins::NewRelicInstrumentation::MethodWrapping
42
42
 
43
43
  wrap_sequel_method :delete
44
44
  wrap_sequel_method :destroy
@@ -52,7 +52,7 @@ module Sequel
52
52
 
53
53
  # Methods to be added to Sequel::Model classes.
54
54
  module ClassMethods
55
- extend Sequel::Plugins::NewrelicInstrumentation::MethodWrapping
55
+ extend Sequel::Plugins::NewRelicInstrumentation::MethodWrapping
56
56
 
57
57
  wrap_sequel_method :[], "get"
58
58
  wrap_sequel_method :all
@@ -43,7 +43,7 @@ module Format
43
43
  def flatten_config_hash(config_hash)
44
44
  sections = []
45
45
  config = [GENERAL, 'transaction_tracer', 'error_collector',
46
- 'browser_monitoring', 'analytics_events', 'transaction_events',
46
+ 'browser_monitoring', 'transaction_events',
47
47
  'application_logging']
48
48
 
49
49
  config.each { |config| sections << pluck(config, config_hash) }
@@ -14,7 +14,7 @@ class Instrumentation < Thor
14
14
  NEWRELIC_YML_LOCATION = 'newrelic.yml'
15
15
 
16
16
  desc('scaffold NAME', 'Scaffold the required files for adding new instrumentation')
17
- long_desc <<-LONGDESC
17
+ long_desc <<~LONGDESC
18
18
  `instrumentation scaffold` requires one parameter by default: the name of the
19
19
  library or class you are instrumenting. This task generates the basic
20
20
  file structure needed to add new instrumentation to the Ruby agent.
@@ -96,7 +96,7 @@ class Instrumentation < Thor
96
96
  end
97
97
 
98
98
  def config_block(name)
99
- <<-CONFIG
99
+ <<~CONFIG
100
100
  :'instrumentation.#{name.downcase}' => {
101
101
  :default => 'auto',
102
102
  :public => true,
@@ -108,16 +108,13 @@ class Instrumentation < Thor
108
108
  CONFIG
109
109
  end
110
110
 
111
- # TODO: OLD RUBIES - RUBY_VERSION 2.2
112
- # When we only support 2.3+ this can be changed to a sqiggle heredoc (<<~)
113
- # and use standard indentation
114
111
  def yaml_block(name)
115
- <<HEREDOC # rubocop:disable Layout/IndentationWidth
112
+ <<~HEREDOC
116
113
 
117
- # Controls auto-instrumentation of #{name} at start up.
118
- # May be one of [auto|prepend|chain|disabled]
119
- # instrumentation.#{name.downcase}: auto
120
- HEREDOC
114
+ # Controls auto-instrumentation of #{name} at start up.
115
+ # May be one of [auto|prepend|chain|disabled]
116
+ # instrumentation.#{name.downcase}: auto
117
+ HEREDOC
121
118
  end
122
119
  end
123
120
 
@@ -4,6 +4,6 @@
4
4
 
5
5
  instrumentation_methods :chain, :prepend
6
6
 
7
- gemfile <<-RB
7
+ gemfile <<~RB
8
8
  gem '<%= @name.downcase %>'
9
9
  RB
data/newrelic.yml CHANGED
@@ -162,10 +162,6 @@ common: &default_settings
162
162
  # or port_path_or_id parameters to transaction or slow SQL traces.
163
163
  # datastore_tracer.instance_reporting.enabled: true
164
164
 
165
- # If true, when the agent is in an application using Ruby on Rails, it will start after
166
- # config/initializers have run.
167
- # defer_rails_initialization: false
168
-
169
165
  # If true, disables Action Cable instrumentation.
170
166
  # disable_action_cable_instrumentation: false
171
167
 
@@ -196,9 +192,6 @@ common: &default_settings
196
192
  # If true, disables ActiveSupport custom events instrumentation.
197
193
  # disable_custom_events_instrumentation: false
198
194
 
199
- # If true, disables DataMapper instrumentation.
200
- # disable_data_mapper: false
201
-
202
195
  # If true, the agent won't measure the depth of Delayed Job queues.
203
196
  # disable_delayed_job_sampler: false
204
197
 
@@ -337,6 +330,10 @@ common: &default_settings
337
330
  # May be one of [auto|prepend|chain|disabled].
338
331
  # instrumentation.bunny: auto
339
332
 
333
+ # Controls auto-instrumentation of Fiber at start up.
334
+ # May be one of [auto|prepend|chain|disabled]
335
+ # instrumentation.fiber: auto
336
+
340
337
  # Controls auto-instrumentation of concurrent_ruby at start up.
341
338
  # May be one of [auto|prepend|chain|disabled]
342
339
  # instrumentation.concurrent_ruby: auto
@@ -444,7 +441,7 @@ common: &default_settings
444
441
  # instrumentation.thread: auto
445
442
 
446
443
  # Controls auto-instrumentation of the Thread class at start up to automatically add tracing to all Threads created in the application.
447
- # instrumentation.thread.tracing: false
444
+ # instrumentation.thread.tracing: true
448
445
 
449
446
  # Controls auto-instrumentation of gRPC clients at start up.
450
447
  # May be one of [auto|prepend|chain|disabled].
data/newrelic_rpm.gemspec CHANGED
@@ -8,17 +8,17 @@ require 'new_relic/latest_changes'
8
8
  Gem::Specification.new do |s|
9
9
  s.name = "newrelic_rpm"
10
10
  s.version = NewRelic::VERSION::STRING
11
- s.required_ruby_version = '>= 2.2.0'
11
+ s.required_ruby_version = '>= 2.4.0'
12
12
  s.required_rubygems_version = Gem::Requirement.new("> 1.3.1") if s.respond_to?(:required_rubygems_version=)
13
13
  s.authors = ["Tanna McClure", "Kayla Reopelle", "James Bunch", "Hannah Ramadan"]
14
14
  s.licenses = ['Apache-2.0']
15
- s.description = <<-EOS
16
- New Relic is a performance management system, developed by New Relic,
17
- Inc (http://www.newrelic.com). New Relic provides you with deep
18
- information about the performance of your web application as it runs
19
- in production. The New Relic Ruby agent is dual-purposed as a either a
20
- Gem or plugin, hosted on
21
- https://github.com/newrelic/newrelic-ruby-agent/
15
+ s.description = <<~EOS
16
+ New Relic is a performance management system, developed by New Relic,
17
+ Inc (http://www.newrelic.com). New Relic provides you with deep
18
+ information about the performance of your web application as it runs
19
+ in production. The New Relic Ruby agent is dual-purposed as a either a
20
+ Gem or plugin, hosted on
21
+ https://github.com/newrelic/newrelic-ruby-agent/
22
22
  EOS
23
23
  s.email = "support@newrelic.com"
24
24
  s.executables = %w[newrelic_cmd newrelic nrdebug]
@@ -54,12 +54,15 @@ https://github.com/newrelic/newrelic-ruby-agent/
54
54
  s.add_development_dependency 'mocha', '~> 1.16'
55
55
  s.add_development_dependency 'pry' unless ENV['CI']
56
56
  s.add_development_dependency 'rake', '12.3.3'
57
- s.add_development_dependency 'rubocop' unless ENV['CI'] && RUBY_VERSION < '3.0.0'
58
- s.add_development_dependency 'rubocop-minitest' unless ENV['CI'] && RUBY_VERSION < '3.0.0'
59
- s.add_development_dependency 'rubocop-performance' unless ENV['CI'] && RUBY_VERSION < '3.0.0'
60
- s.add_development_dependency 'rubocop-rake' unless ENV['CI'] && RUBY_VERSION < '3.0.0'
57
+
58
+ s.add_development_dependency 'rubocop', '1.44.1' unless ENV['CI'] && RUBY_VERSION < '3.0.0'
59
+ s.add_development_dependency 'rubocop-ast', '1.24.1' unless ENV['CI'] && RUBY_VERSION < '3.0.0'
60
+ s.add_development_dependency 'rubocop-minitest', '0.27.0' unless ENV['CI'] && RUBY_VERSION < '3.0.0'
61
+ s.add_development_dependency 'rubocop-performance', '1.16.0' unless ENV['CI'] && RUBY_VERSION < '3.0.0'
62
+ s.add_development_dependency 'rubocop-rake', '0.6.0' unless ENV['CI'] && RUBY_VERSION < '3.0.0'
63
+
61
64
  s.add_development_dependency 'simplecov' if RUBY_VERSION >= '2.7.0'
62
65
  s.add_development_dependency 'thor' unless ENV['CI']
63
66
  s.add_development_dependency 'warning' if RUBY_VERSION >= '2.4.0'
64
- s.add_development_dependency 'yard', "#{RUBY_VERSION < '2.3.0' ? '0.9.26' : '> 0.9.26'}"
67
+ s.add_development_dependency 'yard'
65
68
  end
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: 8.16.0
4
+ version: 9.0.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: 2023-02-06 00:00:00.000000000 Z
14
+ date: 2023-02-21 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: bundler
@@ -115,16 +115,16 @@ dependencies:
115
115
  name: yard
116
116
  requirement: !ruby/object:Gem::Requirement
117
117
  requirements:
118
- - - ">"
118
+ - - ">="
119
119
  - !ruby/object:Gem::Version
120
- version: 0.9.26
120
+ version: '0'
121
121
  type: :development
122
122
  prerelease: false
123
123
  version_requirements: !ruby/object:Gem::Requirement
124
124
  requirements:
125
- - - ">"
125
+ - - ">="
126
126
  - !ruby/object:Gem::Version
127
- version: 0.9.26
127
+ version: '0'
128
128
  description: |
129
129
  New Relic is a performance management system, developed by New Relic,
130
130
  Inc (http://www.newrelic.com). New Relic provides you with deep
@@ -280,8 +280,6 @@ files:
280
280
  - lib/new_relic/agent/instrumentation/active_support_logger/instrumentation.rb
281
281
  - lib/new_relic/agent/instrumentation/active_support_logger/prepend.rb
282
282
  - lib/new_relic/agent/instrumentation/active_support_subscriber.rb
283
- - lib/new_relic/agent/instrumentation/acts_as_solr.rb
284
- - lib/new_relic/agent/instrumentation/authlogic.rb
285
283
  - lib/new_relic/agent/instrumentation/bunny.rb
286
284
  - lib/new_relic/agent/instrumentation/bunny/chain.rb
287
285
  - lib/new_relic/agent/instrumentation/bunny/instrumentation.rb
@@ -297,7 +295,6 @@ files:
297
295
  - lib/new_relic/agent/instrumentation/curb/prepend.rb
298
296
  - lib/new_relic/agent/instrumentation/custom_events.rb
299
297
  - lib/new_relic/agent/instrumentation/custom_events_subscriber.rb
300
- - lib/new_relic/agent/instrumentation/data_mapper.rb
301
298
  - lib/new_relic/agent/instrumentation/delayed_job/chain.rb
302
299
  - lib/new_relic/agent/instrumentation/delayed_job/instrumentation.rb
303
300
  - lib/new_relic/agent/instrumentation/delayed_job/prepend.rb
@@ -308,6 +305,10 @@ files:
308
305
  - lib/new_relic/agent/instrumentation/elasticsearch/prepend.rb
309
306
  - lib/new_relic/agent/instrumentation/excon.rb
310
307
  - lib/new_relic/agent/instrumentation/excon/middleware.rb
308
+ - lib/new_relic/agent/instrumentation/fiber.rb
309
+ - lib/new_relic/agent/instrumentation/fiber/chain.rb
310
+ - lib/new_relic/agent/instrumentation/fiber/instrumentation.rb
311
+ - lib/new_relic/agent/instrumentation/fiber/prepend.rb
311
312
  - lib/new_relic/agent/instrumentation/grape.rb
312
313
  - lib/new_relic/agent/instrumentation/grape/chain.rb
313
314
  - lib/new_relic/agent/instrumentation/grape/instrumentation.rb
@@ -368,7 +369,6 @@ files:
368
369
  - lib/new_relic/agent/instrumentation/rails_notifications/action_controller.rb
369
370
  - lib/new_relic/agent/instrumentation/rails_notifications/action_view.rb
370
371
  - lib/new_relic/agent/instrumentation/rails_notifications/custom_events.rb
371
- - lib/new_relic/agent/instrumentation/rainbows_instrumentation.rb
372
372
  - lib/new_relic/agent/instrumentation/rake.rb
373
373
  - lib/new_relic/agent/instrumentation/rake/chain.rb
374
374
  - lib/new_relic/agent/instrumentation/rake/instrumentation.rb
@@ -396,7 +396,6 @@ files:
396
396
  - lib/new_relic/agent/instrumentation/sinatra/instrumentation.rb
397
397
  - lib/new_relic/agent/instrumentation/sinatra/prepend.rb
398
398
  - lib/new_relic/agent/instrumentation/sinatra/transaction_namer.rb
399
- - lib/new_relic/agent/instrumentation/sunspot.rb
400
399
  - lib/new_relic/agent/instrumentation/thread.rb
401
400
  - lib/new_relic/agent/instrumentation/thread/chain.rb
402
401
  - lib/new_relic/agent/instrumentation/thread/instrumentation.rb
@@ -544,8 +543,8 @@ files:
544
543
  - lib/new_relic/traced_thread.rb
545
544
  - lib/new_relic/version.rb
546
545
  - lib/newrelic_rpm.rb
547
- - lib/sequel/extensions/newrelic_instrumentation.rb
548
- - lib/sequel/plugins/newrelic_instrumentation.rb
546
+ - lib/sequel/extensions/new_relic_instrumentation.rb
547
+ - lib/sequel/plugins/new_relic_instrumentation.rb
549
548
  - lib/tasks/all.rb
550
549
  - lib/tasks/config.rake
551
550
  - lib/tasks/coverage_report.rake
@@ -594,7 +593,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
594
593
  requirements:
595
594
  - - ">="
596
595
  - !ruby/object:Gem::Version
597
- version: 2.2.0
596
+ version: 2.4.0
598
597
  required_rubygems_version: !ruby/object:Gem::Requirement
599
598
  requirements:
600
599
  - - ">"
@@ -1,83 +0,0 @@
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 'new_relic/agent/database'
6
-
7
- module NewRelic
8
- module Instrumentation
9
- module ActsAsSolrInstrumentation
10
- module ParserMethodsInstrumentation
11
- def parse_query_with_newrelic(*args)
12
- self.class.trace_execution_scoped(["SolrClient/ActsAsSolr/query"]) do
13
- begin
14
- parse_query_without_newrelic(*args)
15
- ensure
16
- return unless txn = ::NewRelic::Agent::Tracer.current_transaction
17
-
18
- txn.current_segment.params[:statement] = ::NewRelic::Agent::Database.truncate_query(args.first.inspect) rescue nil
19
- end
20
- end
21
- end
22
- end
23
- end
24
- end
25
- end
26
-
27
- DependencyDetection.defer do
28
- @name = :acts_as_solr
29
-
30
- depends_on do
31
- defined?(ActsAsSolr)
32
- end
33
-
34
- depends_on do
35
- defined?(ActsAsSolr::ParserMethods)
36
- end
37
-
38
- depends_on do
39
- defined?(ActsAsSolr::ClassMethods)
40
- end
41
-
42
- depends_on do
43
- defined?(ActsAsSolr::CommonMethods)
44
- end
45
-
46
- executes do
47
- NewRelic::Agent.logger.info('Installing ActsAsSolr instrumentation')
48
- deprecation_msg = 'The instrumentation for ActsAsSolr is deprecated. ' \
49
- 'It will be removed in version 9.0.0.' \
50
-
51
- NewRelic::Agent.logger.log_once(
52
- :warn,
53
- :deprecated_acts_as_solr,
54
- deprecation_msg
55
- )
56
- end
57
-
58
- executes do
59
- ActsAsSolr::ParserMethods.module_eval do
60
- include NewRelic::Instrumentation::ActsAsSolrInstrumentation::ParserMethodsInstrumentation
61
- alias :parse_query_without_newrelic :parse_query
62
- alias :parse_query :parse_query_with_newrelic
63
- end
64
- end
65
-
66
- executes do
67
- ActsAsSolr::ClassMethods.module_eval do
68
- %w[find_by_solr find_id_by_solr multi_solr_search count_by_solr].each do |method|
69
- add_method_tracer method, 'SolrClient/ActsAsSolr/query'
70
- end
71
- add_method_tracer :rebuild_solr_index, 'SolrClient/ActsAsSolr/index'
72
- end
73
- end
74
-
75
- executes do
76
- ActsAsSolr::CommonMethods.module_eval do
77
- add_method_tracer :solr_add, 'SolrClient/ActsAsSolr/add'
78
- add_method_tracer :solr_delete, 'SolrClient/ActsAsSolr/delete'
79
- add_method_tracer :solr_commit, 'SolrClient/ActsAsSolr/commit'
80
- add_method_tracer :solr_optimize, 'SolrClient/ActsAsSolr/optimize'
81
- end
82
- end
83
- end
@@ -1,33 +0,0 @@
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
- DependencyDetection.defer do
6
- @name = :authlogic
7
-
8
- depends_on do
9
- defined?(Authlogic) &&
10
- defined?(Authlogic::Session) &&
11
- defined?(Authlogic::Session::Base)
12
- end
13
-
14
- executes do
15
- NewRelic::Agent.logger.info('Installing Authlogic instrumentation')
16
- deprecation_msg = 'The instrumentation for Authlogic is deprecated. ' \
17
- 'It will be removed in version 9.0.0.' \
18
-
19
- NewRelic::Agent.logger.log_once(
20
- :warn,
21
- :deprecated_authlogic,
22
- deprecation_msg
23
- )
24
- end
25
-
26
- executes do
27
- Authlogic::Session::Base.class_eval do
28
- class << self
29
- add_method_tracer :find, 'Custom/Authlogic/find'
30
- end
31
- end
32
- end
33
- end
@@ -1,215 +0,0 @@
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
- DependencyDetection.defer do
6
- named :data_mapper
7
-
8
- depends_on do
9
- defined?(DataMapper) &&
10
- defined?(DataMapper::Model) &&
11
- defined?(DataMapper::Resource) &&
12
- defined?(DataMapper::Collection)
13
- end
14
-
15
- executes do
16
- NewRelic::Agent.logger.info('Installing DataMapper instrumentation')
17
- require 'new_relic/agent/datastores/metric_helper'
18
-
19
- deprecation_msg = 'The instrumentation for DataMapper is deprecated. ' \
20
- 'It will be removed in version 9.0.0.' \
21
- 'Visit https://docs.newrelic.com/docs/apm/agents/ruby-agent/getting-started/ruby-agent-requirements-supported-frameworks ' \
22
- 'to learn about supported gems.'
23
-
24
- NewRelic::Agent.logger.log_once(
25
- :warn,
26
- :deprecated_datamapper,
27
- deprecation_msg
28
- )
29
- end
30
-
31
- executes do
32
- NewRelic::Agent::DataMapperTracing.add_tracer(DataMapper::Model, :get)
33
- NewRelic::Agent::DataMapperTracing.add_tracer(DataMapper::Model, :first)
34
- NewRelic::Agent::DataMapperTracing.add_tracer(DataMapper::Model, :last)
35
- NewRelic::Agent::DataMapperTracing.add_tracer(DataMapper::Model, :all)
36
-
37
- NewRelic::Agent::DataMapperTracing.add_tracer(DataMapper::Model, :create)
38
- NewRelic::Agent::DataMapperTracing.add_tracer(DataMapper::Model, :create!)
39
- NewRelic::Agent::DataMapperTracing.add_tracer(DataMapper::Model, :update)
40
- NewRelic::Agent::DataMapperTracing.add_tracer(DataMapper::Model, :update!)
41
- NewRelic::Agent::DataMapperTracing.add_tracer(DataMapper::Model, :destroy)
42
- NewRelic::Agent::DataMapperTracing.add_tracer(DataMapper::Model, :destroy!)
43
-
44
- NewRelic::Agent::DataMapperTracing.add_tracer(DataMapper::Model, :aggregate)
45
- NewRelic::Agent::DataMapperTracing.add_tracer(DataMapper::Model, :find)
46
- NewRelic::Agent::DataMapperTracing.add_tracer(DataMapper::Model, :find_by_sql)
47
- end
48
-
49
- executes do
50
- NewRelic::Agent::DataMapperTracing.add_tracer(DataMapper::Resource, :update)
51
- NewRelic::Agent::DataMapperTracing.add_tracer(DataMapper::Resource, :update!)
52
- NewRelic::Agent::DataMapperTracing.add_tracer(DataMapper::Resource, :save)
53
- NewRelic::Agent::DataMapperTracing.add_tracer(DataMapper::Resource, :save!)
54
- NewRelic::Agent::DataMapperTracing.add_tracer(DataMapper::Resource, :destroy)
55
- NewRelic::Agent::DataMapperTracing.add_tracer(DataMapper::Resource, :destroy!)
56
- end
57
-
58
- executes do
59
- NewRelic::Agent::DataMapperTracing.add_tracer(DataMapper::Collection, :get)
60
- NewRelic::Agent::DataMapperTracing.add_tracer(DataMapper::Collection, :first)
61
- NewRelic::Agent::DataMapperTracing.add_tracer(DataMapper::Collection, :last)
62
- NewRelic::Agent::DataMapperTracing.add_tracer(DataMapper::Collection, :all)
63
-
64
- NewRelic::Agent::DataMapperTracing.add_tracer(DataMapper::Collection, :lazy_load)
65
-
66
- NewRelic::Agent::DataMapperTracing.add_tracer(DataMapper::Collection, :create)
67
- NewRelic::Agent::DataMapperTracing.add_tracer(DataMapper::Collection, :create!)
68
- NewRelic::Agent::DataMapperTracing.add_tracer(DataMapper::Collection, :update)
69
- NewRelic::Agent::DataMapperTracing.add_tracer(DataMapper::Collection, :update!)
70
- NewRelic::Agent::DataMapperTracing.add_tracer(DataMapper::Collection, :destroy)
71
- NewRelic::Agent::DataMapperTracing.add_tracer(DataMapper::Collection, :destroy!)
72
-
73
- NewRelic::Agent::DataMapperTracing.add_tracer(DataMapper::Collection, :aggregate)
74
- end
75
-
76
- executes do
77
- # Catch direct SQL calls that bypass CRUD
78
- if defined?(DataMapper::Adapters::DataObjectsAdapter)
79
- NewRelic::Agent::DataMapperTracing.add_tracer(DataMapper::Adapters::DataObjectsAdapter, :select, true)
80
- NewRelic::Agent::DataMapperTracing.add_tracer(DataMapper::Adapters::DataObjectsAdapter, :execute, true)
81
- end
82
- end
83
-
84
- executes do
85
- # DM::Validations overrides Model#create, so we patch it here as well
86
- if defined?(DataMapper::Validations::ClassMethods)
87
- NewRelic::Agent::DataMapperTracing.add_tracer(DataMapper::Validations::ClassMethods, :create)
88
- end
89
- end
90
-
91
- executes do
92
- # DM::Transaction calls commit() twice, so potentially shows up twice.
93
- if defined?(DataMapper::Transaction)
94
- NewRelic::Agent::DataMapperTracing.add_tracer(DataMapper::Transaction, :commit, true)
95
- end
96
- end
97
-
98
- executes do
99
- if defined?(DataObjects::Connection)
100
- DataObjects::Connection.class_eval do
101
- include NewRelic::Agent::Instrumentation::DataMapperInstrumentation
102
- end
103
- end
104
- end
105
- end
106
-
107
- module NewRelic
108
- module Agent
109
- module DataMapperTracing
110
- def self.add_tracer(clazz, method_name, operation_only = false)
111
- clazz.class_eval do
112
- if method_defined?(method_name) || private_method_defined?(method_name)
113
- define_method("#{method_name}_with_newrelic",
114
- NewRelic::Agent::DataMapperTracing.method_body(clazz, method_name, operation_only))
115
-
116
- alias_method("#{method_name}_without_newrelic", method_name)
117
- alias_method(method_name, "#{method_name}_with_newrelic")
118
- end
119
- end
120
- end
121
-
122
- DATA_MAPPER = "DataMapper".freeze
123
- PASSWORD_REGEX = /&password=.*?(&|$)/
124
- AMPERSAND = '&'.freeze
125
- PASSWORD_PARAM = '&password='.freeze
126
-
127
- def self.method_body(clazz, method_name, operation_only)
128
- use_model_name = NewRelic::Helper.instance_methods_include?(clazz, :model)
129
- metric_operation = method_name.to_s.gsub(/[!?]/, "")
130
-
131
- proc do |*args, &blk|
132
- begin
133
- if operation_only
134
- # Used by direct SQL, like ::DataMapper::Adapters::DataObjectsAdapter#select
135
- name = nil
136
- elsif use_model_name
137
- # Used by ::DataMapper::Collection to get contained model name
138
- name = self.model.name
139
- elsif self.is_a?(Class)
140
- # Used by class-style access, like Model.first()
141
- name = self.name
142
- else
143
- # Used by instance-style access, like model.update(attr: "new")
144
- name = self.class.name
145
- end
146
-
147
- segment = NewRelic::Agent::Tracer.start_datastore_segment(
148
- product: DATA_MAPPER,
149
- operation: metric_operation,
150
- collection: name
151
- )
152
-
153
- begin
154
- NewRelic::Agent::Tracer.capture_segment_error(segment) do
155
- self.send("#{method_name}_without_newrelic", *args, &blk)
156
- end
157
- rescue ::DataObjects::ConnectionError => e
158
- raise
159
- rescue ::DataObjects::SQLError => e
160
- e.uri.gsub!(PASSWORD_REGEX, AMPERSAND) if e.uri.include?(PASSWORD_PARAM)
161
-
162
- strategy = NewRelic::Agent::Database.record_sql_method(:slow_sql)
163
- case strategy
164
- when :obfuscated
165
- adapter_name = if self.respond_to?(:options)
166
- self.options[:adapter]
167
- else
168
- if self.repository.adapter.respond_to?(:options)
169
- self.repository.adapter.options[:adapter]
170
- else
171
- # DataMapper < 0.10.0
172
- self.repository.adapter.uri.scheme
173
- end
174
- end
175
- statement = NewRelic::Agent::Database::Statement.new(e.query, :adapter => adapter_name)
176
- obfuscated_sql = NewRelic::Agent::Database.obfuscate_sql(statement)
177
- e.instance_variable_set(:@query, obfuscated_sql)
178
- when :off
179
- e.instance_variable_set(:@query, nil)
180
- end
181
-
182
- raise
183
- ensure
184
- ::NewRelic::Agent::Transaction::Segment.finish(segment)
185
- end
186
- end
187
- end
188
- end
189
- end
190
-
191
- module Instrumentation
192
- module DataMapperInstrumentation
193
- # Unlike in AR, log is called in DM after the query actually ran,
194
- # complete with metrics. Since DO has already calculated the
195
- # duration, there's nothing more to measure, so just record and log.
196
- #
197
- # We rely on the assumption that all possible entry points have been
198
- # hooked with tracers, ensuring that notice_sql attaches this SQL to
199
- # the proper call scope.
200
- def log(msg) # THREAD_LOCAL_ACCESS
201
- state = NewRelic::Agent::Tracer.state
202
- return unless state.is_execution_traced?
203
-
204
- txn = state.current_transaction
205
-
206
- if txn && txn.current_segment.respond_to?(:notice_sql)
207
- txn.current_segment.notice_sql(msg.query)
208
- end
209
- ensure
210
- super
211
- end
212
- end
213
- end
214
- end
215
- end