newrelic_rpm 9.4.2 → 9.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (92) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +138 -10
  3. data/Rakefile +1 -1
  4. data/lib/new_relic/agent/attribute_pre_filtering.rb +109 -0
  5. data/lib/new_relic/agent/configuration/default_source.rb +153 -33
  6. data/lib/new_relic/agent/http_clients/async_http_wrappers.rb +83 -0
  7. data/lib/new_relic/agent/http_clients/ethon_wrappers.rb +111 -0
  8. data/lib/new_relic/agent/http_clients/httpx_wrappers.rb +93 -0
  9. data/lib/new_relic/agent/instrumentation/active_record_helper.rb +1 -2
  10. data/lib/new_relic/agent/instrumentation/active_support_broadcast_logger/chain.rb +69 -0
  11. data/lib/new_relic/agent/instrumentation/active_support_broadcast_logger/instrumentation.rb +13 -0
  12. data/lib/new_relic/agent/instrumentation/active_support_broadcast_logger/prepend.rb +37 -0
  13. data/lib/new_relic/agent/instrumentation/active_support_broadcast_logger.rb +23 -0
  14. data/lib/new_relic/agent/instrumentation/active_support_logger/instrumentation.rb +4 -0
  15. data/lib/new_relic/agent/instrumentation/active_support_logger.rb +3 -1
  16. data/lib/new_relic/agent/instrumentation/async_http/chain.rb +23 -0
  17. data/lib/new_relic/agent/instrumentation/async_http/instrumentation.rb +37 -0
  18. data/lib/new_relic/agent/instrumentation/async_http/prepend.rb +15 -0
  19. data/lib/new_relic/agent/instrumentation/async_http.rb +26 -0
  20. data/lib/new_relic/agent/instrumentation/bunny/instrumentation.rb +9 -0
  21. data/lib/new_relic/agent/instrumentation/concurrent_ruby/instrumentation.rb +2 -2
  22. data/lib/new_relic/agent/instrumentation/curb/instrumentation.rb +4 -0
  23. data/lib/new_relic/agent/instrumentation/delayed_job/instrumentation.rb +3 -0
  24. data/lib/new_relic/agent/instrumentation/elasticsearch/instrumentation.rb +4 -1
  25. data/lib/new_relic/agent/instrumentation/ethon/chain.rb +39 -0
  26. data/lib/new_relic/agent/instrumentation/ethon/instrumentation.rb +105 -0
  27. data/lib/new_relic/agent/instrumentation/ethon/prepend.rb +35 -0
  28. data/lib/new_relic/agent/instrumentation/ethon.rb +39 -0
  29. data/lib/new_relic/agent/instrumentation/excon/middleware.rb +3 -0
  30. data/lib/new_relic/agent/instrumentation/grape/instrumentation.rb +4 -0
  31. data/lib/new_relic/agent/instrumentation/grpc/client/instrumentation.rb +4 -0
  32. data/lib/new_relic/agent/instrumentation/grpc/server/instrumentation.rb +4 -0
  33. data/lib/new_relic/agent/instrumentation/grpc_client.rb +1 -1
  34. data/lib/new_relic/agent/instrumentation/grpc_server.rb +1 -1
  35. data/lib/new_relic/agent/instrumentation/httpclient/instrumentation.rb +4 -0
  36. data/lib/new_relic/agent/instrumentation/httprb/instrumentation.rb +4 -0
  37. data/lib/new_relic/agent/instrumentation/httpx/chain.rb +20 -0
  38. data/lib/new_relic/agent/instrumentation/httpx/instrumentation.rb +51 -0
  39. data/lib/new_relic/agent/instrumentation/httpx/prepend.rb +15 -0
  40. data/lib/new_relic/agent/instrumentation/httpx.rb +27 -0
  41. data/lib/new_relic/agent/instrumentation/logger/instrumentation.rb +3 -0
  42. data/lib/new_relic/agent/instrumentation/memcache/instrumentation.rb +9 -0
  43. data/lib/new_relic/agent/instrumentation/mongodb_command_subscriber.rb +1 -3
  44. data/lib/new_relic/agent/instrumentation/net_http/instrumentation.rb +5 -1
  45. data/lib/new_relic/agent/instrumentation/notifications_subscriber.rb +4 -0
  46. data/lib/new_relic/agent/instrumentation/padrino/instrumentation.rb +4 -0
  47. data/lib/new_relic/agent/instrumentation/rack/instrumentation.rb +6 -0
  48. data/lib/new_relic/agent/instrumentation/rails3/action_controller.rb +4 -0
  49. data/lib/new_relic/agent/instrumentation/rails_notifications/action_controller.rb +1 -0
  50. data/lib/new_relic/agent/instrumentation/rake/instrumentation.rb +4 -0
  51. data/lib/new_relic/agent/instrumentation/redis/instrumentation.rb +4 -0
  52. data/lib/new_relic/agent/instrumentation/resque/instrumentation.rb +4 -0
  53. data/lib/new_relic/agent/instrumentation/roda/ignorer.rb +45 -0
  54. data/lib/new_relic/agent/instrumentation/roda/instrumentation.rb +16 -0
  55. data/lib/new_relic/agent/instrumentation/roda/roda_transaction_namer.rb +1 -2
  56. data/lib/new_relic/agent/instrumentation/roda.rb +2 -0
  57. data/lib/new_relic/agent/instrumentation/sidekiq/client.rb +4 -0
  58. data/lib/new_relic/agent/instrumentation/sidekiq/server.rb +26 -3
  59. data/lib/new_relic/agent/instrumentation/sidekiq.rb +5 -3
  60. data/lib/new_relic/agent/instrumentation/sinatra/instrumentation.rb +4 -0
  61. data/lib/new_relic/agent/instrumentation/sinatra/transaction_namer.rb +1 -3
  62. data/lib/new_relic/agent/instrumentation/stripe.rb +28 -0
  63. data/lib/new_relic/agent/instrumentation/stripe_subscriber.rb +77 -0
  64. data/lib/new_relic/agent/instrumentation/tilt/instrumentation.rb +4 -0
  65. data/lib/new_relic/agent/instrumentation/typhoeus/instrumentation.rb +5 -1
  66. data/lib/new_relic/agent/messaging.rb +2 -2
  67. data/lib/new_relic/agent/monitors/synthetics_monitor.rb +12 -1
  68. data/lib/new_relic/agent/rules_engine.rb +1 -1
  69. data/lib/new_relic/agent/span_event_primitive.rb +16 -4
  70. data/lib/new_relic/agent/system_info.rb +26 -0
  71. data/lib/new_relic/agent/tracer.rb +1 -3
  72. data/lib/new_relic/agent/transaction/abstract_segment.rb +55 -0
  73. data/lib/new_relic/agent/transaction/external_request_segment.rb +5 -2
  74. data/lib/new_relic/agent/transaction/message_broker_segment.rb +1 -2
  75. data/lib/new_relic/agent/transaction/request_attributes.rb +1 -3
  76. data/lib/new_relic/agent/transaction.rb +25 -2
  77. data/lib/new_relic/agent/transaction_error_primitive.rb +16 -0
  78. data/lib/new_relic/agent/transaction_event_primitive.rb +19 -0
  79. data/lib/new_relic/agent/utilization/gcp.rb +1 -3
  80. data/lib/new_relic/agent.rb +18 -2
  81. data/lib/new_relic/constants.rb +3 -0
  82. data/lib/new_relic/control/frameworks/rails.rb +14 -2
  83. data/lib/new_relic/language_support.rb +4 -0
  84. data/lib/new_relic/rack/agent_hooks.rb +1 -1
  85. data/lib/new_relic/rack/agent_middleware.rb +0 -16
  86. data/lib/new_relic/supportability_helper.rb +1 -0
  87. data/lib/new_relic/version.rb +2 -2
  88. data/lib/tasks/instrumentation_generator/instrumentation.thor +3 -3
  89. data/lib/tasks/tests.rake +71 -0
  90. data/newrelic.yml +93 -32
  91. data/newrelic_rpm.gemspec +4 -1
  92. metadata +39 -2
