newrelic_rpm 3.18.1.330 → 4.0.0.332

Sign up to get free protection for your applications and to get access to all the features.
Files changed (229) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +2 -74
  3. data/CHANGELOG.md +77 -0
  4. data/CONTRIBUTING.md +14 -6
  5. data/LICENSE +1 -88
  6. data/lib/new_relic/agent.rb +2 -103
  7. data/lib/new_relic/agent/agent.rb +3 -32
  8. data/lib/new_relic/agent/commands/thread_profiler_session.rb +2 -6
  9. data/lib/new_relic/agent/configuration/default_source.rb +1 -8
  10. data/lib/new_relic/agent/configuration/yaml_source.rb +1 -12
  11. data/lib/new_relic/agent/cross_app_monitor.rb +2 -1
  12. data/lib/new_relic/agent/cross_app_tracing.rb +4 -2
  13. data/lib/new_relic/agent/datastores/mongo.rb +1 -1
  14. data/lib/new_relic/agent/datastores/redis.rb +1 -1
  15. data/lib/new_relic/agent/encoding_normalizer.rb +1 -20
  16. data/lib/new_relic/agent/error_collector.rb +8 -21
  17. data/lib/new_relic/agent/inbound_request_monitor.rb +4 -1
  18. data/lib/new_relic/agent/instrumentation/active_record_helper.rb +14 -30
  19. data/lib/new_relic/agent/instrumentation/active_record_subscriber.rb +1 -1
  20. data/lib/new_relic/agent/instrumentation/controller_instrumentation.rb +4 -5
  21. data/lib/new_relic/agent/instrumentation/curb.rb +2 -2
  22. data/lib/new_relic/agent/instrumentation/excon.rb +3 -3
  23. data/lib/new_relic/agent/instrumentation/grape.rb +3 -3
  24. data/lib/new_relic/agent/instrumentation/httpclient.rb +2 -2
  25. data/lib/new_relic/agent/instrumentation/memcache/dalli.rb +2 -2
  26. data/lib/new_relic/agent/instrumentation/middleware_proxy.rb +2 -2
  27. data/lib/new_relic/agent/instrumentation/middleware_tracing.rb +3 -7
  28. data/lib/new_relic/agent/instrumentation/queue_time.rb +13 -15
  29. data/lib/new_relic/agent/instrumentation/rack.rb +4 -50
  30. data/lib/new_relic/agent/instrumentation/rake.rb +1 -1
  31. data/lib/new_relic/agent/instrumentation/resque.rb +1 -2
  32. data/lib/new_relic/agent/instrumentation/sinatra.rb +0 -1
  33. data/lib/new_relic/agent/instrumentation/typhoeus.rb +2 -2
  34. data/lib/new_relic/agent/javascript_instrumentor.rb +3 -2
  35. data/lib/new_relic/agent/method_tracer.rb +1 -60
  36. data/lib/new_relic/agent/new_relic_service.rb +3 -2
  37. data/lib/new_relic/agent/new_relic_service/encoders.rb +5 -6
  38. data/lib/new_relic/agent/new_relic_service/json_marshaller.rb +7 -16
  39. data/lib/new_relic/agent/pipe_channel_manager.rb +1 -3
  40. data/lib/new_relic/agent/pipe_service.rb +1 -3
  41. data/lib/new_relic/agent/rules_engine.rb +2 -17
  42. data/lib/new_relic/agent/stats_engine.rb +0 -2
  43. data/lib/new_relic/agent/stats_engine/metric_stats.rb +0 -48
  44. data/lib/new_relic/agent/supported_versions.rb +12 -19
  45. data/lib/new_relic/agent/threading/backtrace_service.rb +1 -1
  46. data/lib/new_relic/agent/transaction.rb +0 -3
  47. data/lib/new_relic/agent/transaction/attributes.rb +1 -10
  48. data/lib/new_relic/agent/vm.rb +1 -4
  49. data/lib/new_relic/agent/vm/jruby_vm.rb +1 -3
  50. data/lib/new_relic/agent/vm/mri_vm.rb +2 -10
  51. data/lib/new_relic/control.rb +1 -2
  52. data/lib/new_relic/control/frameworks/rails.rb +1 -1
  53. data/lib/new_relic/control/frameworks/rails3.rb +1 -2
  54. data/lib/new_relic/control/frameworks/rails4.rb +1 -1
  55. data/lib/new_relic/control/frameworks/rails5.rb +1 -1
  56. data/lib/new_relic/control/instance_methods.rb +1 -1
  57. data/{vendor/gems/dependency_detection-0.0.1.build/lib → lib/new_relic}/dependency_detection.rb +0 -1
  58. data/lib/new_relic/helper.rb +6 -13
  59. data/lib/new_relic/language_support.rb +44 -139
  60. data/lib/new_relic/metric_spec.rb +0 -17
  61. data/lib/new_relic/noticed_error.rb +18 -27
  62. data/lib/new_relic/version.rb +3 -48
  63. data/lib/tasks/versions.rake +7 -5
  64. data/newrelic_rpm.gemspec +1 -16
  65. data/test/agent_helper.rb +4 -2
  66. data/test/environments/lib/environments/runner.rb +5 -14
  67. data/test/environments/norails/Gemfile +0 -8
  68. data/test/environments/rails21/Gemfile +0 -8
  69. data/test/environments/rails21/config/database.yml +1 -1
  70. data/test/environments/rails22/Gemfile +0 -8
  71. data/test/environments/rails22/config/database.yml +1 -1
  72. data/test/environments/rails23/Gemfile +1 -7
  73. data/test/environments/rails23/config/database.yml +1 -1
  74. data/test/environments/rails30/Gemfile +0 -1
  75. data/test/environments/rails30/config/database.yml +1 -1
  76. data/test/environments/rails31/Gemfile +0 -3
  77. data/test/environments/rails31/config/database.yml +1 -1
  78. data/test/environments/rails32/Gemfile +0 -3
  79. data/test/environments/rails32/config/database.yml +1 -1
  80. data/test/environments/rails40/Gemfile +0 -26
  81. data/test/environments/rails40/config/database.yml +1 -1
  82. data/test/environments/rails41/Gemfile +0 -18
  83. data/test/environments/rails41/config/database.yml +1 -1
  84. data/test/environments/rails42/Gemfile +0 -22
  85. data/test/environments/rails42/config/database.yml +1 -1
  86. data/test/environments/rails50/Gemfile +0 -13
  87. data/test/environments/rails50/config/database.yml +1 -1
  88. data/test/helpers/logging.rb +37 -0
  89. data/test/helpers/minitest.rb +50 -0
  90. data/test/helpers/misc.rb +87 -0
  91. data/test/helpers/transaction_sample.rb +44 -0
  92. data/test/multiverse/lib/multiverse/suite.rb +6 -91
  93. data/test/multiverse/script/runner +1 -1
  94. data/test/multiverse/suites/active_record/Envfile +1 -28
  95. data/test/multiverse/suites/active_record/active_record_test.rb +6 -6
  96. data/test/multiverse/suites/active_record/config/database.rb +2 -3
  97. data/test/multiverse/suites/active_record/config/database.yml +0 -2
  98. data/test/multiverse/suites/activemerchant/Envfile +4 -18
  99. data/test/multiverse/suites/agent_only/encoding_handling_test.rb +7 -15
  100. data/test/multiverse/suites/agent_only/error_events_test.rb +1 -7
  101. data/test/multiverse/suites/agent_only/harvest_timestamps_test.rb +4 -20
  102. data/test/multiverse/suites/agent_only/labels_test.rb +1 -1
  103. data/test/multiverse/suites/agent_only/marshaling_test.rb +5 -10
  104. data/test/multiverse/suites/agent_only/script/public_api_when_disabled.rb +0 -11
  105. data/test/multiverse/suites/agent_only/start_up_test.rb +3 -3
  106. data/test/multiverse/suites/agent_only/synthetics_test.rb +1 -1
  107. data/test/multiverse/suites/agent_only/thread_profiling_test.rb +0 -3
  108. data/test/multiverse/suites/agent_only/xray_sessions_test.rb +0 -3
  109. data/test/multiverse/suites/capistrano/Envfile +2 -4
  110. data/test/multiverse/suites/capistrano2/Envfile +0 -4
  111. data/test/multiverse/suites/curb/Envfile +3 -7
  112. data/test/multiverse/suites/datamapper/Envfile +2 -2
  113. data/test/multiverse/suites/datamapper/datamapper_test.rb +2 -2
  114. data/test/multiverse/suites/deferred_instrumentation/sinatra_test.rb +0 -1
  115. data/test/multiverse/suites/delayed_job/Envfile +28 -41
  116. data/test/multiverse/suites/excon/Envfile +0 -3
  117. data/test/multiverse/suites/grape/Envfile +0 -4
  118. data/test/multiverse/suites/grape/grape_versioning_test.rb +2 -2
  119. data/test/multiverse/suites/grape/grape_versioning_test_api.rb +2 -2
  120. data/test/multiverse/suites/json/Envfile +1 -9
  121. data/test/multiverse/suites/marshalling/Envfile +0 -9
  122. data/test/multiverse/suites/memcached/Envfile +5 -23
  123. data/test/multiverse/suites/mongo/Envfile +9 -11
  124. data/test/multiverse/suites/padrino/Envfile +0 -6
  125. data/test/multiverse/suites/rack/http_response_code_test.rb +0 -1
  126. data/test/multiverse/suites/rack/rack_auto_instrumentation_test.rb +5 -10
  127. data/test/multiverse/suites/rack/rack_cascade_test.rb +0 -1
  128. data/test/multiverse/suites/rack/rack_env_mutation_test.rb +0 -1
  129. data/test/multiverse/suites/rack/response_content_type_test.rb +0 -1
  130. data/test/multiverse/suites/rails/Envfile +1 -19
  131. data/test/multiverse/suites/rails/activejob_test.rb +1 -2
  132. data/test/multiverse/suites/rails/error_tracing_test.rb +0 -13
  133. data/test/multiverse/suites/rails/gc_instrumentation_test.rb +12 -32
  134. data/test/multiverse/suites/rake/Envfile +15 -22
  135. data/test/multiverse/suites/redis/redis_instrumentation_test.rb +1 -1
  136. data/test/multiverse/suites/sequel/database.rb +1 -4
  137. data/test/multiverse/suites/sidekiq/Envfile +13 -23
  138. data/test/multiverse/suites/sinatra/sinatra_test_cases.rb +3 -3
  139. data/test/multiverse/suites/typhoeus/Envfile +0 -19
  140. data/test/multiverse/suites/typhoeus/typhoeus_test.rb +3 -3
  141. data/test/multiverse/suites/yajl/Envfile +5 -0
  142. data/test/multiverse/suites/yajl/yajl_test.rb +1 -3
  143. data/test/new_relic/agent/agent/start_test.rb +3 -3
  144. data/test/new_relic/agent/agent_logger_test.rb +2 -2
  145. data/test/new_relic/agent/agent_test.rb +2 -2
  146. data/test/new_relic/agent/attribute_processing_test.rb +3 -4
  147. data/test/new_relic/agent/audit_logger_test.rb +4 -6
  148. data/test/new_relic/agent/aws_info_test.rb +17 -1
  149. data/test/new_relic/agent/busy_calculator_test.rb +14 -16
  150. data/test/new_relic/agent/configuration/manager_test.rb +1 -7
  151. data/test/new_relic/agent/cross_app_monitor_test.rb +1 -1
  152. data/test/new_relic/agent/database_test.rb +2 -10
  153. data/test/new_relic/agent/datastores/mongo/event_formatter_test.rb +90 -93
  154. data/test/new_relic/agent/datastores/redis_test.rb +14 -16
  155. data/test/new_relic/agent/encoding_normalizer_test.rb +38 -40
  156. data/test/new_relic/agent/error_collector_test.rb +16 -49
  157. data/test/new_relic/agent/instrumentation/active_record_helper_test.rb +0 -6
  158. data/test/new_relic/agent/instrumentation/active_record_subscriber_test.rb +1 -1
  159. data/test/new_relic/agent/instrumentation/mongodb_command_subscriber_test.rb +101 -103
  160. data/test/new_relic/agent/instrumentation/rack_test.rb +11 -14
  161. data/test/new_relic/agent/instrumentation/task_instrumentation_test.rb +0 -10
  162. data/test/new_relic/agent/javascript_instrumentor_test.rb +2 -2
  163. data/test/new_relic/agent/method_tracer/class_methods/add_method_tracer_test.rb +0 -10
  164. data/test/new_relic/agent/method_tracer_test.rb +35 -76
  165. data/test/new_relic/agent/new_relic_service_test.rb +86 -102
  166. data/test/new_relic/agent/pipe_channel_manager_test.rb +4 -9
  167. data/test/new_relic/agent/pipe_service_test.rb +2 -3
  168. data/test/new_relic/agent/rpm_agent_test.rb +0 -4
  169. data/test/new_relic/agent/sampled_buffer_test.rb +2 -2
  170. data/test/new_relic/agent/samplers/cpu_sampler_test.rb +28 -0
  171. data/test/new_relic/agent/samplers/memory_sampler_test.rb +66 -0
  172. data/test/new_relic/agent/sized_buffer_test.rb +1 -1
  173. data/test/new_relic/agent/stats_engine/gc_profiler_test.rb +2 -14
  174. data/test/new_relic/agent/stats_engine/metric_stats_test.rb +44 -66
  175. data/test/new_relic/agent/stats_test.rb +6 -8
  176. data/test/new_relic/agent/synthetics_event_buffer_test.rb +1 -1
  177. data/test/new_relic/agent/transaction/attributes_test.rb +4 -12
  178. data/test/new_relic/agent/transaction_test.rb +2 -10
  179. data/test/new_relic/agent/utilization_data_test.rb +17 -1
  180. data/test/new_relic/agent/vm/mri_vm_test.rb +5 -7
  181. data/test/new_relic/agent_test.rb +0 -43
  182. data/test/new_relic/coerce_test.rb +1 -3
  183. data/test/new_relic/fake_collector.rb +3 -3
  184. data/test/new_relic/fake_external_server.rb +1 -1
  185. data/test/new_relic/fake_server.rb +1 -1
  186. data/test/new_relic/http_client_test_cases.rb +3 -3
  187. data/test/new_relic/language_support_test.rb +6 -12
  188. data/test/new_relic/latest_changes_test.rb +0 -11
  189. data/test/new_relic/license_test.rb +3 -8
  190. data/test/new_relic/multiverse_helpers.rb +1 -1
  191. data/test/new_relic/noticed_error_test.rb +11 -7
  192. data/test/new_relic/rack/browser_monitoring_test.rb +1 -3
  193. data/test/nullverse/nullverse_helper.rb +1 -1
  194. data/test/performance/lib/performance.rb +1 -1
  195. data/test/performance/lib/performance/instrumentation/gc_stats.rb +4 -6
  196. data/test/performance/lib/performance/instrumentation/perf_tools.rb +1 -1
  197. data/test/performance/lib/performance/instrumentation/stackprof.rb +1 -1
  198. data/test/performance/lib/performance/platform.rb +1 -8
  199. data/test/performance/script/runner +1 -3
  200. data/test/performance/suites/active_record.rb +3 -24
  201. data/test/test_helper.rb +9 -216
  202. metadata +9 -45
  203. data/lib/conditional_vendored_dependency_detection.rb +0 -7
  204. data/lib/new_relic/agent/hash_extensions.rb +0 -41
  205. data/lib/new_relic/agent/instrumentation/metric_frame.rb +0 -39
  206. data/lib/new_relic/agent/instrumentation/rails/errors.rb +0 -51
  207. data/lib/new_relic/agent/instrumentation/rails3/errors.rb +0 -47
  208. data/lib/new_relic/agent/instrumentation/rails4/errors.rb +0 -46
  209. data/lib/new_relic/agent/stats_engine/samplers.rb +0 -22
  210. data/lib/new_relic/agent/vm/rubinius_vm.rb +0 -140
  211. data/lib/new_relic/json_wrapper.rb +0 -78
  212. data/lib/new_relic/okjson.rb +0 -602
  213. data/lib/new_relic/rack/error_collector.rb +0 -27
  214. data/lib/new_relic/timer_lib.rb +0 -31
  215. data/test/helpers/runtime_detection.rb +0 -17
  216. data/test/multiverse/suites/no_json/Envfile +0 -12
  217. data/test/multiverse/suites/no_json/config/newrelic.yml +0 -27
  218. data/test/multiverse/suites/no_json/marshal_config_test.rb +0 -22
  219. data/test/new_relic/agent/hash_extensions_test.rb +0 -59
  220. data/test/new_relic/agent/instrumentation/metric_frame_test.rb +0 -22
  221. data/test/new_relic/agent/stats_engine/samplers_test.rb +0 -98
  222. data/test/new_relic/agent/vm/rubinius_vm_test.rb +0 -69
  223. data/test/new_relic/json_wrapper_test.rb +0 -32
  224. data/test/new_relic/rack/deferred_instrumentation_test.rb +0 -33
  225. data/test/new_relic/rack/error_collector_test.rb +0 -83
  226. data/test/new_relic/version_number_test.rb +0 -101
  227. data/test/script/before_install/revert_rubygems.sh +0 -15
  228. data/test/script/before_install/update_bundler.sh +0 -12
  229. data/vendor/gems/dependency_detection-0.0.1.build/lib/dependency_detection/version.rb +0 -7
