newrelic_rpm 3.7.3.204 → 3.8.0.218

Sign up to get free protection for your applications and to get access to all the features.
Files changed (154) hide show
  1. data.tar.gz.sig +0 -0
  2. data/CHANGELOG +73 -0
  3. data/README.md +1 -1
  4. data/Rakefile +1 -5
  5. data/lib/new_relic/agent.rb +1 -0
  6. data/lib/new_relic/agent/agent.rb +47 -18
  7. data/lib/new_relic/agent/agent_logger.rb +11 -1
  8. data/lib/new_relic/agent/configuration/default_source.rb +85 -1
  9. data/lib/new_relic/agent/configuration/manager.rb +5 -1
  10. data/lib/new_relic/agent/datastores/mongo.rb +8 -3
  11. data/lib/new_relic/agent/harvester.rb +5 -1
  12. data/lib/new_relic/agent/instrumentation/action_controller_subscriber.rb +1 -0
  13. data/lib/new_relic/agent/instrumentation/active_merchant.rb +7 -3
  14. data/lib/new_relic/agent/instrumentation/controller_instrumentation.rb +13 -3
  15. data/lib/new_relic/agent/instrumentation/rails/action_controller.rb +7 -1
  16. data/lib/new_relic/agent/instrumentation/sidekiq.rb +3 -1
  17. data/lib/new_relic/agent/instrumentation/sinatra.rb +3 -1
  18. data/lib/new_relic/agent/new_relic_service.rb +8 -0
  19. data/lib/new_relic/agent/request_sampler.rb +1 -1
  20. data/lib/new_relic/agent/sampler.rb +22 -2
  21. data/lib/new_relic/agent/sampler_collection.rb +13 -1
  22. data/lib/new_relic/agent/samplers/cpu_sampler.rb +3 -1
  23. data/lib/new_relic/agent/samplers/delayed_job_sampler.rb +2 -1
  24. data/lib/new_relic/agent/samplers/memory_sampler.rb +2 -1
  25. data/lib/new_relic/agent/samplers/object_sampler.rb +1 -3
  26. data/lib/new_relic/agent/samplers/vm_sampler.rb +126 -0
  27. data/lib/new_relic/agent/stats.rb +0 -15
  28. data/lib/new_relic/agent/stats_engine/gc_profiler.rb +66 -75
  29. data/lib/new_relic/agent/stats_engine/stats_hash.rb +1 -1
  30. data/lib/new_relic/agent/supported_versions.rb +2 -2
  31. data/lib/new_relic/agent/transaction.rb +6 -3
  32. data/lib/new_relic/agent/vm/monotonic_gc_profiler.rb +17 -5
  33. data/lib/new_relic/agent/vm/mri_vm.rb +2 -1
  34. data/lib/new_relic/agent/vm/snapshot.rb +5 -1
  35. data/lib/new_relic/control/instance_methods.rb +8 -5
  36. data/lib/new_relic/control/instrumentation.rb +0 -9
  37. data/lib/new_relic/environment_report.rb +1 -1
  38. data/lib/new_relic/language_support.rb +4 -0
  39. data/lib/new_relic/local_environment.rb +39 -14
  40. data/lib/new_relic/noticed_error.rb +7 -4
  41. data/lib/new_relic/rack/browser_monitoring.rb +16 -3
  42. data/lib/new_relic/version.rb +2 -2
  43. data/newrelic_rpm.gemspec +1 -1
  44. data/test/agent_helper.rb +5 -3
  45. data/test/environments/lib/environments/runner.rb +8 -7
  46. data/test/environments/norails/Gemfile +1 -1
  47. data/test/environments/rails21/Gemfile +1 -0
  48. data/test/environments/rails22/Gemfile +1 -0
  49. data/test/environments/rails23/Gemfile +1 -0
  50. data/test/environments/rails30/Gemfile +4 -1
  51. data/test/environments/rails31/Gemfile +4 -1
  52. data/test/environments/rails32/Gemfile +3 -4
  53. data/test/environments/rails40/Gemfile +1 -1
  54. data/test/environments/rails41/Gemfile +1 -1
  55. data/test/flaky_proxy/lib/flaky_proxy/proxy.rb +1 -0
  56. data/test/multiverse/lib/multiverse/output_collector.rb +3 -1
  57. data/test/multiverse/lib/multiverse/runner.rb +2 -10
  58. data/test/multiverse/lib/multiverse/suite.rb +100 -30
  59. data/test/multiverse/suites/activemerchant/Envfile +16 -0
  60. data/test/multiverse/suites/activemerchant/activemerchant_test.rb +65 -0
  61. data/test/multiverse/suites/agent_only/custom_queue_time_test.rb +57 -0
  62. data/test/multiverse/suites/config_file_loading/config_file_loading_test.rb +1 -1
  63. data/test/multiverse/suites/mongo/Envfile +9 -1
  64. data/test/multiverse/suites/rails/Envfile +2 -2
  65. data/test/multiverse/suites/rails/app.rb +3 -0
  66. data/test/multiverse/suites/rails/bad_instrumentation_test.rb +0 -2
  67. data/test/multiverse/suites/rails/error_tracing_test.rb +1 -2
  68. data/test/multiverse/suites/rails/gc_instrumentation_test.rb +17 -8
  69. data/test/multiverse/suites/rails/ignore_test.rb +0 -2
  70. data/test/multiverse/suites/rails/mongrel_queue_depth_test.rb +0 -2
  71. data/test/multiverse/suites/rails/queue_time_test.rb +40 -11
  72. data/test/multiverse/suites/rails/request_statistics_test.rb +0 -3
  73. data/test/multiverse/suites/rails/view_instrumentation_test.rb +0 -2
  74. data/test/multiverse/suites/sidekiq/Envfile +7 -2
  75. data/test/multiverse/suites/sinatra/Envfile +1 -1
  76. data/test/multiverse/suites/sinatra/nested_middleware_test.rb +41 -0
  77. data/test/multiverse/suites/sinatra/sinatra_metric_explosion_test.rb +1 -1
  78. data/test/new_relic/agent/agent/connect_test.rb +32 -4
  79. data/test/new_relic/agent/agent/start_test.rb +9 -1
  80. data/test/new_relic/agent/agent_logger_test.rb +23 -2
  81. data/test/new_relic/agent/agent_test.rb +49 -7
  82. data/test/new_relic/agent/configuration/manager_test.rb +8 -0
  83. data/test/new_relic/agent/configuration/orphan_configuration_test.rb +7 -0
  84. data/test/new_relic/agent/cross_app_monitor_test.rb +5 -6
  85. data/test/new_relic/agent/harvester_test.rb +13 -8
  86. data/test/new_relic/agent/instrumentation/action_controller_subscriber_test.rb +28 -7
  87. data/test/new_relic/agent/instrumentation/controller_instrumentation_test.rb +32 -21
  88. data/test/new_relic/agent/new_relic_service_test.rb +14 -0
  89. data/test/new_relic/agent/request_sampler_test.rb +5 -3
  90. data/test/new_relic/agent/rpm_agent_test.rb +2 -3
  91. data/test/new_relic/agent/sampler_collection_test.rb +15 -5
  92. data/test/new_relic/agent/sampler_test.rb +43 -0
  93. data/test/new_relic/agent/{cpu_sampler_test.rb → samplers/cpu_sampler_test.rb} +1 -1
  94. data/test/new_relic/agent/samplers/vm_sampler_test.rb +349 -0
  95. data/test/new_relic/agent/stats_engine/gc_profiler_test.rb +165 -44
  96. data/test/new_relic/agent/stats_hash_test.rb +1 -1
  97. data/test/new_relic/agent/transaction_test.rb +14 -0
  98. data/test/new_relic/agent/vm/monotonic_gc_profiler_test.rb +5 -5
  99. data/test/new_relic/agent/vm/mri_vm_test.rb +7 -0
  100. data/test/new_relic/agent/vm/snapshot_test.rb +5 -0
  101. data/test/new_relic/agent_test.rb +2 -2
  102. data/test/new_relic/control/instance_methods_test.rb +30 -0
  103. data/test/new_relic/control_test.rb +43 -21
  104. data/test/new_relic/dispatcher_test.rb +5 -0
  105. data/test/new_relic/local_environment_test.rb +3 -26
  106. data/test/new_relic/multiverse_helpers.rb +5 -0
  107. data/test/new_relic/noticed_error_test.rb +7 -0
  108. data/test/new_relic/rack/browser_monitoring_test.rb +13 -14
  109. data/test/test_helper.rb +2 -1
  110. metadata +56 -68
  111. metadata.gz.sig +1 -1
  112. data/lib/new_relic/agent/instrumentation/puma.rb +0 -25
  113. data/lib/new_relic/agent/instrumentation/unicorn_instrumentation.rb +0 -26
  114. data/test/multiverse/script/run_one +0 -5
  115. data/test/rum/basic.result.html +0 -10
  116. data/test/rum/basic.source.html +0 -10
  117. data/test/rum/comments1.result.html +0 -24
  118. data/test/rum/comments1.source.html +0 -24
  119. data/test/rum/comments2.result.html +0 -24
  120. data/test/rum/comments2.source.html +0 -24
  121. data/test/rum/gt_in_quotes1.result.html +0 -27
  122. data/test/rum/gt_in_quotes1.source.html +0 -27
  123. data/test/rum/gt_in_quotes2.result.html +0 -24
  124. data/test/rum/gt_in_quotes2.source.html +0 -24
  125. data/test/rum/gt_in_quotes_mismatch.result.html +0 -24
  126. data/test/rum/gt_in_quotes_mismatch.source.html +0 -24
  127. data/test/rum/gt_in_single_quotes1.result.html +0 -25
  128. data/test/rum/gt_in_single_quotes1.source.html +0 -25
  129. data/test/rum/gt_in_single_quotes_mismatch.result.html +0 -25
  130. data/test/rum/gt_in_single_quotes_mismatch.source.html +0 -25
  131. data/test/rum/incomplete_non_meta_tags.result.html +0 -10
  132. data/test/rum/incomplete_non_meta_tags.source.html +0 -10
  133. data/test/rum/no_body.result.html +0 -21
  134. data/test/rum/no_body.source.html +0 -21
  135. data/test/rum/no_header.result.html +0 -7
  136. data/test/rum/no_header.source.html +0 -7
  137. data/test/rum/no_html_and_no_header.result.html +0 -3
  138. data/test/rum/no_html_and_no_header.source.html +0 -3
  139. data/test/rum/no_start_header.result.html +0 -9
  140. data/test/rum/no_start_header.source.html +0 -9
  141. data/test/rum/script1.result.html +0 -19
  142. data/test/rum/script1.source.html +0 -19
  143. data/test/rum/script2.result.html +0 -17
  144. data/test/rum/script2.source.html +0 -17
  145. data/test/rum/x_ua_meta_tag.result.html +0 -10
  146. data/test/rum/x_ua_meta_tag.source.html +0 -10
  147. data/test/rum/x_ua_meta_tag_multiline.result.html +0 -11
  148. data/test/rum/x_ua_meta_tag_multiline.source.html +0 -11
  149. data/test/rum/x_ua_meta_tag_spaces_around_equals.result.html +0 -10
  150. data/test/rum/x_ua_meta_tag_spaces_around_equals.source.html +0 -10
  151. data/test/rum/x_ua_meta_tag_with_others.result.html +0 -11
  152. data/test/rum/x_ua_meta_tag_with_others.source.html +0 -11
  153. data/test/rum/x_ua_meta_tag_with_spaces.result.html +0 -10
  154. data/test/rum/x_ua_meta_tag_with_spaces.source.html +0 -10