@@ -31,9 +31,14 @@ module NewRelic
31
31
  SYNTHETICS_RESOURCE_ID_KEY = 'nr.syntheticsResourceId'.freeze
32
32
  SYNTHETICS_JOB_ID_KEY = 'nr.syntheticsJobId'.freeze
33
33
  SYNTHETICS_MONITOR_ID_KEY = 'nr.syntheticsMonitorId'.freeze
34
+ SYNTHETICS_TYPE_KEY = 'nr.syntheticsType'
35
+ SYNTHETICS_INITIATOR_KEY = 'nr.syntheticsInitiator'
36
+ SYNTHETICS_KEY_PREFIX = 'nr.synthetics'
34
37
  PRIORITY_KEY = 'priority'.freeze
35
38
  SPAN_ID_KEY = 'spanId'.freeze
36
39
 
40
+ SYNTHETICS_PAYLOAD_EXPECTED = [:synthetics_resource_id, :synthetics_job_id, :synthetics_monitor_id, :synthetics_type, :synthetics_initiator]
41
+
37
42
  def create(noticed_error, payload, span_id)
38
43
  [
39
44
  intrinsic_attributes_for(noticed_error, payload, span_id),
@@ -71,9 +76,20 @@ module NewRelic
71
76
  end
72
77
 
73
78
  def append_synthetics(payload, sample)
79
+ return unless payload[:synthetics_job_id]
80
+
74
81
  sample[SYNTHETICS_RESOURCE_ID_KEY] = payload[:synthetics_resource_id] if payload[:synthetics_resource_id]
75
82
  sample[SYNTHETICS_JOB_ID_KEY] = payload[:synthetics_job_id] if payload[:synthetics_job_id]
76
83
  sample[SYNTHETICS_MONITOR_ID_KEY] = payload[:synthetics_monitor_id] if payload[:synthetics_monitor_id]
84
+ sample[SYNTHETICS_TYPE_KEY] = payload[:synthetics_type] if payload[:synthetics_type]
85
+ sample[SYNTHETICS_INITIATOR_KEY] = payload[:synthetics_initiator] if payload[:synthetics_initiator]
86
+
87
+ payload.each do |k, v|
88
+ next unless k.to_s.start_with?('synthetics_') && !SYNTHETICS_PAYLOAD_EXPECTED.include?(k)
89
+
90
+ new_key = SYNTHETICS_KEY_PREFIX + NewRelic::LanguageSupport.camelize(k.to_s.gsub('synthetics_', ''))
91
+ sample[new_key] = v
92
+ end
77
93
  end
78
94
 
79
95
  def append_cat(payload, sample)
@@ -38,6 +38,11 @@ module NewRelic
38
38
  SYNTHETICS_RESOURCE_ID_KEY = 'nr.syntheticsResourceId'
39
39
  SYNTHETICS_JOB_ID_KEY = 'nr.syntheticsJobId'
40
40
  SYNTHETICS_MONITOR_ID_KEY = 'nr.syntheticsMonitorId'
41
+ SYNTHETICS_TYPE_KEY = 'nr.syntheticsType'
42
+ SYNTHETICS_INITIATOR_KEY = 'nr.syntheticsInitiator'
43
+ SYNTHETICS_KEY_PREFIX = 'nr.synthetics'
44
+
45
+ SYNTHETICS_PAYLOAD_EXPECTED = [:synthetics_resource_id, :synthetics_job_id, :synthetics_monitor_id, :synthetics_type, :synthetics_initiator]
41
46
 
42
47
  def create(payload)
43
48
  intrinsics = {
@@ -71,9 +76,23 @@ module NewRelic
71
76
  optionally_append(SYNTHETICS_RESOURCE_ID_KEY, :synthetics_resource_id, sample, payload)
72
77
  optionally_append(SYNTHETICS_JOB_ID_KEY, :synthetics_job_id, sample, payload)
73
78
  optionally_append(SYNTHETICS_MONITOR_ID_KEY, :synthetics_monitor_id, sample, payload)
79
+ optionally_append(SYNTHETICS_TYPE_KEY, :synthetics_type, sample, payload)
80
+ optionally_append(SYNTHETICS_INITIATOR_KEY, :synthetics_initiator, sample, payload)
81
+ append_synthetics_info_attributes(sample, payload)
74
82
  append_cat_alternate_path_hashes(sample, payload)
75
83
  end
76
84
 
85
+ def append_synthetics_info_attributes(sample, payload)
86
+ return unless payload.include?(:synthetics_job_id)
87
+
88
+ payload.each do |k, v|
89
+ next unless k.to_s.start_with?('synthetics_') && !SYNTHETICS_PAYLOAD_EXPECTED.include?(k)
90
+
91
+ new_key = SYNTHETICS_KEY_PREFIX + NewRelic::LanguageSupport.camelize(k.to_s.gsub('synthetics_', ''))
92
+ sample[new_key] = v.to_s
93
+ end
94
+ end
95
+
77
96
  def append_cat_alternate_path_hashes(sample, payload)
78
97
  if payload.include?(:cat_alternate_path_hashes)
79
98
  sample[CAT_ALTERNATE_PATH_HASHES_KEY] = payload[:cat_alternate_path_hashes].sort.join(COMMA)
@@ -24,10 +24,8 @@ module NewRelic
24
24
  body
25
25
  end
26
26
 
27
- SLASH = '/'.freeze
28
-
29
27
  def trim_leading(value)
30
- value.split(SLASH).last
28
+ value.split(NewRelic::SLASH).last
31
29
  end
32
30
  end
33
31
  end
@@ -58,6 +58,7 @@ module NewRelic
58
58
  require 'new_relic/agent/deprecator'
59
59
  require 'new_relic/agent/logging'
60
60
  require 'new_relic/agent/distributed_tracing'
61
+ require 'new_relic/agent/attribute_pre_filtering'
61
62
  require 'new_relic/agent/attribute_processing'
62
63
  require 'new_relic/agent/linking_metadata'
63
64
  require 'new_relic/agent/local_log_decorator'
@@ -213,6 +214,17 @@ module NewRelic
213
214
  record_metric(metric_name, value)
214
215
  end
215
216
 
217
+ def record_instrumentation_invocation(library)
218
+ record_metric_once("Supportability/#{library}/Invoked")
219
+ end
220
+
221
+ # see ActiveSupport::Inflector.demodulize
222
+ def base_name(klass_name)
223
+ return klass_name unless ridx = klass_name.rindex('::')
224
+
225
+ klass_name[(ridx + 2), klass_name.length]
226
+ end
227
+
216
228
  SUPPORTABILITY_INCREMENT_METRIC = 'Supportability/API/increment_metric'.freeze
217
229
 
218
230
  # Increment a simple counter metric.
@@ -621,7 +633,9 @@ module NewRelic
621
633
  def add_new_segment_attributes(params, segment)
622
634
  # Make sure not to override existing segment-level custom attributes
623
635
  segment_custom_keys = segment.attributes.custom_attributes.keys.map(&:to_sym)
624
- segment.add_custom_attributes(params.reject { |k, _v| segment_custom_keys.include?(k.to_sym) })
636
+ segment.add_custom_attributes(params.reject do |k, _v|
637
+ segment_custom_keys.include?(k.to_sym) if k.respond_to?(:to_sym) # param keys can be integers
638
+ end)
625
639
  end
626
640
 
627
641
  # Add custom attributes to the span event for the current span. Attributes will be visible on spans in the
@@ -649,7 +663,9 @@ module NewRelic
649
663
  end
650
664
  end
651
665
 
652
- # Add custom attributes to log events for the current agent instance.
666
+ # Add global custom attributes to log events for the current agent instance. As these attributes are global to the
667
+ # agent instance, they will be attached to all log events generated by the agent, and this methods usage isn't
668
+ # suitable for setting dynamic values.
653
669
  #
654
670
  # @param [Hash] params A Hash of attributes to attach to log
655
671
  # events. The agent accepts up to 240 custom
@@ -35,4 +35,7 @@ module NewRelic
35
35
 
36
36
  CONNECT_RETRY_PERIODS = [15, 15, 30, 60, 120, 300]
37
37
  MAX_RETRY_PERIOD = 300
38
+
39
+ SLASH = '/'
40
+ ROOT = SLASH
38
41
  end
@@ -10,6 +10,9 @@ module NewRelic
10
10
  # Rails specific configuration, instrumentation, environment values,
11
11
  # etc.
12
12
  class Rails < NewRelic::Control::Frameworks::Ruby
13
+ BROWSER_MONITORING_INSTALLED_SINGLETON = NewRelic::Agent.config
14
+ BROWSER_MONITORING_INSTALLED_VARIABLE = :@browser_monitoring_installed
15
+
13
16
  def env
14
17
  @env ||= (ENV['NEW_RELIC_ENV'] || RAILS_ENV.dup)
15
18
  end
@@ -97,9 +100,9 @@ module NewRelic
97
100
 
98
101
  def install_browser_monitoring(config)
99
102
  @install_lock.synchronize do
100
- return if defined?(@browser_monitoring_installed) && @browser_monitoring_installed
103
+ return if browser_agent_already_installed?
101
104
 
102
- @browser_monitoring_installed = true
105
+ mark_browser_agent_as_installed
103
106
  return if config.nil? || !config.respond_to?(:middleware) || !Agent.config[:'browser_monitoring.auto_instrument']
104
107
 
105
108
  begin
@@ -112,6 +115,15 @@ module NewRelic
112
115
  end
113
116
  end
114
117
 
118
+ def browser_agent_already_installed?
119
+ BROWSER_MONITORING_INSTALLED_SINGLETON.instance_variable_defined?(BROWSER_MONITORING_INSTALLED_VARIABLE) &&
120
+ BROWSER_MONITORING_INSTALLED_SINGLETON.instance_variable_get(BROWSER_MONITORING_INSTALLED_VARIABLE)
121
+ end
122
+
123
+ def mark_browser_agent_as_installed
124
+ BROWSER_MONITORING_INSTALLED_SINGLETON.instance_variable_set(BROWSER_MONITORING_INSTALLED_VARIABLE, true)
125
+ end
126
+
115
127
  def rails_version
116
128
  @rails_version ||= Gem::Version.new(::Rails::VERSION::STRING)
117
129
  end
@@ -83,6 +83,10 @@ module NewRelic
83
83
  camelized[0].downcase.concat(camelized[1..-1])
84
84
  end
85
85
 
86
+ def snakeize(string)
87
+ string.gsub(/(.)([A-Z])/, '\1_\2').downcase
88
+ end
89
+
86
90
  def bundled_gem?(gem_name)
87
91
  defined?(Bundler) && Bundler.rubygems.all_specs.map(&:name).include?(gem_name)
88
92
  rescue => e
@@ -23,7 +23,7 @@ module NewRelic::Rack
23
23
  #
24
24
  class AgentHooks < AgentMiddleware
25
25
  def self.needed?
26
- !NewRelic::Agent.config[:disable_middleware_instrumentation]
26
+ NewRelic::Agent.config[:disable_middleware_instrumentation]
27
27
  end
28
28
 
29
29
  def traced_call(env)
@@ -26,22 +26,6 @@ module NewRelic
26
26
  prefix = ::NewRelic::Agent::Instrumentation::ControllerInstrumentation::TransactionNamer.prefix_for_category(nil, @category)
27
27
  "#{prefix}#{self.class.name}/call"
28
28
  end
29
-
30
- # If middleware tracing is disabled, we'll still inject our agent-specific
31
- # middlewares, and still trace those, but we don't want to capture HTTP
32
- # response codes, since middleware that's outside of ours might change the
33
- # response code before it goes back to the client.
34
- def capture_http_response_code(state, result)
35
- return if NewRelic::Agent.config[:disable_middleware_instrumentation]
36
-
37
- super
38
- end
39
-
40
- def capture_response_content_type(state, result)
41
- return if NewRelic::Agent.config[:disable_middleware_instrumentation]
42
-
43
- super
44
- end
45
29
  end
46
30
  end
47
31
  end
@@ -46,6 +46,7 @@ module NewRelic
46
46
  :recording_web_transaction?,
47
47
  :require_test_helper,
48
48
  :set_error_group_callback,
49
+ :set_segment_callback,
49
50
  :set_sql_obfuscator,
50
51
  :set_transaction_name,
51
52
  :set_user_id,
@@ -6,8 +6,8 @@
6
6
  module NewRelic
7
7
  module VERSION # :nodoc:
8
8
  MAJOR = 9
9
- MINOR = 4
10
- TINY = 2
9
+ MINOR = 6
10
+ TINY = 0
11
11
 
12
12
  STRING = "#{MAJOR}.#{MINOR}.#{TINY}"
13
13
  end
@@ -82,7 +82,7 @@ class Instrumentation < Thor
82
82
  insert_into_file(
83
83
  DEFAULT_SOURCE_LOCATION,
84
84
  config_block(name.downcase),
85
- after: ":description => 'Controls auto-instrumentation of bunny at start up. May be one of [auto|prepend|chain|disabled].'
85
+ after: ":description => 'Controls auto-instrumentation of bunny at start-up. May be one of [auto|prepend|chain|disabled].'
86
86
  },\n"
87
87
  )
88
88
  end
@@ -103,7 +103,7 @@ class Instrumentation < Thor
103
103
  :type => String,
104
104
  :dynamic_name => true,
105
105
  :allowed_from_server => false,
106
- :description => 'Controls auto-instrumentation of the #{name} library at start up. May be one of [auto|prepend|chain|disabled].'
106
+ :description => 'Controls auto-instrumentation of the #{name} library at start-up. May be one of [auto|prepend|chain|disabled].'
107
107
  },