@@ -376,32 +376,16 @@ module NewRelic
376
376
 
377
377
  def should_install_exit_handler?
378
378
  (
379
- Agent.config[:send_data_on_exit] &&
380
- !NewRelic::LanguageSupport.using_engine?('jruby') &&
379
+ Agent.config[:send_data_on_exit] &&
380
+ !NewRelic::LanguageSupport.jruby? &&
381
381
  !sinatra_classic_app?
382
382
  )
383
383
  end
384
384
 
385
- # There's an MRI 1.9 bug that loses exit codes in at_exit blocks.
386
- # A workaround is necessary to get correct exit codes for the agent's
387
- # test suites.
388
- # http://bugs.ruby-lang.org/issues/5218
389
- def need_exit_code_workaround?
390
- defined?(RUBY_ENGINE) && RUBY_ENGINE == "ruby" && RUBY_VERSION.match(/^1\.9/)
391
- end
392
-
393
385
  def install_exit_handler
394
386
  return unless should_install_exit_handler?
395
387
  NewRelic::Agent.logger.debug("Installing at_exit handler")
396
- at_exit do
397
- if need_exit_code_workaround?
398
- exit_status = $!.status if $!.is_a?(SystemExit)
399
- shutdown
400
- exit exit_status if exit_status
401
- else
402
- shutdown
403
- end
404
- end
388
+ at_exit { shutdown }
405
389
  end