data.tar.gz.sig CHANGED
Binary file
data/CHANGELOG CHANGED
@@ -1,5 +1,78 @@
1
1
  # New Relic Ruby Agent Release Notes #
2
2
 
3
+ ## v3.8.0 ##
4
+
5
+ * Better support for forking and daemonizing dispatchers (e.g. Puma, Unicorn)
6
+
7
+ The agent should now work out-of-the box with no special configuration on
8
+ servers that fork or daemonize themselves (such as Unicorn or Puma in some
9
+ configurations). The agent's background thread will be automatically restarted
10
+ after the first transaction processed within each child process.
11
+
12
+ This change means it's no longer necessary to set the
13
+ 'restart_thread_in_children setting' in your agent configuration file if you
14
+ were doing so previously.
15
+
16
+ * Rails 4.1 support
17
+
18
+ Rails 4.1 has shipped, and the Ruby agent is ready for it! We've been running
19
+ our test suites against the release candidates with no significant issues, so
20
+ we're happy to announce full compatibility with this new release of Rails.
21
+
22
+ * Ruby VM measurements
23
+
24
+ The Ruby agent now records more detailed information about the performance and
25
+ behavior of the Ruby VM, mainly focused around Ruby's garbage collector. This
26
+ information is exposed on the new 'Ruby VM' tab in the UI. For details about
27
+ what is recorded, see:
28
+
29
+ http://docs.newrelic.com/docs/ruby/ruby-vm-stats
30
+
31
+ * Separate in-transaction GC timings for web and background processes
32
+
33
+ Previously, an application with GC instrumentation enabled, and both web and
34
+ background processes reporting in to it would show an overly inflated GC band
35
+ on the application overview graph, because data from both web and non-web
36
+ transactions would be included. This has been fixed, and GC time during web
37
+ and non-web transactions is now tracked separately.
38
+
39
+ * More accurate GC measurements on multi-threaded web servers
40
+
41
+ The agent could previously have reported inaccurate GC times on multi-threaded
42
+ web servers such as Puma. It will now correctly report GC timings in
43
+ multi-threaded contexts.
44
+
45
+ * Improved ActiveMerchant instrumentation
46
+
47
+ The agent will now trace the store, unstore, and update methods on
48
+ ActiveMerchant gateways. In addition, a bug preventing ActiveMerchant
49
+ instrumentation from working on Ruby 1.9+ has been fixed.
50
+
51
+ Thanks to Troex Nevelin for the contribution!
52
+
53
+ * More robust Real User Monitoring script injection with charset meta tags
54
+
55
+ Previous versions of the agent with Real User Monitoring enabled could have
56
+ injected JavaScript code into the page above a charset meta tag. By the HTML5
57
+ spec, the charset tag must appear in the first 1024 bytes of the page, so the
58
+ Ruby agent will now attempt to inject RUM script after a charset tag, if one
59
+ is present.
60
+
61
+ * More robust connection sequence with New Relic servers
62
+
63
+ A rare bug that could cause the agent's initial connection handshake with
64
+ New Relic servers to silently fail has been fixed, and better logging has been
65
+ added to the related code path to ease diagnosis of any future issues.
66
+
67
+ * Prevent over-counting of queue time with nested transactions
68
+
69
+ When using add_transaction_tracer on methods called from within a Rails or
70
+ Sinatra action, it was previously possible to get inflated queue time
71
+ measurements, because queue time would be recorded for both the outer
72
+ transaction (the Rails or Sinatra action) and the inner transaction (the
73
+ method given to add_transaction_tracer). This has been fixed, so only the
74
+ outermost transaction will now record queue time.
75
+
3
76
  ## v3.7.3 ##