108
108
  CONFIG
109
109
  end
@@ -111,7 +111,7 @@ class Instrumentation < Thor
111
111
  def yaml_block(name)
112
112
  <<~HEREDOC
113
113
 
114
- # Controls auto-instrumentation of #{name} at start up.
114
+ # Controls auto-instrumentation of #{name} at start-up.
115
115
  # May be one of [auto|prepend|chain|disabled]
116
116
  # instrumentation.#{name.downcase}: auto
117
117
  HEREDOC
data/lib/tasks/tests.rake CHANGED
@@ -11,6 +11,75 @@ rescue LoadError
11
11
  end
12
12
 
13
13
  if defined? Rake::TestTask
14
+ def name_for_number(content, number)
15
+ (number - 1).downto(0).each do |i|
16
+ return Regexp.last_match(1) if content[i] =~ /^\s*def (test_.+)\s*$/
17
+ end
18
+ end
19
+
20
+ def info_from_test_var
21
+ return {} unless ENV['TEST'].to_s =~ /^(.+)((?::\d+)+)/
22
+
23
+ file = Regexp.last_match(1)
24
+ numbers = Regexp.last_match(2).split(':').reject(&:empty?).uniq.map(&:to_i)
25
+ abs = File.expand_path(File.join('../../..', file), __FILE__)
26
+ raise "File >>#{abs}<< does not exist!" unless File.exist?(abs)
27
+
28
+ content = File.read(abs).split("\n")
29
+ {file: file, numbers: numbers, content: content}
30
+ end
31
+
32
+ def test_names_from_test_file(info)
33
+ info[:numbers].each_with_object([]) do |number, names|
34
+ name = name_for_number(info[:content], number)
35
+ unless name
36
+ warn "Unable to determine a test name given line >>#{number}<< for file >>#{info[:file]}<<"
37
+ next
38
+ end
39
+ names << name
40
+ end
41
+ end
42
+
43
+ # Allow ENV['TEST'] to be set to a test file path with one or more
44
+ # `:<line number>` patterns on the end of it.
45
+ #
46
+ # For example:
47
+ # TEST=test/new_relic/agent/autostart_test.rb:57 bundle exec rake test
48
+ #
49
+ # The `autostart_test.rb` file will be read, and starting from line 57 and
50
+ # working upwards in the file (downwards by line number), a test definition
51
+ # will be searched for that matches `def test_<rest of the test name>`.
52
+ #
53
+ # Multiple line numbers can be specified like so:
54
+ # TEST=test/new_relic/agent/autostart_test.rb:57:26 bundle exec rake test
55
+ #
56
+ # For this multiple line number based example, both lines 57 and 26 will
57
+ # serve as separate starting points for the search for a test name.
58
+ #
59
+ # All test names that are discovered will be "ORed" into a regex pattern with
60
+ # pipes ('|') that is passed to Minitest via
61
+ # `TESTOPTS="--name='test_name1|test_name2'"`
62
+ #
63
+ # Once a line with one or more `:<line number>` values on the end of it has
64
+ # been found, replace the value of ENV['TEST'] with the path leading up to
65
+ # the first colon before invoking Minitest.
66
+ #
67
+ # Why refer to a test by line number instead of just supplying the name
68
+ # directly? The primary use case is text editor integration. A text editor
69
+ # can be taught to "run the single unit test containing the line the cursor is
70
+ # on" by building a string containing the path to the file, a colon, (':'),
71
+ # and the line number.
72
+ def process_line_numbers
73
+ info = info_from_test_var
74
+ return unless info.key?(:file)
75
+
76
+ test_names = test_names_from_test_file(info)
77
+ raise "Could not determine any test names for file >>#{abs}<< given numbers >>#{numbers}" if test_names.empty?
78
+
79
+ ENV['TESTOPTS'] = "#{ENV['TESTOPTS']} --name='#{test_names.map { |n| Regexp.escape(n) }.join('|')}'"
80
+ ENV['TEST'] = info[:file]
81
+ end
82
+
14
83
  namespace :test do