406
390
 
407
391
  # Classy logging of the agent version and the current pid,
@@ -535,14 +519,6 @@ module NewRelic
535
519
  return false
536
520
  end
537
521
 
538
- unless NewRelic::Agent::NewRelicService::JsonMarshaller.is_supported?
539
- NewRelic::Agent.logger.error "JSON marshaller requested, but the 'json' gem was not available. ",
540
- "You will need to: 1) upgrade to Ruby 1.9.3 or newer (strongly recommended), ",
541
- "2) add the 'json' gem to your Gemfile or operating environment, ",
542
- "or 3) use a version of newrelic_rpm prior to 3.14.0."
543
- return false
544
- end
545
-
546
522
  return true
547
523
  end
548
524
 
@@ -569,11 +545,6 @@ module NewRelic
569
545
  @sql_sampler.reset!
570
546
  end
571
547
 
572
- # Deprecated, and not part of the public API, but here for backwards
573
- # compatibility because some 3rd-party gems call it.
574
- # @deprecated
575
- def reset_stats; drop_buffered_data; end
576
-
577
548
  # Clear out state for any objects that we know lock from our parents
578
549
  # This is necessary for cases where we're in a forked child and Ruby
579
550
  # might be holding locks for background thread that aren't there anymore.
@@ -87,12 +87,8 @@ module NewRelic
87
87
 