4
77
 
5
78
  * Obfuscation for PostgreSQL explain plans
data/README.md CHANGED
@@ -21,7 +21,7 @@ automatically in Rails applications.
21
21
 
22
22
  ## Supported Environments
23
23
 
24
- * Ruby 1.8.7, REE, 1.9.x, 2.0.x
24
+ * Ruby 1.8.7, REE, 1.9.x, 2.0.x, 2.1.x
25
25
  * JRuby 1.6 and 1.7
26
26
  * Rubinius 2.x (Experimental support only)
27
27
  * Rails 2.1 or later for Production Mode
data/Rakefile CHANGED
@@ -23,11 +23,7 @@ namespace :test do
23
23
  task :multiverse, [:suite, :param1, :param2, :param3, :param4] => [] do |t, args|
24
24
  require File.expand_path(File.join(File.dirname(__FILE__), 'test', 'multiverse', 'lib', 'multiverse', 'environment'))
25
25
  opts = Multiverse::Runner.parse_args(args)
26
- if opts.key?(:run_one)
27
- Multiverse::Runner.run_one(args.suite, opts)
28
- else
29
- Multiverse::Runner.run(args.suite, opts)
30
- end
26
+ Multiverse::Runner.run(args.suite, opts)
31
27
  end
32
28
 