15
84
  tasks = Rake.application.top_level_tasks
16
85
  ENV['TESTOPTS'] ||= ''
@@ -21,6 +90,8 @@ if defined? Rake::TestTask
21
90
  ENV['TESTOPTS'] += ' --' + seed
22
91
  end
23
92
 
93
+ process_line_numbers
94
+
24
95
  agent_home = File.expand_path(File.join(File.dirname(__FILE__), '..', '..'))
25
96
 
26
97
  Rake::TestTask.new(:newrelic) do |t|
data/newrelic.yml CHANGED
@@ -102,7 +102,7 @@ common: &default_settings
102
102
  # Specify a list of constants that should prevent the agent from starting
103
103
  # automatically. Separate individual constants with a comma ,. For example,
104
104
  # "Rails::Console,UninstrumentedBackgroundJob".
105
- # autostart.denylisted_constants: Rails::Console
105
+ # autostart.denylisted_constants: Rails::Command::ConsoleCommand,Rails::Command::CredentialsCommand,Rails::Command::Db::System::ChangeCommand,Rails::Command::DbConsoleCommand,Rails::Command::DestroyCommand,Rails::Command::DevCommand,Rails::Command::EncryptedCommand,Rails::Command::GenerateCommand,Rails::Command::InitializersCommand,Rails::Command::NotesCommand,Rails::Command::RoutesCommand,Rails::Command::SecretsCommand,Rails::Console,Rails::DBConsole
106
106
 