88
88
  def raise_unsupported_error
89
89
  msg = <<-EOF
90
- Thread profiling is only supported on 1.9.2 and greater versions of Ruby.
91
- We detected running agents capable of profiling, but the profile started with
92
- an agent running Ruby #{RUBY_VERSION}.
93
-
94
- Profiling again might select an appropriate agent, but we recommend running a
95
- consistent version of Ruby across your application for better results.
90
+ Thread profiling is not supported for Resque processes. If you did not intend to
91
+ profile a Resque process, profiling again might select an appropriate agent.
96
92
  EOF
97
93
  raise_command_error(msg)
98
94
  end
@@ -127,13 +127,6 @@ module NewRelic
127
127
  Proc.new { NewRelic::Control.instance.local_env.discovered_dispatcher }
128
128
  end
129
129
 
130
- # On Rubies with string encodings support (1.9.x+), default to always
131
- # normalize encodings since it's safest and fast. Without that support
132
- # the conversions are too expensive, so only enable if overridden to.
133
- def self.normalize_json_string_encodings
134
- Proc.new { NewRelic::LanguageSupport.supports_string_encodings? }
135
- end
136
-
137
130
  def self.thread_profiler_enabled
138
131
  Proc.new { NewRelic::Agent::Threading::BacktraceService.is_supported? }