33
29
  desc "Test the multiverse testing framework by executing tests in test/multiverse/test. Get meta with it."
@@ -113,6 +113,7 @@ module NewRelic
113
113
  require 'new_relic/agent/samplers/memory_sampler'
114
114
  require 'new_relic/agent/samplers/object_sampler'
115
115
  require 'new_relic/agent/samplers/delayed_job_sampler'
116
+ require 'new_relic/agent/samplers/vm_sampler'
116
117
  require 'set'
117
118
  require 'thread'
118
119
  require 'resolv'
@@ -106,6 +106,8 @@ module NewRelic
106
106
  # collector on connect. The former are applied during txns,
107
107
  # the latter during harvest.
108
108
  attr_reader :transaction_rules
109
+ # Responsbile for restarting the harvest thread
110
+ attr_reader :harvester
109
111
  attr_reader :harvest_lock
110
112
  # GC::Profiler.total_time is not monotonic so we wrap it.
111
113
  attr_reader :monotonic_gc_profiler
@@ -166,6 +168,8 @@ module NewRelic
166
168
  # connection, this tells me to only try it once so this method returns
167
169
  # quickly if there is some kind of latency with the server.
168
170
  def after_fork(options={})
171
+ # Mark started early because if we've explicitly called after_fork,
172
+ # we should be ready to run and shouldn't restarting if we can't.
169
173
  @harvester.mark_started