107
107
  # Defines a comma-delimited list of executables that the agent should not
108
108
  # instrument. For example, "rake,my_ruby_script.rb".
@@ -223,6 +223,9 @@ common: &default_settings
223
223
 
224
224
  # If true, the agent won't wrap third-party middlewares in instrumentation
225
225
  # (regardless of whether they are installed via Rack::Builder or Rails).
226
+ # When middleware instrumentation is disabled, if an application is using
227
+ # middleware that could alter the response code, the HTTP status code reported on
228
+ # the transaction may not reflect the altered value.
226
229
  # disable_middleware_instrumentation: false
227
230
 
228
231
  # If true, disables agent middleware for Roda. This middleware is responsible for
@@ -371,39 +374,51 @@ common: &default_settings
371
374
  # Configures the TCP/IP port for the trace observer Host
372
375
  # infinite_tracing.trace_observer.port: 443
373
376
 
377
+ # Controls auto-instrumentation of ActiveSupport::BroadcastLogger at start up. May
378
+ # be one of: auto, prepend, chain, disabled. Used in Rails versions >= 7.1.
379
+ # instrumentation.active_support_broadcast_logger: auto
380
+
374
381
  # Controls auto-instrumentation of ActiveSupport::Logger at start up. May be one
375
- # of: auto, prepend, chain, disabled.
382
+ # of: auto, prepend, chain, disabled. Used in Rails versions below 7.1.
376
383
  # instrumentation.active_support_logger: auto