139
132
  end
@@ -1204,7 +1197,7 @@ module NewRelic
1204
1197
  :description => 'Controls whether to check on running a transaction whether to respawn the harvest thread.'
1205
1198
  },
1206
1199
  :normalize_json_string_encodings => {
1207
- :default => DefaultSource.normalize_json_string_encodings,
1200
+ :default => true,
1208
1201
  :public => false,
1209
1202
  :type => Boolean,
1210
1203
  :allowed_from_server => false,
@@ -100,7 +100,7 @@ module NewRelic
100
100
 
101
101
  def process_yaml(file, env, config, path)
102
102
  if file
103
- confighash = with_yaml_engine { YAML.load(file) }
103
+ confighash = YAML.load(file)
104
104
  unless confighash.key?(env)
105
105
  log_failure("Config file at #{path} doesn't include a '#{env}' section!")
106
106
  end
@@ -119,17 +119,6 @@ module NewRelic
119
119
  end
120
120
  end
121
121
 
122
- def with_yaml_engine
123
- return yield unless NewRelic::LanguageSupport.needs_syck?
124
-
125
- yamler = ::YAML::ENGINE.yamler
126
- ::YAML::ENGINE.yamler = 'syck'
127
- result = yield
128
- ::YAML::ENGINE.yamler = yamler
129
- result
130
- end
131
-
132
-
133
122
  def booleanify_values(config, *keys)
134
123
  # auto means defer ro default
135
124
  keys.each do |option|
@@ -3,6 +3,7 @@
3
3
  # See https://github.com/newrelic/rpm/blob/master/LICENSE for complete details.
4
4
 
5
5
  require 'digest'
6
+ require 'json'
6
7
 
7
8
  require 'new_relic/agent/inbound_request_monitor'
8
9
  require 'new_relic/agent/transaction_state'
@@ -129,7 +130,7 @@ module NewRelic
129
130
  content_length,
130
131
  state.request_guid
131
132
  ]
132
- payload = obfuscator.obfuscate(NewRelic::JSONWrapper.dump(payload))
133
+ payload = obfuscator.obfuscate(::JSON.dump(payload))
133
134
  end
134
135
 
135
136
  def set_transaction_attributes(state)
@@ -3,6 +3,8 @@
3
3
  # This file is distributed under New Relic's license terms.
4
4
  # See https://github.com/newrelic/rpm/blob/master/LICENSE for complete details.
5
5
 
6
+ require 'json'
7
+
6
8
  module NewRelic
7
9
  module Agent
8
10
  module CrossAppTracing
@@ -57,7 +59,7 @@ module NewRelic
57
59
 
58
60
  def insert_request_headers(request, txn_guid, trip_id, path_hash, synthetics_header)
59
61
  cross_app_id = NewRelic::Agent.config[:cross_process_id]