170
174
 
171
175
  Agent.config.apply_config(NewRelic::Agent::Configuration::ManualSource.new(options), 1)
@@ -173,9 +177,9 @@ module NewRelic
173
177
  if channel_id = options[:report_to_channel]
174
178
  @service = NewRelic::Agent::PipeService.new(channel_id)
175
179
  if connected?
176
- @connected_pid = $$
180
+ @connected_pid = Process.pid
177
181
  else
178
- ::NewRelic::Agent.logger.debug("Child process #{$$} not reporting to non-connected parent.")
182
+ ::NewRelic::Agent.logger.debug("Child process #{Process.pid} not reporting to non-connected parent (process #{Process.ppid}).")
179
183
  @service.shutdown(Time.now)
180
184
  disconnect
181
185
  end
@@ -188,13 +192,11 @@ module NewRelic
188
192
 
189
193
  ::NewRelic::Agent.logger.debug "Starting the worker thread in #{$$} after forking."
190
194
 
195
+ # Clear out locks and stats left over from parent process
191
196
  reset_objects_with_locks
192
-
193
- # Clear out stats that are left over from parent process
194
197
  drop_buffered_data
195
198
 
196
- generate_environment_report unless @service.is_a?(NewRelic::Agent::PipeService)
197
- start_worker_thread(options)
199
+ setup_and_start_agent(options)
198
200
  end
199
201
 
200
202
  # True if we have initialized and completed 'start'
@@ -462,16 +464,35 @@ module NewRelic
462
464
  !NewRelic::Agent::PipeChannelManager.listener.started?