377
384
 
378
- # Controls auto-instrumentation of bunny at start up. May be one of: auto,
385
+ # Controls auto-instrumentation of Async::HTTP at start up. May be one of: auto,
386
+ # prepend, chain, disabled.
387
+ # instrumentation.async_http: auto
388
+
389
+ # Controls auto-instrumentation of bunny at start-up. May be one of: auto,
379
390
  # prepend, chain, disabled.
380
391
  # instrumentation.bunny: auto
381
392
 
382
- # Controls auto-instrumentation of the concurrent-ruby library at start up. May be
393
+ # Controls auto-instrumentation of the concurrent-ruby library at start-up. May be
383
394
  # one of: auto, prepend, chain, disabled.
384
395
  # instrumentation.concurrent_ruby: auto
385
396
 
386
- # Controls auto-instrumentation of Curb at start up. May be one of: auto, prepend,
397
+ # Controls auto-instrumentation of Curb at start-up. May be one of: auto, prepend,
387
398
  # chain, disabled.
388
399
  # instrumentation.curb: auto
389
400
 
390
- # Controls auto-instrumentation of Delayed Job at start up. May be one of: auto,
401
+ # Controls auto-instrumentation of Delayed Job at start-up. May be one of: auto,
391
402
  # prepend, chain, disabled.
392
403
  # instrumentation.delayed_job: auto
393
404
 
394
- # Controls auto-instrumentation of the elasticsearch library at start up. May be
405
+ # Controls auto-instrumentation of the elasticsearch library at start-up. May be
395
406
  # one of: auto, prepend, chain, disabled.
396
407
  # instrumentation.elasticsearch: auto
397
408
 
398
- # Controls auto-instrumentation of Excon at start up. May be one of: enabled,
409
+ # Controls auto-instrumentation of ethon at start up. May be one of
410
+ # [auto|prepend|chain|disabled]
411
+ # instrumentation.ethon: auto
412
+
413
+ # Controls auto-instrumentation of Excon at start-up. May be one of: enabled,
399
414
  # disabled.
400
415
  # instrumentation.excon: enabled
401
416
 
402
- # Controls auto-instrumentation of the Fiber class at start up. May be one of:
417
+ # Controls auto-instrumentation of the Fiber class at start-up. May be one of:
403
418
  # auto, prepend, chain, disabled.
404
419
  # instrumentation.fiber: auto
405
420
 
406
- # Controls auto-instrumentation of Grape at start up. May be one of: auto,
421
+ # Controls auto-instrumentation of Grape at start-up. May be one of: auto,
407
422
  # prepend, chain, disabled.
408
423
  # instrumentation.grape: auto
409
424
 
@@ -416,43 +431,47 @@ common: &default_settings
416
431
  # example, "private.com$,exception.*"
417
432
  # instrumentation.grpc.host_denylist: []
418
433
 
419
- # Controls auto-instrumentation of gRPC clients at start up. May be one of: auto,
434
+ # Controls auto-instrumentation of gRPC clients at start-up. May be one of: auto,
420
435
  # prepend, chain, disabled.
421
436
  # instrumentation.grpc_client: auto
422
437
 