60
- txn_data = NewRelic::JSONWrapper.dump([txn_guid, false, trip_id, path_hash])
62
+ txn_data = ::JSON.dump([txn_guid, false, trip_id, path_hash])
61
63
 
62
64
  request[NR_ID_HEADER] = obfuscator.obfuscate(cross_app_id)
63
65
  request[NR_TXN_HEADER] = obfuscator.obfuscate(txn_data)
@@ -93,7 +95,7 @@ module NewRelic
93
95
  decoded_appdata.set_encoding(::Encoding::UTF_8) if
94
96
  decoded_appdata.respond_to?(:set_encoding)
95
97
 
96
- NewRelic::JSONWrapper.load(decoded_appdata)
98
+ ::JSON.load(decoded_appdata)
97
99
  end
98
100
 
99
101
  def valid_cross_app_id?(xp_id)
@@ -16,7 +16,7 @@ module NewRelic
16
16
  end
17
17
 
18
18
  def self.is_unsupported_2x?
19
- defined?(::Mongo::VERSION) && VersionNumber.new(::Mongo::VERSION).major_version == 2 &&
19
+ defined?(::Mongo::VERSION) && Gem::Version.new(::Mongo::VERSION).segments[0] == 2 &&
20
20
  !self.is_monitoring_enabled?
21
21
  end
22
22
 
@@ -89,7 +89,7 @@ module NewRelic
89
89
  end
90
90
 
91
91
  def self.is_supported_version?
92
- ::NewRelic::VersionNumber.new(::Redis::VERSION) >= ::NewRelic::VersionNumber.new("3.0.0")
92
+ Gem::Version.new(::Redis::VERSION) >= Gem::Version.new("3.0.0")
93
93
  end
94
94
 
95
95
  def self.ellipsize(result, string)
@@ -8,8 +8,7 @@ module NewRelic
8
8
  module Agent
9
9
  module EncodingNormalizer
10
10
  def self.normalize_string(raw_string)
11
- @normalizer ||= choose_normalizer
12
- @normalizer.normalize(raw_string)
11
+ EncodingNormalizer.normalize(raw_string)
13
12
  end
14
13
 
15
14
  def self.normalize_object(object)
@@ -37,14 +36,6 @@ module NewRelic
37
36
  end
38
37
  end
39
38
 
40
- def self.choose_normalizer
41
- if NewRelic::LanguageSupport.supports_string_encodings?
42
- EncodingNormalizer
43
- else
44
- IconvNormalizer
45
- end
46
- end
47
-
48
39
  module EncodingNormalizer
49
40
  def self.normalize(raw_string)
50
41
  encoding = raw_string.encoding
@@ -69,16 +60,6 @@ module NewRelic
69
60
  normalized
70
61
  end
71
62
  end
72
-
73
- module IconvNormalizer
74
- def self.normalize(raw_string)
75
- if @iconv.nil?
76
- require 'iconv'
77
- @iconv = Iconv.new('utf-8', 'iso-8859-1')
78
- end
79
- @iconv.iconv(raw_string)
80
- end
81
- end
82
63
  end
83
64
  end
84
65
  end
@@ -14,8 +14,8 @@ module NewRelic
14
14
  # Maximum possible length of the queue - defaults to 20, may be
15
15
  # made configurable in the future. This is a tradeoff between
16
16
  # memory and data retention
17
- MAX_ERROR_QUEUE_LENGTH = 20 unless defined? MAX_ERROR_QUEUE_LENGTH
18
- EXCEPTION_TAG_IVAR = :'@__nr_seen_exception' unless defined? EXCEPTION_TAG_IVAR
17
+ MAX_ERROR_QUEUE_LENGTH = 20
18
+ EXCEPTION_TAG_IVAR = :'@__nr_seen_exception'
19
19
 
20
20
  attr_reader :error_trace_aggregator, :error_event_aggregator
21
21
 
@@ -180,12 +180,16 @@ module NewRelic
180
180
  # detection and soft fail-safe. Returns nil if the method does
181
181
  # not exist
182
182
  def sense_method(object, method)
183
- object.send(method) if object.respond_to?(method)
183
+ object.__send__(method) if object.respond_to?(method)
184
184
  end
185
185
 
186
186
  # extracts a stack trace from the exception for debugging purposes
187
187
  def extract_stack_trace(exception)
188
- actual_exception = sense_method(exception, :cause) || sense_method(exception, :original_exception) || exception
188
+ actual_exception = if defined?(Rails) && Rails::VERSION::MAJOR < 5
189
+ sense_method(exception, :original_exception) || exception
190
+ else
191
+ exception
192
+ end
189
193
  sense_method(actual_exception, :backtrace) || '<no stack trace>'
190
194
  end
191
195
 
@@ -225,8 +229,6 @@ module NewRelic
225
229
  noticed_error.line_number = sense_method(exception, :line_number)