463
465
  end
464
466
 
467
+ def in_resque_child_process?
468
+ @service.is_a?(NewRelic::Agent::PipeService)
469
+ end
470
+
465
471
  # Sanity-check the agent configuration and start the agent,
466
472
  # setting up the worker thread and the exit handler to shut
467
473
  # down the agent
468
474
  def check_config_and_start_agent
469
475
  return unless monitoring? && has_correct_license_key?
470
476
  return if using_forking_dispatcher?
471
- generate_environment_report
477
+ setup_and_start_agent
478
+ end
479
+
480
+ # This is the shared method between the main agent startup and the
481
+ # after_fork call restarting the thread in deferred dispatchers.
482
+ #
483
+ # Treatment of @started and env report is important to get right.
484
+ def setup_and_start_agent(options={})
485
+ @started = true
486
+ @harvester.mark_started
487
+
488
+ unless in_resque_child_process?
489
+ generate_environment_report
490
+ install_exit_handler
491
+ @harvest_samplers.load_samplers unless Agent.config[:disable_samplers]
492
+ end
493
+
472
494
  connect_in_foreground if Agent.config[:sync_startup]
473
- start_worker_thread
474
- install_exit_handler
495
+ start_worker_thread(options)
475
496
  end
476
497
  end
477
498
 
@@ -512,8 +533,6 @@ module NewRelic
512
533
  def start
513
534
  return unless agent_should_start?
514
535
 
515
- @started = true
516
- @local_host = determine_host
517
536
  log_startup
518
537
  check_config_and_start_agent
519
538
  log_version_and_pid
@@ -541,10 +560,6 @@ module NewRelic
541
560
  reset_harvest_locks
542
561
  end
543
562
 
544
- def add_harvest_sampler(subclass)
545
- @harvest_samplers.add_sampler(subclass)
546
- end
547
-
548
563
  private
549
564
 
550
565
  # All of this module used to be contained in the
@@ -763,12 +778,22 @@ module NewRelic
763
778
  Agent.config[:send_environment_info] ? Array(EnvironmentReport.new) : []
764
779
  end
765
780
 
781
+ # We've seen objects in the environment report (Rails.env in
782
+ # particular) that can't seralize to JSON. Cope with that here and
783
+ # clear out so downstream code doesn't have to check again.
784
+ def sanitize_environment_report
785
+ if !@service.valid_to_marshal?(@environment_report)
786
+ @environment_report = []
787
+ end
788
+ end
789
+
766
790
  # Initializes the hash of settings that we send to the
767
791
  # server. Returns a literal hash containing the options
768
792
  def connect_settings