423
- # Controls auto-instrumentation of gRPC servers at start up. May be one of: auto,
438
+ # Controls auto-instrumentation of gRPC servers at start-up. May be one of: auto,
424
439
  # prepend, chain, disabled.
425
440
  # instrumentation.grpc_server: auto
426
441
 
427
- # Controls auto-instrumentation of HTTPClient at start up. May be one of: auto,
442
+ # Controls auto-instrumentation of HTTPClient at start-up. May be one of: auto,
428
443
  # prepend, chain, disabled.
429
444
  # instrumentation.httpclient: auto
430
445
 
431
- # Controls auto-instrumentation of http.rb gem at start up. May be one of: auto,
446
+ # Controls auto-instrumentation of http.rb gem at start-up. May be one of: auto,
432
447
  # prepend, chain, disabled.
433
448
  # instrumentation.httprb: auto
434
449
 
435
- # Controls auto-instrumentation of Ruby standard library Logger at start up. May
450
+ # Controls auto-instrumentation of httpx at start up. May be one of
451
+ # [auto|prepend|chain|disabled]
452
+ # instrumentation.httpx: auto
453
+
454
+ # Controls auto-instrumentation of Ruby standard library Logger at start-up. May
436
455
  # be one of: auto, prepend, chain, disabled.
437
456
  # instrumentation.logger: auto
438
457
 
439
- # Controls auto-instrumentation of dalli gem for Memcache at start up. May be one
458
+ # Controls auto-instrumentation of dalli gem for Memcache at start-up. May be one
440
459
  # of: auto, prepend, chain, disabled.
441
460
  # instrumentation.memcache: auto
442
461
 
443
- # Controls auto-instrumentation of memcache-client gem for Memcache at start up.
462
+ # Controls auto-instrumentation of memcache-client gem for Memcache at start-up.
444
463
  # May be one of: auto, prepend, chain, disabled.
445
464
  # instrumentation.memcache_client: auto
446
465
 
447
- # Controls auto-instrumentation of memcached gem for Memcache at start up. May be
466
+ # Controls auto-instrumentation of memcached gem for Memcache at start-up. May be
448
467
  # one of: auto, prepend, chain, disabled.
449
468
  # instrumentation.memcached: auto
450
469
 
451
- # Controls auto-instrumentation of Mongo at start up. May be one of: enabled,
470
+ # Controls auto-instrumentation of Mongo at start-up. May be one of: enabled,
452
471
  # disabled.
453
472
  # instrumentation.mongo: enabled
454
473
 
455
- # Controls auto-instrumentation of Net::HTTP at start up. May be one of: auto,
474
+ # Controls auto-instrumentation of Net::HTTP at start-up. May be one of: auto,
456
475
  # prepend, chain, disabled.
457
476
  # instrumentation.net_http: auto
458
477
 
@@ -461,7 +480,7 @@ common: &default_settings
461
480
  # application startup. May be one of: auto, prepend, chain, disabled.
462
481
  # instrumentation.puma_rack: auto
463
482
 
464
- # Controls auto-instrumentation of Puma::Rack::URLMap at start up. May be one of:
483
+ # Controls auto-instrumentation of Puma::Rack::URLMap at start-up. May be one of:
465
484
  # auto, prepend, chain, disabled.
466
485
  # instrumentation.puma_rack_urlmap: auto
467
486
 
@@ -470,45 +489,49 @@ common: &default_settings
470
489
  # startup. May be one of: auto, prepend, chain, disabled.
471
490
  # instrumentation.rack: auto
472
491
 
473
- # Controls auto-instrumentation of Rack::URLMap at start up. May be one of: auto,
492
+ # Controls auto-instrumentation of Rack::URLMap at start-up. May be one of: auto,
474
493
  # prepend, chain, disabled.
475
494
  # instrumentation.rack_urlmap: auto
476
495
 
477
- # Controls auto-instrumentation of rake at start up. May be one of: auto, prepend,
496
+ # Controls auto-instrumentation of rake at start-up. May be one of: auto, prepend,
478
497
  # chain, disabled.
479
498
  # instrumentation.rake: auto
480
499
 
481
- # Controls auto-instrumentation of Redis at start up. May be one of: auto,
500
+ # Controls auto-instrumentation of Redis at start-up. May be one of: auto,
482
501
  # prepend, chain, disabled.
483
502
  # instrumentation.redis: auto
484
503
 
485
- # Controls auto-instrumentation of resque at start up. May be one of: auto,
504
+ # Controls auto-instrumentation of resque at start-up. May be one of: auto,
486
505
  # prepend, chain, disabled.
487
506
  # instrumentation.resque: auto
488
507
 
489
- # Controls auto-instrumentation of Roda at start up. May be one of: auto, prepend,
508
+ # Controls auto-instrumentation of Roda at start-up. May be one of: auto, prepend,
490
509
  # chain, disabled.
491
510
  # instrumentation.roda: auto
492
511
 
493
- # Controls auto-instrumentation of Sinatra at start up. May be one of: auto,
512
+ # Controls auto-instrumentation of Sinatra at start-up. May be one of: auto,
494
513
  # prepend, chain, disabled.
495
514
  # instrumentation.sinatra: auto
496
515
 