226
230
  noticed_error.stack_trace = extract_stack_trace(exception)
227
231
 
228
- handle_deprecated_options(options)
229
-
230
232
  noticed_error.attributes_from_notice_error = options.delete(:custom_params) || {}
231
233
 
232
234
  # Any options that are passed to notice_error which aren't known keys
@@ -236,21 +238,6 @@ module NewRelic
236
238
  noticed_error
237
239
  end
238
240
 
239
- DEPRECATED_OPTIONS_MSG = "Passing %s to notice_error is no longer supported. Set values on the enclosing transaction or record them as custom attributes instead.".freeze
240
- DEPRECATED_OPTIONS = [:request_params, :request, :referer].freeze
241
-
242
- # Old options no longer used by notice_error can still be passed. If they
243
- # are, they shouldn't get merged into custom attributes. Delete and
244
- # warn callers so they can fix their calls to notice_error.
245
- def handle_deprecated_options(options)
246
- DEPRECATED_OPTIONS.each do |deprecated|
247
- if options.include?(deprecated)
248
- NewRelic::Agent.logger.warn(DEPRECATED_OPTIONS_MSG % deprecated)
249
- options.delete(deprecated)
250
- end
251
- end
252
- end
253
-
254
241
  # *Use sparingly for difficult to track bugs.*
255
242
  #
256
243
  # Track internal agent errors for communication back to New Relic.
@@ -10,6 +10,9 @@
10
10
  # be called when the agent is fully configured. That method is expected to
11
11
  # subscribe to the necessary request events, such as before_call and after_call
12
12
  # for the monitor to do its work.
13
+
14
+ require 'json'
15
+
13
16
  module NewRelic
14
17
  module Agent
15
18
  class InboundRequestMonitor
@@ -30,7 +33,7 @@ module NewRelic
30
33
 
31
34
  def deserialize_header(encoded_header, key)
32
35
  decoded_header = obfuscator.deobfuscate(encoded_header)
33
- NewRelic::JSONWrapper.load(decoded_header)
36
+ ::JSON.load(decoded_header)
34
37
  rescue => err
35
38
  # If we have a failure of any type here, just return nil and carry on
36
39
  NewRelic::Agent.logger.debug("Failure deserializing encoded header '#{key}' in #{self.class}, #{err.class}, #{err.message}")
@@ -3,7 +3,6 @@
3
3
  # See https://github.com/newrelic/rpm/blob/master/LICENSE for complete details.
4
4
 
5
5
  require 'new_relic/agent/datastores/metric_helper'
6
- require 'new_relic/agent/deprecator'
7
6
 
8
7
  module NewRelic
9
8
  module Agent
@@ -83,8 +82,8 @@ module NewRelic
83
82
  end
84
83
  end
85
84
 
86
- ACTIVE_RECORD = "ActiveRecord".freeze unless defined?(ACTIVE_RECORD)
87
- OTHER = "other".freeze unless defined?(OTHER)
85
+ ACTIVE_RECORD = "ActiveRecord".freeze
86
+ OTHER = "other".freeze
88
87
 
89
88
  def product_operation_collection_for name, sql, adapter_name
90
89
  product = map_product(adapter_name)
@@ -94,23 +93,8 @@ module NewRelic
94
93
  NewRelic::Agent::Datastores::MetricHelper.product_operation_collection_for product, operation, model, ACTIVE_RECORD
95
94
  end
96
95
 
97
- # @deprecated
98
- def rollup_metrics_for(*_)
99
- NewRelic::Agent::Deprecator.deprecate("ActiveRecordHelper.rollup_metrics_for",
100
- "NewRelic::Agent::Datastores::MetricHelper.metrics_for")
101
-
102
- rollup_metric = if NewRelic::Agent::Transaction.recording_web_transaction?
103
- NewRelic::Agent::Datastores::MetricHelper::WEB_ROLLUP_METRIC
104
- else
105
- NewRelic::Agent::Datastores::MetricHelper::OTHER_ROLLUP_METRIC
106
- end
107
-
108
- [rollup_metric,
109
- NewRelic::Agent::Datastores::MetricHelper::ROLLUP_METRIC]
110
- end
111
-
112
- SPACE = ' '.freeze unless defined?(SPACE)
113
- EMPTY = [].freeze unless defined?(EMPTY)
96
+ SPACE = ' '.freeze
97
+ EMPTY = [].freeze
114
98
 
115
99
  def split_name(name)
116
100
  if name && name.respond_to?(:split)
@@ -150,7 +134,7 @@ module NewRelic
150
134
  'Destroy' => 'destroy',
151
135
  'Update' => 'update',
152
136
  'Save' => 'save'
153
- }.freeze unless defined?(OPERATION_NAMES)
137
+ }.freeze
154
138
 
155
139
  def map_operation(raw_operation)
156
140
  direct_op = OPERATION_NAMES[raw_operation]
@@ -195,9 +179,9 @@ module NewRelic
195
179
 