793
+ sanitize_environment_report
769
794
  {
770
795
  :pid => $$,
771
- :host => @local_host,
796
+ :host => local_host,
772
797
  :app_name => Agent.config.app_names,
773
798
  :language => 'ruby',
774
799
  :agent_version => NewRelic::VERSION::STRING,
@@ -811,7 +836,7 @@ module NewRelic
811
836
 
812
837
  ::NewRelic::Agent.logger.debug "Server provided config: #{config_data.inspect}"
813
838
  server_config = NewRelic::Agent::Configuration::ServerSource.new(config_data, Agent.config)
814
- Agent.config.apply_config(server_config, 1)
839
+ Agent.config.replace_or_add_config(server_config, 1)
815
840
  log_connection!(config_data) if @service
816
841
 
817
842
  @transaction_rules = RulesEngine.from_specs(config_data['transaction_name_rules'])
@@ -912,6 +937,10 @@ module NewRelic
912
937
  Socket.gethostname
913
938
  end
914
939
 
940
+ def local_host
941
+ @local_host ||= determine_host
942
+ end
943
+
915
944
  # Delegates to the control class to determine the root
916
945
  # directory of this project
917
946
  def determine_home_directory
@@ -934,7 +963,7 @@ module NewRelic
934
963
  # #merge!(items)
935
964
  # merge the given items back into the internal buffer of the
936
965
  # container, so that they may be harvested again later.
937
- #
966
+ #
938
967
  def harvest_and_send_from_container(container, endpoint)
939
968
  items = harvest_from_container(container, endpoint)
940
969
  send_data_to_endpoint(endpoint, items, container) unless items.empty?
@@ -54,7 +54,7 @@ module NewRelic
54
54
  def log_exception(level, e, backtrace_level=level)
55
55
  @log.send(level, "%p: %s" % [ e.class, e.message ])
56
56
  @log.send(backtrace_level) do
57
- backtrace = e.backtrace
57
+ backtrace = backtrace_from_exception(e)
58
58
  if backtrace
59
59
  "Debugging backtrace:\n" + backtrace.join("\n ")
60
60
  else
@@ -63,6 +63,16 @@ module NewRelic
63
63
  end
64
64
  end
65
65
 
66
+ def backtrace_from_exception(e)
67
+ # We've seen that often the backtrace on a SystemStackError is bunk
68
+ # so massage the caller instead at a known depth.
69
+ #
70
+ # Tests keep us honest about minmum method depth our log calls add.
71
+ return caller.drop(5) if e.is_a?(SystemStackError)
72
+
73
+ e.backtrace
74
+ end
75
+
66
76
  # Allows for passing exceptions in explicitly, which format with backtrace
67
77
  def format_and_send(level, *msgs)
68
78
  msgs.flatten.each do |item|
@@ -902,7 +902,7 @@ module NewRelic
902
902
  :description => 'Include custom attributes in analytics event data.'
903
903
  },
904
904
  :restart_thread_in_children => {
905
- :default => false,
905
+ :default => true,
906
906
  :public => false,
907
907
  :type => Boolean,
908
908
  :description => 'Controls whether to check on running a transaction whether to respawn the harvest thread.'
@@ -912,6 +912,90 @@ module NewRelic
912
912
  :public => false,
913
913
  :type => Boolean,
914
914
  :description => 'Controls whether to normalize string encodings prior to serializing data for the collector to JSON.'
915
+ },
916
+ :disable_vm_sampler => {
917
+ :default => false,
918
+ :public => true,
919
+ :type => Boolean,
920
+ :dynamic_name => true,
921
+ :description => 'Controls whether the Ruby VM sampler is enabled. This sampler periodically gathers performance measurements from the Ruby VM.'
922
+ },
923
+ :disable_memory_sampler => {
924
+ :default => false,
925
+ :public => true,
926
+ :type => Boolean,
927
+ :dynamic_name => true,
928
+ :description => 'Controls whether the memory sampler is enabled. This sampler periodically measures the memory usage of the host process.'
929
+ },
930
+ :disable_cpu_sampler => {
931
+ :default => false,
932
+ :public => true,
933
+ :type => Boolean,
934
+ :dynamic_name => true,
935
+ :description => 'Controls whether the CPU sampler is enabled. This sampler periodically samples the CPU usage of the host process.'
936
+ },
937
+ :disable_delayed_job_sampler => {
938
+ :default => false,
939
+ :public => true,
940
+ :type => Boolean,
941
+ :dynamic_name => true,
942
+ :description => 'Controls whether the Delayed Job sampler is enabled. This sampler periodically measures the depth of Delayed Job queues.'
943
+ },
944
+ :disable_active_record_4 => {
945
+ :default => false,
946
+ :public => true,
947
+ :type => Boolean,
948
+ :dynamic_name => true,
949
+ :description => 'Controls whether instrumentation for ActiveRecord 4 will be installed by the agent.'
950
+ },
951
+ :disable_curb => {
952
+ :default => false,
953
+ :public => true,
954
+ :type => Boolean,
955
+ :dynamic_name => true,
956
+ :description => 'Controls whether instrumentation for the curb gem will be installed by the agent.'
957
+ },
958
+ :disable_excon => {
959
+ :default => false,
960
+ :public => true,
961
+ :type => Boolean,
962
+ :dynamic_name => true,
963
+ :description => 'Controls whether instrumentation for the excon gem will be installed by the agent.'
964
+ },
965
+ :disable_httpclient => {
966
+ :default => false,
967
+ :public => true,
968
+ :type => Boolean,
969
+ :dynamic_name => true,
970
+ :description => 'Controls whether instrumentation for the httpclient gem will be installed by the agent.'
971
+ },
972
+ :disable_mongo => {
973
+ :default => false,
974
+ :public => true,
975
+ :type => Boolean,
976
+ :dynamic_name => true,
977
+ :description => 'Controls whether instrumentation for the mongo gem will be installed by the agent.'
978
+ },
979
+ :disable_rack => {
980
+ :default => false,
981
+ :public => true,
982
+ :type => Boolean,
983
+ :dynamic_name => true,
984
+ :description => "Controls whether the agent will hook into Rack::Builder's to_app method in order to look for gems to instrument during application startup."
985
+ },
986
+ :disable_rubyprof => {
987
+ :default => false,
988
+ :public => true,
989
+ :type => Boolean,
990
+ :dynamic_name => true,
991
+ :description => 'Controls whether the agent will make use of RubyProf in developer mode if it is present.'
992
+ },
993
+ :disable_typhoeus => {
994
+ :default => false,
995
+ :public => true,
996
+ :type => Boolean,
997
+ :dynamic_name => true,
998
+ :description => 'Controls whether instrumentation for the typhoeus gem will be installed by the agent.'
915
999
  }