497
- # Controls auto-instrumentation of the Thread class at start up to allow the agent
516
+ # Controls auto-instrumentation of Stripe at startup. May be one of: enabled,
517
+ # disabled.
518
+ # instrumentation.stripe: enabled
519
+
520
+ # Controls auto-instrumentation of the Thread class at start-up to allow the agent
498
521
  # to correctly nest spans inside of an asynchronous transaction. This does not
499
522
  # enable the agent to automatically trace all threads created (see
500
523
  # instrumentation.thread.tracing). May be one of: auto, prepend, chain, disabled.
501
524
  # instrumentation.thread: auto
502
525
 
503
- # Controls auto-instrumentation of the Thread class at start up to automatically
526
+ # Controls auto-instrumentation of the Thread class at start-up to automatically
504
527
  # add tracing to all Threads created in the application.
505
528
  # instrumentation.thread.tracing: true
506
529
 
507
- # Controls auto-instrumentation of the Tilt template rendering library at start
508
- # up. May be one of: auto, prepend, chain, disabled.
530
+ # Controls auto-instrumentation of the Tilt template rendering library at
531
+ # start-up. May be one of: auto, prepend, chain, disabled.
509
532
  # instrumentation.tilt: auto
510
533
 
511
- # Controls auto-instrumentation of Typhoeus at start up. May be one of: auto,
534
+ # Controls auto-instrumentation of Typhoeus at start-up. May be one of: auto,
512
535
  # prepend, chain, disabled.
513
536
  # instrumentation.typhoeus: auto
514
537
 
@@ -585,6 +608,26 @@ common: &default_settings
585
608
  # before shutting down.
586
609
  # send_data_on_exit: true
587
610
 
611
+ # An array of strings that will collectively serve as a denylist for filtering
612
+ # which Sidekiq job arguments get reported to New Relic. To capture any Sidekiq
613
+ # arguments, 'job.sidekiq.args.*' must be added to the separate
614
+ # :'attributes.include' configuration option. Each string in this array will be
615
+ # turned into a regular expression via Regexp.new to permit advanced matching. For
616
+ # job argument hashes, if either a key or value matches the pair will be excluded.
617
+ # All matching job argument array elements and job argument scalars will be
618
+ # excluded.
619
+ # sidekiq.args.exclude: []
620
+
621
+ # An array of strings that will collectively serve as an allowlist for filtering
622
+ # which Sidekiq job arguments get reported to New Relic. To capture any Sidekiq
623
+ # arguments, 'job.sidekiq.args.*' must be added to the separate
624
+ # :'attributes.include' configuration option. Each string in this array will be
625
+ # turned into a regular expression via Regexp.new to permit advanced matching. For
626
+ # job argument hashes, if either a key or value matches the pair will be included.
627
+ # All matching job argument array elements and job argument scalars will be
628
+ # included.
629
+ # sidekiq.args.include: []
630
+
588
631
  # If true, the agent collects slow SQL queries.
589
632
  # slow_sql.enabled: true
590
633
 
@@ -634,6 +677,24 @@ common: &default_settings
634
677
  # allowlist. Enabled automatically in high security mode.
635
678
  # strip_exception_messages.enabled: false
636
679
 
680
+ # An array of strings to specify which keys and/or values inside a Stripe event's
681
+ # user_data hash should
682
+ # not be reported to New Relic. Each string in this array will be turned into a
683
+ # regular expression via
684
+ # Regexp.new to permit advanced matching. For each hash pair, if either the key or
685
+ # value is matched the
686
+ # pair will not be reported. By default, no user_data is reported, so this option
687
+ # should only be used if
688
+ # the stripe.user_data.include option is being used.
689
+ # stripe.user_data.exclude: []
690
+
691
+ # An array of strings to specify which keys inside a Stripe event's user_data hash
692
+ # should be reported
693
+ # to New Relic. Each string in this array will be turned into a regular expression
694
+ # via Regexp.new to
695
+ # permit advanced matching. Setting the value to ["."] will report all user_data.
696
+ # stripe.user_data.include: []
697
+
637
698
  # When set to true, forces a synchronous connection to the New Relic collector
638
699
  # during application startup. For very short-lived processes, this helps ensure
639
700
  # the New Relic agent has time to report.
data/newrelic_rpm.gemspec CHANGED
@@ -49,13 +49,16 @@ Gem::Specification.new do |s|
49
49
  s.homepage = 'https://github.com/newrelic/newrelic-ruby-agent'
50
50
  s.require_paths = ['lib']
51
51
  s.summary = 'New Relic Ruby Agent'
52
+
53
+ s.add_dependency 'base64'
54
+
52
55
  s.add_development_dependency 'bundler'
53
56
  s.add_development_dependency 'feedjira', '3.2.1' unless ENV['CI'] || RUBY_VERSION < '2.5' # for Gabby
54
57
  s.add_development_dependency 'httparty' unless ENV['CI'] # for perf tests and Gabby
55
58
  s.add_development_dependency 'minitest', "#{RUBY_VERSION >= '2.7.0' ? '5.3.3' : '4.7.5'}"
56
59
  s.add_development_dependency 'minitest-stub-const', '0.6'
57
60
  s.add_development_dependency 'mocha', '~> 1.16'
58
- s.add_development_dependency 'pry' unless ENV['CI']
61
+ s.add_development_dependency 'pry' if ENV['ENABLE_PRY']
59
62
  s.add_development_dependency 'rack'
60
63
  s.add_development_dependency 'rake', '12.3.3'
61
64