196
180
  # https://rubygems.org/gems/activerecord-oracle_enhanced-adapter
197
181
  "oracle_enhanced" => "Oracle"
198
- }.freeze unless defined?(PRODUCT_NAMES)
182
+ }.freeze
199
183
 
200
- ACTIVE_RECORD_DEFAULT_PRODUCT_NAME = "ActiveRecord".freeze unless defined?(ACTIVE_RECORD_DEFAULT_PRODUCT_NAME)
184
+ ACTIVE_RECORD_DEFAULT_PRODUCT_NAME = "ActiveRecord".freeze
201
185
 
202
186
  def map_product(adapter_name)
203
187
  PRODUCT_NAMES.fetch(adapter_name,
@@ -214,17 +198,17 @@ module NewRelic
214
198
 
215
199
  "postgresql" => :postgres,
216
200
  "jdbcpostgresql" => :postgres
217
- }.freeze unless defined?(PRODUCT_SYMBOLS)
201
+ }.freeze
218
202
 
219
203
  DATASTORE_DEFAULT_PORTS = {
220
204
  :mysql => "3306",
221
205
  :postgres => "5432"
222
- }.freeze unless defined?(DATASTORE_DEFAULT_PORTS)
206
+ }.freeze
223
207
 
224
- DEFAULT = "default".freeze unless defined?(DEFAULT)
225
- UNKNOWN = "unknown".freeze unless defined?(UNKNOWN)
226
- SLASH = "/".freeze unless defined?(SLASH)
227
- LOCALHOST = "localhost".freeze unless defined?(LOCALHOST)
208
+ DEFAULT = "default".freeze
209
+ UNKNOWN = "unknown".freeze
210
+ SLASH = "/".freeze
211
+ LOCALHOST = "localhost".freeze
228
212
 
229
213
  def host(config)
230
214
  return UNKNOWN unless config
@@ -267,7 +251,7 @@ module NewRelic
267
251
  UNKNOWN
268
252
  end
269
253
 
270
- SUPPORTED_ADAPTERS = [:mysql, :postgres].freeze unless defined?(SUPPORTED_ADAPTERS)
254
+ SUPPORTED_ADAPTERS = [:mysql, :postgres].freeze
271
255
 
272
256
  def supported_adapter? config
273
257
  config && SUPPORTED_ADAPTERS.include?(PRODUCT_SYMBOLS[config[:adapter]])
@@ -11,7 +11,7 @@ module NewRelic
11
11
  module Agent
12
12
  module Instrumentation
13
13
  class ActiveRecordSubscriber < EventedSubscriber
14
- CACHED_QUERY_NAME = 'CACHE'.freeze unless defined? CACHED_QUERY_NAME
14
+ CACHED_QUERY_NAME = 'CACHE'.freeze
15
15
 
16
16
  def initialize
17
17
  # We cache this in an instance variable to avoid re-calling method
@@ -38,15 +38,14 @@ module NewRelic
38
38
  def self.included(clazz)
39
39
  clazz.extend(ClassMethodsShim)
40
40
  end
41
- def newrelic_notice_error(*args); end
42
41
  def new_relic_trace_controller_action(*args); yield; end
43
42
  def perform_action_with_newrelic_trace(*args); yield; end
44
43
  end
45
44
 
46
- NR_DO_NOT_TRACE_KEY = :'@do_not_trace' unless defined?(NR_DO_NOT_TRACE_KEY )
47
- NR_IGNORE_APDEX_KEY = :'@ignore_apdex' unless defined?(NR_IGNORE_APDEX_KEY )
48
- NR_IGNORE_ENDUSER_KEY = :'@ignore_enduser' unless defined?(NR_IGNORE_ENDUSER_KEY)
49
- NR_DEFAULT_OPTIONS = {}.freeze unless defined?(NR_DEFAULT_OPTIONS )
45
+ NR_DO_NOT_TRACE_KEY = :'@do_not_trace'
46
+ NR_IGNORE_APDEX_KEY = :'@ignore_apdex'
47
+ NR_IGNORE_ENDUSER_KEY = :'@ignore_enduser'
48
+ NR_DEFAULT_OPTIONS = {}.freeze
50
49
 
51
50
  # @api public
52
51
  module ClassMethods
@@ -5,11 +5,11 @@
5
5
  DependencyDetection.defer do
6
6
  named :curb
7
7
 
8
- CURB_MIN_VERSION = ::NewRelic::VersionNumber.new("0.8.1")
8
+ CURB_MIN_VERSION = Gem::Version.new("0.8.1")
9
9
 
10
10
  depends_on do
11
11
  defined?(::Curl) && defined?(::Curl::CURB_VERSION) &&
12
- ::NewRelic::VersionNumber.new(::Curl::CURB_VERSION) >= CURB_MIN_VERSION
12
+ Gem::Version.new(::Curl::CURB_VERSION) >= CURB_MIN_VERSION
13
13
  end
14
14
 
15
15
  executes do