916
1000
  }.freeze
917
1001
 
@@ -53,11 +53,15 @@ module NewRelic
53
53
  end
54
54
 
55
55
  def replace_or_add_config(source, level=0)
56
- index = @config_stack.map{|s| s.class}.index(source.class)
56
+ index = config_stack_index_for(source.class)
57
57
  @config_stack.delete_at(index) if index
58
58
  apply_config(source, index || level)
59
59
  end
60
60
 
61
+ def config_stack_index_for(source_class)
62
+ @config_stack.map{|s| s.class}.index(source_class)
63
+ end
64
+
61
65
  def source(key)
62
66
  @config_stack.each do |config|
63
67
  if config.respond_to?(key.to_sym) || config.has_key?(key.to_sym)
@@ -6,16 +6,21 @@ module NewRelic
6
6
  module Agent
7
7
  module Datastores
8
8
  module Mongo
9
-
10
9
  def self.is_supported_version?
11
10
  # No version constant in < 2.0 versions of Mongo :(
12
11
  defined?(::Mongo) &&
13
12
  defined?(::Mongo::MongoClient) &&
14
- !is_version2
13
+ !is_version2? &&
14
+ !is_version_1_10_or_later?
15
+ end
16
+
17
+ def self.is_version_1_10_or_later?
18
+ # Again, no VERSION constant in 1.x, so we have to rely on constant checks
19
+ defined?(::Mongo::CollectionOperationWriter)
15
20
  end
16
21
 
17
22
  # At present we explicitly don't support version 2.x of the driver yet
18
- def self.is_version2
23
+ def self.is_version2?
19
24
  defined?(::Mongo::VERSION) &&
20
25
  NewRelic::VersionNumber.new(::Mongo::VERSION) > NewRelic::VersionNumber.new("2.0.0")
21
26
  end
@@ -5,11 +5,15 @@
5
5
  module NewRelic
6
6
  module Agent
7
7
  class Harvester
8
+
8
9
  attr_accessor :starting_pid
9
10
 
10
11
  # Inject target for after_fork call to avoid spawning thread in tests
11
12
  def initialize(events, after_forker=NewRelic::Agent)
12
- @starting_pid = Process.pid
13
+ # We intentionally don't set our pid as started at this point.
14
+ # Startup routines must call mark_started when they consider us set!
15
+ @starting_pid = nil
16
+
13
17
  @after_forker = after_forker
14
18
  @lock = Mutex.new
15
19