newrelic_rpm 3.6.6.147 → 3.6.7.152

Sign up to get free protection for your applications and to get access to all the features.
Files changed (265) hide show
  1. data.tar.gz.sig +0 -0
  2. data/.gitignore +0 -1
  3. data/CHANGELOG +55 -17
  4. data/Guardfile +7 -0
  5. data/Rakefile +6 -0
  6. data/bin/mongrel_rpm +33 -0
  7. data/bin/newrelic +13 -0
  8. data/bin/newrelic_cmd +5 -0
  9. data/bin/nrdebug +273 -0
  10. data/install.rb +3 -3
  11. data/lib/new_relic/agent.rb +4 -6
  12. data/lib/new_relic/agent/agent.rb +76 -72
  13. data/lib/new_relic/agent/autostart.rb +18 -5
  14. data/lib/new_relic/agent/browser_monitoring.rb +41 -35
  15. data/lib/new_relic/agent/browser_token.rb +38 -0
  16. data/lib/new_relic/agent/busy_calculator.rb +7 -5
  17. data/lib/new_relic/agent/commands/agent_command.rb +19 -0
  18. data/lib/new_relic/agent/commands/agent_command_router.rb +88 -0
  19. data/lib/new_relic/agent/commands/thread_profiler.rb +80 -0
  20. data/lib/new_relic/agent/configuration/default_source.rb +700 -0
  21. data/lib/new_relic/agent/configuration/environment_source.rb +83 -30
  22. data/lib/new_relic/agent/configuration/manager.rb +8 -8
  23. data/lib/new_relic/agent/configuration/mask_defaults.rb +2 -2
  24. data/lib/new_relic/agent/cross_app_monitor.rb +10 -21
  25. data/lib/new_relic/agent/cross_app_tracing.rb +3 -3
  26. data/lib/new_relic/agent/error_collector.rb +7 -10
  27. data/lib/new_relic/agent/http_clients/curb_wrappers.rb +1 -1
  28. data/lib/new_relic/agent/http_clients/excon_wrappers.rb +5 -1
  29. data/lib/new_relic/agent/http_clients/httpclient_wrappers.rb +5 -1
  30. data/lib/new_relic/agent/http_clients/net_http_wrappers.rb +5 -1
  31. data/lib/new_relic/agent/http_clients/typhoeus_wrappers.rb +1 -1
  32. data/lib/new_relic/agent/instrumentation/action_controller_subscriber.rb +5 -12
  33. data/lib/new_relic/agent/instrumentation/action_view_subscriber.rb +4 -0
  34. data/lib/new_relic/agent/instrumentation/{rails4/active_record.rb → active_record_4.rb} +1 -1
  35. data/lib/new_relic/agent/instrumentation/active_record_subscriber.rb +11 -11
  36. data/lib/new_relic/agent/instrumentation/authlogic.rb +8 -6
  37. data/lib/new_relic/agent/instrumentation/controller_instrumentation.rb +12 -6
  38. data/lib/new_relic/agent/instrumentation/curb.rb +11 -2
  39. data/lib/new_relic/agent/instrumentation/delayed_job_instrumentation.rb +1 -3
  40. data/lib/new_relic/agent/instrumentation/evented_subscriber.rb +11 -2
  41. data/lib/new_relic/agent/instrumentation/excon/middleware.rb +13 -4
  42. data/lib/new_relic/agent/instrumentation/puma.rb +2 -1
  43. data/lib/new_relic/agent/instrumentation/rack.rb +15 -17
  44. data/lib/new_relic/agent/method_tracer.rb +181 -191
  45. data/lib/new_relic/agent/new_relic_service.rb +16 -14
  46. data/lib/new_relic/agent/pipe_channel_manager.rb +1 -1
  47. data/lib/new_relic/agent/request_sampler.rb +32 -165
  48. data/lib/new_relic/agent/sampled_buffer.rb +79 -0
  49. data/lib/new_relic/agent/samplers/delayed_job_sampler.rb +1 -8
  50. data/lib/new_relic/agent/sql_sampler.rb +3 -3
  51. data/lib/new_relic/agent/stats_engine.rb +1 -1
  52. data/lib/new_relic/agent/stats_engine/gc_profiler.rb +1 -1
  53. data/lib/new_relic/agent/stats_engine/metric_stats.rb +2 -3
  54. data/lib/new_relic/agent/stats_engine/transactions.rb +2 -22
  55. data/lib/new_relic/agent/threading/agent_thread.rb +41 -0
  56. data/lib/new_relic/agent/threading/backtrace_node.rb +71 -0
  57. data/lib/new_relic/agent/threading/thread_profile.rb +172 -0
  58. data/lib/new_relic/agent/transaction.rb +16 -4
  59. data/lib/new_relic/agent/transaction_sample_builder.rb +13 -3
  60. data/lib/new_relic/agent/transaction_sampler.rb +5 -8
  61. data/lib/new_relic/agent/transaction_state.rb +166 -0
  62. data/lib/new_relic/agent/transaction_timings.rb +53 -0
  63. data/lib/new_relic/cli/command.rb +91 -0
  64. data/lib/new_relic/{commands → cli}/deployments.rb +13 -9
  65. data/lib/new_relic/{commands → cli}/install.rb +2 -2
  66. data/lib/new_relic/control/frameworks/rails.rb +1 -8
  67. data/lib/new_relic/control/instance_methods.rb +1 -2
  68. data/lib/new_relic/helper.rb +9 -0
  69. data/lib/new_relic/local_environment.rb +16 -63
  70. data/lib/new_relic/rack/browser_monitoring.rb +8 -5
  71. data/lib/new_relic/recipes.rb +44 -31
  72. data/lib/new_relic/transaction_sample.rb +6 -2
  73. data/lib/new_relic/version.rb +1 -1
  74. data/lib/tasks/install.rake +21 -1
  75. data/newrelic_rpm.gemspec +5 -1
  76. data/test/agent_helper.rb +4 -9
  77. data/test/environments/.gitignore +16 -0
  78. data/test/environments/lib/environments/runner.rb +104 -0
  79. data/test/environments/norails/Gemfile +11 -0
  80. data/test/environments/norails/Rakefile +9 -0
  81. data/test/environments/rails21/Gemfile +24 -0
  82. data/test/environments/rails21/Rakefile +12 -0
  83. data/test/environments/rails21/app/controllers/application.rb +20 -0
  84. data/test/environments/rails21/config/boot.rb +113 -0
  85. data/test/environments/rails21/config/database.yml +31 -0
  86. data/test/environments/rails21/config/environment.rb +28 -0
  87. data/test/environments/rails21/config/environments/development.rb +16 -0
  88. data/test/environments/rails21/config/environments/production.rb +8 -0
  89. data/test/environments/rails21/config/environments/test.rb +10 -0
  90. data/test/environments/rails21/config/routes.rb +5 -0
  91. data/test/environments/rails21/db/schema.rb +5 -0
  92. data/test/environments/rails22/Gemfile +29 -0
  93. data/test/environments/rails22/Rakefile +12 -0
  94. data/test/environments/rails22/app/controllers/application.rb +20 -0
  95. data/test/environments/rails22/config/boot.rb +113 -0
  96. data/test/environments/rails22/config/database.yml +31 -0
  97. data/test/environments/rails22/config/environment.rb +27 -0
  98. data/test/environments/rails22/config/environments/development.rb +16 -0
  99. data/test/environments/rails22/config/environments/production.rb +8 -0
  100. data/test/environments/rails22/config/environments/test.rb +10 -0
  101. data/test/environments/rails22/config/routes.rb +5 -0
  102. data/test/environments/rails22/db/schema.rb +5 -0
  103. data/test/environments/rails23/Gemfile +22 -0
  104. data/test/environments/rails23/Rakefile +12 -0
  105. data/test/environments/rails23/app/controllers/application.rb +20 -0
  106. data/test/environments/rails23/config/boot.rb +127 -0
  107. data/test/environments/rails23/config/database.yml +31 -0
  108. data/test/environments/rails23/config/environment.rb +25 -0
  109. data/test/environments/rails23/config/environments/development.rb +16 -0
  110. data/test/environments/rails23/config/environments/production.rb +8 -0
  111. data/test/environments/rails23/config/environments/test.rb +10 -0
  112. data/test/environments/rails23/config/preinitializer.rb +25 -0
  113. data/test/environments/rails23/config/routes.rb +5 -0
  114. data/test/environments/rails23/db/schema.rb +5 -0
  115. data/test/environments/rails30/Gemfile +19 -0
  116. data/test/environments/rails30/Rakefile +9 -0
  117. data/test/environments/rails30/config/application.rb +17 -0
  118. data/test/environments/rails30/config/boot.rb +10 -0
  119. data/test/environments/rails30/config/database.yml +31 -0
  120. data/test/environments/rails30/config/environment.rb +6 -0
  121. data/test/environments/rails30/config/initializers/new_rails_defaults.rb +11 -0
  122. data/test/environments/rails30/db/schema.rb +5 -0
  123. data/test/environments/rails31/Gemfile +19 -0
  124. data/test/environments/rails31/Rakefile +9 -0
  125. data/test/environments/rails31/config/application.rb +18 -0
  126. data/test/environments/rails31/config/boot.rb +10 -0
  127. data/test/environments/rails31/config/database.yml +31 -0
  128. data/test/environments/rails31/config/environment.rb +6 -0
  129. data/test/environments/rails31/config/initializers/new_rails_defaults.rb +21 -0
  130. data/test/environments/rails31/db/schema.rb +5 -0
  131. data/test/environments/rails32/Gemfile +25 -0
  132. data/test/environments/rails32/Rakefile +9 -0
  133. data/test/environments/rails32/config/application.rb +19 -0
  134. data/test/environments/rails32/config/boot.rb +10 -0
  135. data/test/environments/rails32/config/database.yml +31 -0
  136. data/test/environments/rails32/config/environment.rb +6 -0
  137. data/test/environments/rails32/db/schema.rb +5 -0
  138. data/test/environments/rails40/Gemfile +25 -0
  139. data/test/environments/rails40/Rakefile +9 -0
  140. data/test/environments/rails40/config/application.rb +18 -0
  141. data/test/environments/rails40/config/boot.rb +10 -0
  142. data/test/environments/rails40/config/database.yml +31 -0
  143. data/test/environments/rails40/config/environment.rb +6 -0
  144. data/test/environments/rails40/db/schema.rb +5 -0
  145. data/test/multiverse/lib/multiverse/suite.rb +24 -12
  146. data/test/multiverse/suites/agent_only/logging_test.rb +18 -1
  147. data/test/multiverse/suites/agent_only/rum_instrumentation_test.rb +1 -8
  148. data/test/multiverse/suites/agent_only/thread_profiling_test.rb +10 -7
  149. data/test/multiverse/suites/curb/curb_test.rb +17 -3
  150. data/test/multiverse/suites/excon/Envfile +1 -1
  151. data/test/multiverse/suites/excon/excon_test.rb +18 -2
  152. data/test/multiverse/suites/httpclient/httpclient_test.rb +2 -2
  153. data/test/multiverse/suites/net_http/net_http_test.rb +2 -2
  154. data/test/multiverse/suites/rails/error_tracing_test.rb +35 -8
  155. data/test/multiverse/suites/rails/ignore_test.rb +48 -0
  156. data/test/multiverse/suites/rails/mongrel_queue_depth_test.rb +44 -0
  157. data/test/multiverse/suites/sequel/sequel_test.rb +11 -0
  158. data/test/multiverse/suites/sinatra/ignoring_test.rb +2 -2
  159. data/test/multiverse/suites/typhoeus/Envfile +9 -2
  160. data/test/multiverse/suites/typhoeus/typhoeus_test.rb +3 -2
  161. data/test/new_relic/agent/agent/start_test.rb +3 -22
  162. data/test/new_relic/agent/agent_test.rb +6 -5
  163. data/test/new_relic/agent/autostart_test.rb +39 -1
  164. data/test/new_relic/agent/browser_monitoring_test.rb +43 -88
  165. data/test/new_relic/agent/browser_token_test.rb +52 -0
  166. data/test/new_relic/agent/busy_calculator_test.rb +1 -1
  167. data/test/new_relic/agent/commands/agent_command_router_test.rb +98 -0
  168. data/test/new_relic/agent/commands/agent_command_test.rb +37 -0
  169. data/test/new_relic/agent/commands/thread_profiler_test.rb +177 -0
  170. data/test/new_relic/agent/configuration/default_source_test.rb +81 -0
  171. data/test/new_relic/agent/configuration/environment_source_test.rb +81 -7
  172. data/test/new_relic/agent/configuration/manager_test.rb +16 -1
  173. data/test/new_relic/agent/cross_app_monitor_test.rb +3 -5
  174. data/test/new_relic/agent/error_collector_test.rb +14 -0
  175. data/test/new_relic/agent/instrumentation/action_controller_subscriber_test.rb +1 -1
  176. data/test/new_relic/agent/instrumentation/active_record_instrumentation_test.rb +2 -3
  177. data/test/new_relic/agent/instrumentation/active_record_subscriber_test.rb +29 -31
  178. data/test/new_relic/agent/instrumentation/controller_instrumentation_test.rb +22 -0
  179. data/test/new_relic/agent/method_tracer/instance_methods/trace_execution_scoped_test.rb +2 -2
  180. data/test/new_relic/agent/method_tracer_test.rb +2 -2
  181. data/test/new_relic/agent/new_relic_service_test.rb +5 -49
  182. data/test/new_relic/agent/pipe_channel_manager_test.rb +1 -0
  183. data/test/new_relic/agent/request_sampler_test.rb +32 -95
  184. data/test/new_relic/agent/rpm_agent_test.rb +7 -5
  185. data/test/new_relic/agent/sampled_buffer_test.rb +178 -0
  186. data/test/new_relic/agent/stats_engine/metric_stats_test.rb +0 -1
  187. data/test/new_relic/agent/stats_engine_test.rb +10 -17
  188. data/test/new_relic/agent/threading/agent_thread_test.rb +107 -0
  189. data/test/new_relic/agent/threading/backtrace_node_test.rb +96 -0
  190. data/test/new_relic/agent/{threaded_test.rb → threading/fake_thread.rb} +0 -25
  191. data/test/new_relic/agent/threading/thread_profile_test.rb +308 -0
  192. data/test/new_relic/agent/threading/threaded_test_case.rb +33 -0
  193. data/test/new_relic/agent/transaction/pop_test.rb +0 -16
  194. data/test/new_relic/agent/transaction_sample_builder_test.rb +23 -4
  195. data/test/new_relic/agent/transaction_sampler_test.rb +14 -15
  196. data/test/new_relic/agent/transaction_state_test.rb +75 -0
  197. data/test/new_relic/agent/transaction_test.rb +15 -0
  198. data/test/new_relic/agent/transaction_timings_test.rb +81 -0
  199. data/test/new_relic/agent_test.rb +12 -14
  200. data/test/new_relic/{command → cli}/deployments_test.rb +41 -13
  201. data/test/new_relic/control/frameworks/rails_test.rb +1 -2
  202. data/test/new_relic/control_test.rb +1 -2
  203. data/test/new_relic/dependency_detection_test.rb +14 -0
  204. data/test/new_relic/fake_collector.rb +1 -0
  205. data/test/new_relic/helper_test.rb +7 -2
  206. data/test/new_relic/http_client_test_cases.rb +33 -1
  207. data/test/new_relic/local_environment_test.rb +0 -23
  208. data/test/new_relic/metric_data_test.rb +4 -0
  209. data/test/new_relic/rack/browser_monitoring_test.rb +31 -30
  210. data/test/performance/lib/performance/result.rb +15 -4
  211. data/test/performance/lib/performance/timer.rb +7 -1
  212. data/test/performance/script/baselines +102 -0
  213. data/test/performance/suites/rum_autoinsertion.rb +57 -0
  214. data/test/rum/basic.result.html +10 -0
  215. data/test/rum/basic.source.html +10 -0
  216. data/test/rum/comments1.result.html +24 -0
  217. data/test/rum/comments1.source.html +24 -0
  218. data/test/rum/comments2.result.html +24 -0
  219. data/test/rum/comments2.source.html +24 -0
  220. data/test/rum/gt_in_quotes1.result.html +27 -0
  221. data/test/rum/gt_in_quotes1.source.html +27 -0
  222. data/test/rum/gt_in_quotes2.result.html +24 -0
  223. data/test/rum/gt_in_quotes2.source.html +24 -0
  224. data/test/rum/gt_in_quotes_mismatch.result.html +24 -0
  225. data/test/rum/gt_in_quotes_mismatch.source.html +24 -0
  226. data/test/rum/gt_in_single_quotes1.result.html +25 -0
  227. data/test/rum/gt_in_single_quotes1.source.html +25 -0
  228. data/test/rum/gt_in_single_quotes_mismatch.result.html +25 -0
  229. data/test/rum/gt_in_single_quotes_mismatch.source.html +25 -0
  230. data/test/rum/incomplete_non_meta_tags.result.html +10 -0
  231. data/test/rum/incomplete_non_meta_tags.source.html +10 -0
  232. data/test/rum/no_body.result.html +21 -0
  233. data/test/rum/no_body.source.html +21 -0
  234. data/test/rum/no_header.result.html +7 -0
  235. data/test/rum/no_header.source.html +7 -0
  236. data/test/rum/no_start_header.result.html +9 -0
  237. data/test/rum/no_start_header.source.html +9 -0
  238. data/test/rum/script1.result.html +19 -0
  239. data/test/rum/script1.source.html +19 -0
  240. data/test/rum/script2.result.html +17 -0
  241. data/test/rum/script2.source.html +17 -0
  242. data/test/rum/x_ua_meta_tag.result.html +10 -0
  243. data/test/rum/x_ua_meta_tag.source.html +10 -0
  244. data/test/rum/x_ua_meta_tag_multiline.result.html +11 -0
  245. data/test/rum/x_ua_meta_tag_multiline.source.html +11 -0
  246. data/test/rum/x_ua_meta_tag_with_others.result.html +11 -0
  247. data/test/rum/x_ua_meta_tag_with_others.source.html +11 -0
  248. data/test/rum/x_ua_meta_tag_with_spaces.result.html +10 -0
  249. data/test/rum/x_ua_meta_tag_with_spaces.source.html +10 -0
  250. data/test/script/ci.sh +1 -12
  251. data/test/test_helper.rb +1 -0
  252. data/vendor/gems/dependency_detection-0.0.1.build/lib/dependency_detection.rb +11 -0
  253. metadata +225 -32
  254. metadata.gz.sig +0 -0
  255. data/lib/new_relic/agent/configuration/defaults.rb +0 -157
  256. data/lib/new_relic/agent/instrumentation/browser_monitoring_timings.rb +0 -56
  257. data/lib/new_relic/agent/thread.rb +0 -37
  258. data/lib/new_relic/agent/thread_profiler.rb +0 -323
  259. data/lib/new_relic/agent/transaction_info.rb +0 -114
  260. data/lib/new_relic/command.rb +0 -89
  261. data/test/new_relic/agent/agent_test_controller_test.rb +0 -348
  262. data/test/new_relic/agent/instrumentation/browser_monitoring_timings_test.rb +0 -70
  263. data/test/new_relic/agent/thread_profiler_test.rb +0 -586
  264. data/test/new_relic/agent/thread_test.rb +0 -93
  265. data/test/new_relic/agent/transaction_info_test.rb +0 -99
@@ -97,14 +97,7 @@ module NewRelic
97
97
  begin
98
98
  require 'new_relic/rack/developer_mode'
99
99
  rails_config.middleware.use NewRelic::Rack::DeveloperMode
100
-
101
- # inform user that the dev edition is available if we are running inside
102
- # a webserver process
103
- if @local_env.dispatcher_instance_id
104
- port = @local_env.dispatcher_instance_id.to_s =~ /^\d+/ ? ":#{local_env.dispatcher_instance_id}" : ":port"
105
- ::NewRelic::Agent.logger.debug("NewRelic Agent Developer Mode enabled.")
106
- ::NewRelic::Agent.logger.debug("To view performance information, go to http://localhost#{port}/newrelic")
107
- end
100
+ ::NewRelic::Agent.logger.info("New Relic Agent Developer Mode enabled.")
108
101
  rescue => e
109
102
  ::NewRelic::Agent.logger.warn("Error installing New Relic Developer Mode", e)
110
103
  end
@@ -64,14 +64,13 @@ module NewRelic
64
64
 
65
65
  # Merge the stringified options into the config as overrides:
66
66
  environment_name = options.delete(:env) and self.env = environment_name
67
- dispatcher_instance_id = options.delete(:dispatcher_instance_id) and @local_env.dispatcher_instance_id = dispatcher_instance_id
68
67
 
69
68
  NewRelic::Agent::PipeChannelManager.listener.start if options.delete(:start_channel_listener)
70
69
 
71
70
  # An artifact of earlier implementation, we put both #add_method_tracer and #trace_execution
72
71
  # methods in the module methods.
73
72
  Module.send :include, NewRelic::Agent::MethodTracer::ClassMethods
74
- Module.send :include, NewRelic::Agent::MethodTracer::InstanceMethods
73
+ Module.send :include, NewRelic::Agent::MethodTracer
75
74
  init_config(options)
76
75
  NewRelic::Agent.agent = NewRelic::Agent::Agent.instance
77
76
  if Agent.config[:agent_enabled] && !NewRelic::Agent.instance.started?
@@ -32,6 +32,15 @@ module NewRelic
32
32
  end
33
33
  end
34
34
 
35
+ def instance_methods_include?(klass, method_name)
36
+ method_name_sym = method_name.to_sym
37
+ (
38
+ klass.instance_methods.map{ |s| s.to_sym }.include?(method_name_sym) ||
39
+ klass.protected_instance_methods.map{ |s|s.to_sym }.include?(method_name_sym) ||
40
+ klass.private_instance_methods.map{ |s|s.to_sym }.include?(method_name_sym)
41
+ )
42
+ end
43
+
35
44
  def time_to_millis(time)
36
45
  (time.to_f * 1000).round
37
46
  end
@@ -6,26 +6,21 @@ require 'set'
6
6
  require 'new_relic/version'
7
7
 
8
8
  module NewRelic
9
- # An instance of LocalEnvironment is responsible for determining
10
- # three things:
9
+ # An instance of LocalEnvironment is responsible for determining the 'dispatcher'
10
+ # in use by the current process.
11
11
  #
12
- # * Dispatcher - A supported dispatcher, or nil (:mongrel, :thin, :passenger, :webrick, etc)
13
- # * Dispatcher Instance ID, which distinguishes agents on a single host from each other
12
+ # A dispatcher might be a recognized web server such as unicorn or passenger,
13
+ # a background job processor such as resque or sidekiq, or nil for unknown.
14
14
  #
15
- # If the environment can't be determined, it will be set to
16
- # nil and dispatcher_instance_id will have nil.
15
+ # If the environment can't be determined, it will be set to nil.
17
16
  #
18
17
  # NewRelic::LocalEnvironment should be accessed through NewRelic::Control#env (via the NewRelic::Control singleton).
19
18
  class LocalEnvironment
20
- # mongrel, thin, webrick, or possibly nil
21
19
  def discovered_dispatcher
22
20
  discover_dispatcher unless @discovered_dispatcher
23
21
  @discovered_dispatcher
24
22
  end
25
23
 
26
- # used to distinguish instances of a dispatcher from each other, may be nil
27
- attr_writer :dispatcher_instance_id
28
-
29
24
  def initialize
30
25
  # Extend self with any any submodules of LocalEnvironment. These can override
31
26
  # the discover methods to discover new framworks and dispatchers.
@@ -37,18 +32,6 @@ module NewRelic
37
32
  discover_dispatcher
38
33
  end
39
34
 
40
-
41
- # An instance id pulled from either @dispatcher_instance_id or by
42
- # splitting out the first part of the running file
43
- def dispatcher_instance_id
44
- if @dispatcher_instance_id.nil?
45
- if @discovered_dispatcher.nil?
46
- @dispatcher_instance_id = File.basename($0).split(".").first
47
- end
48
- end
49
- @dispatcher_instance_id
50
- end
51
-
52
35
  # Runs through all the objects in ObjectSpace to find the first one that
53
36
  # match the provided class
54
37
  def find_class_in_object_space(klass)
@@ -70,6 +53,12 @@ module NewRelic
70
53
  @mongrel
71
54
  end
72
55
 
56
+ # Setter for testing
57
+ def mongrel=(m)
58
+ @looked_for_mongrel = true
59
+ @mongrel = m
60
+ end
61
+
73
62
  private
74
63
 
75
64
  # Although you can override the dispatcher with NEWRELIC_DISPATCHER this
@@ -107,11 +96,6 @@ module NewRelic
107
96
  def check_for_webrick
108
97
  return unless defined?(::WEBrick) && defined?(::WEBrick::VERSION)
109
98
  @discovered_dispatcher = :webrick
110
- if defined?(::OPTIONS) && OPTIONS.respond_to?(:fetch)
111
- # OPTIONS is set by script/server
112
- @dispatcher_instance_id = OPTIONS.fetch(:port)
113
- end
114
- @dispatcher_instance_id = default_port unless @dispatcher_instance_id
115
99
  end
116
100
 
117
101
  def check_for_fastcgi
@@ -126,19 +110,8 @@ module NewRelic
126
110
 
127
111
  # Get the port from the server if it's started
128
112
  if mongrel && mongrel.respond_to?(:port)
129
- @dispatcher_instance_id = mongrel.port.to_s
130
113
  end
131
114
 
132
- # Get the port from the configurator if one was created
133
- if NewRelic::LanguageSupport.object_space_enabled? && @dispatcher_instance_id.nil? && defined?(::Mongrel::Configurator)
134
- ObjectSpace.each_object(Mongrel::Configurator) do |mongrel|
135
- @dispatcher_instance_id = mongrel.defaults[:port] && mongrel.defaults[:port].to_s
136
- end
137
- end
138
-
139
- # Still can't find the port. Let's look at ARGV to fall back
140
- @dispatcher_instance_id = default_port if @dispatcher_instance_id.nil?
141
-
142
115
  # Might not have server yet, so allow one more check later on first request
143
116
  @looked_for_mongrel = false
144
117
  end
@@ -168,7 +141,11 @@ module NewRelic
168
141
  defined?(::Resque) &&
169
142
  (ENV['QUEUE'] || ENV['QUEUES']) &&
170
143
  (File.basename($0) == 'rake' && ARGV.include?('resque:work'))
144
+ ) || (
145
+ defined?(::Resque::Pool) &&
146
+ (File.basename($0) == 'resque-pool')
171
147
  )
148
+
172
149
  @discovered_dispatcher = :resque if using_resque
173
150
  end
174
151
 
@@ -184,21 +161,10 @@ module NewRelic
184
161
  # Same issue as above- we assume only one instance per process
185
162
  ObjectSpace.each_object(Thin::Server) do |thin_dispatcher|
186
163
  @discovered_dispatcher = :thin
187
- backend = thin_dispatcher.backend
188
- # We need a way to uniquely identify and distinguish agents. The port
189
- # works for this. When using sockets, use the socket file name.
190
- if backend.respond_to? :port
191
- @dispatcher_instance_id = backend.port
192
- elsif backend.respond_to? :socket
193
- @dispatcher_instance_id = backend.socket
194
- else
195
- raise "Unknown thin backend: #{backend}"
196
- end
197
- end # each thin instance
164
+ end
198
165
  end
199
166
  if defined?(::Thin) && defined?(::Thin::VERSION) && !@discovered_dispatcher
200
167
  @discovered_dispatcher = :thin
201
- @dispatcher_instance_id = default_port
202
168
  end
203
169
  end
204
170
 
@@ -214,24 +180,11 @@ module NewRelic
214
180
  end
215
181
  end
216
182
 
217
-
218
- def default_port
219
- require 'optparse'
220
- # If nothing else is found, use the 3000 default
221
- default_port = 3000
222
- OptionParser.new do |opts|
223
- opts.on("-p", "--port=port", String) { | p | default_port = p }
224
- opts.parse(ARGV.clone) rescue nil
225
- end
226
- default_port
227
- end
228
-
229
183
  public
230
184
  # outputs a human-readable description
231
185
  def to_s
232
186
  s = "LocalEnvironment["
233
187
  s << ";dispatcher=#{@discovered_dispatcher}" if @discovered_dispatcher
234
- s << ";instance=#{@dispatcher_instance_id}" if @dispatcher_instance_id
235
188
  s << "]"
236
189
  end
237
190
 
@@ -39,6 +39,8 @@ module NewRelic::Rack
39
39
  !headers['Content-Disposition'].to_s.include?('attachment')
40
40
  end
41
41
 
42
+ X_UA_COMPATIBLE_RE = /<\s*meta[^>]+http-equiv=['"]x-ua-compatible['"][^>]*>/im.freeze
43
+
42
44
  def autoinstrument_source(response, headers)
43
45
  source = nil
44
46
  response.each {|fragment| source ? (source << fragment.to_s) : (source = fragment.to_s)}
@@ -53,12 +55,13 @@ module NewRelic::Rack
53
55
  footer = NewRelic::Agent.browser_timing_footer
54
56
  header = NewRelic::Agent.browser_timing_header
55
57
 
56
- x_ua_compatible_found = beginning_of_source.include?('X-UA-Compatible')
58
+ match = X_UA_COMPATIBLE_RE.match(beginning_of_source)
59
+ x_ua_compatible_position = match.end(0) if match
57
60
 
58
- head_pos = if x_ua_compatible_found
59
- # put at end of header if X-UA-Compatible meta tag found
60
- ::NewRelic::Agent.logger.debug "Detected X-UA-Compatible meta tag. Attempting to insert RUM header at end of head."
61
- beginning_of_source.index("</head>")
61
+ head_pos = if x_ua_compatible_position
62
+ # put after X-UA-Compatible meta tag if found
63
+ ::NewRelic::Agent.logger.debug "Detected X-UA-Compatible meta tag. Attempting to insert RUM header after meta tag."
64
+ x_ua_compatible_position
62
65
  elsif head_open = beginning_of_source.index("<head")
63
66
  ::NewRelic::Agent.logger.debug "Attempting to insert RUM header at beginning of head."
64
67
  # put at the beginning of the header
@@ -21,37 +21,20 @@ make_notify_task = Proc.new do
21
21
  task :notice_deployment, :roles => :app, :except => {:no_release => true } do
22
22
  rails_env = fetch(:newrelic_rails_env, fetch(:rails_env, "production"))
23
23
 
24
- require File.join(File.dirname(__FILE__), 'command.rb')
24
+ require File.join(File.dirname(__FILE__), 'cli', 'command.rb')
25
25
 
26
26
  begin
27
27
  # allow overrides to be defined for revision, description, changelog, appname, and user
28
- rev = fetch(:newrelic_revision) if exists?(:newrelic_revision)
29
- description = fetch(:newrelic_desc) if exists?(:newrelic_desc)
30
- changelog = fetch(:newrelic_changelog) if exists?(:newrelic_changelog)
31
- appname = fetch(:newrelic_appname) if exists?(:newrelic_appname)
32
- user = fetch(:newrelic_user) if exists?(:newrelic_user)
33
-
34
- if !changelog
35
- logger.debug "Getting log of changes for New Relic Deployment details"
36
- from_revision = source.next_revision(current_revision)
37
-
38
- if scm == :git
39
- log_command = "git log --no-color --pretty=format:' * %an: %s' " +
40
- "--abbrev-commit --no-merges #{previous_revision}..#{real_revision}"
41
- else
42
- log_command = "#{source.log(from_revision)}"
43
- end
44
-
45
- changelog = `#{log_command}`
46
- end
47
-
48
- if rev.nil?
49
- rev = source.query_revision(source.head()) do |cmd|
50
- logger.debug "executing locally: '#{cmd}'"
51
- `#{cmd}`
52
- end
53
-
54
- rev = rev[0..6] if scm == :git
28
+ rev = fetch(:newrelic_revision) if exists?(:newrelic_revision)
29
+ description = fetch(:newrelic_desc) if exists?(:newrelic_desc)
30
+ changelog = fetch(:newrelic_changelog) if exists?(:newrelic_changelog)
31
+ appname = fetch(:newrelic_appname) if exists?(:newrelic_appname)
32
+ user = fetch(:newrelic_user) if exists?(:newrelic_user)
33
+ license_key = fetch(:newrelic_license_key) if exists?(:newrelic_license_key)
34
+
35
+ unless scm == :none
36
+ changelog = lookup_changelog(changelog)
37
+ rev = lookup_rev(rev)
55
38
  end
56
39
 
57
40
  new_revision = rev
@@ -61,15 +44,16 @@ make_notify_task = Proc.new do
61
44
  :changelog => changelog,
62
45
  :description => description,
63
46
  :appname => appname,
64
- :user => user
47
+ :user => user,
48
+ :license_key => license_key
65
49
  }
66
50
 
67
51
  logger.debug "Uploading deployment to New Relic"
68
- deployment = NewRelic::Command::Deployments.new deploy_options
52
+ deployment = NewRelic::Cli::Deployments.new deploy_options
69
53
  deployment.run
70
54
  logger.info "Uploaded deployment information to New Relic"
71
55
 
72
- rescue NewRelic::Command::CommandFailure => e
56
+ rescue NewRelic::Cli::Command::CommandFailure => e
73
57
  logger.info e.message
74
58
 
75
59
  rescue Capistrano::CommandError
@@ -84,6 +68,35 @@ make_notify_task = Proc.new do
84
68
  # run(...)
85
69
  # end
86
70
  end
71
+
72
+ def lookup_changelog(changelog)
73
+ if !changelog
74
+ logger.debug "Getting log of changes for New Relic Deployment details"
75
+ from_revision = source.next_revision(current_revision)
76
+
77
+ if scm == :git
78
+ log_command = "git log --no-color --pretty=format:' * %an: %s' " +
79
+ "--abbrev-commit --no-merges #{previous_revision}..#{real_revision}"
80
+ else
81
+ log_command = "#{source.log(from_revision)}"
82
+ end
83
+
84
+ changelog = `#{log_command}`
85
+ end
86
+ changelog
87
+ end
88
+
89
+ def lookup_rev(rev)
90
+ if rev.nil?
91
+ rev = source.query_revision(source.head()) do |cmd|
92
+ logger.debug "executing locally: '#{cmd}'"
93
+ `#{cmd}`
94
+ end
95
+
96
+ rev = rev[0..6] if scm == :git
97
+ end
98
+ rev
99
+ end
87
100
  end
88
101
  end
89
102
 
@@ -31,7 +31,7 @@ module NewRelic
31
31
  @root_segment = create_segment 0.0, "ROOT"
32
32
 
33
33
  @guid = generate_guid
34
- NewRelic::Agent::TransactionInfo.get.guid = @guid
34
+ NewRelic::Agent::TransactionState.get.request_guid = @guid
35
35
  end
36
36
 
37
37
  def count_segments
@@ -187,6 +187,11 @@ module NewRelic
187
187
  @params = params
188
188
  end
189
189
 
190
+ def force_persist_sample?
191
+ NewRelic::Agent::TransactionState.get.request_token &&
192
+ self.duration > NewRelic::Agent::TransactionState.get.transaction.apdex_t
193
+ end
194
+
190
195
  private
191
196
 
192
197
  HEX_DIGITS = (0..15).map{|i| i.to_s(16)}
@@ -268,6 +273,5 @@ module NewRelic
268
273
  target_called_segment.end_trace(source_called_segment.exit_timestamp)
269
274
  end
270
275
  end
271
-
272
276
  end
273
277
  end
@@ -12,7 +12,7 @@ module NewRelic
12
12
 
13
13
  MAJOR = 3
14
14
  MINOR = 6
15
- TINY = 6
15
+ TINY = 7
16
16
 
17
17
  begin
18
18
  require File.join(File.dirname(__FILE__), 'build')
@@ -1,7 +1,27 @@
1
1
  # run unit tests for the NewRelic Agent
2
2
  namespace :newrelic do
3
- desc "install a default config/newrelic.yml file"
3
+ desc "Install a default config/newrelic.yml file"
4
4
  task :install do
5
5
  load File.expand_path(File.join(File.dirname(__FILE__), "..", "..", "install.rb"))
6
6
  end
7
+
8
+ namespace :config do
9
+ desc "Describe available New Relic configuration settings."
10
+ task :docs do
11
+ require File.expand_path(File.join(File.dirname(__FILE__), "..", "new_relic", "agent", "configuration", "default_source.rb"))
12
+
13
+ NewRelic::Agent::Configuration::DEFAULTS.each do |key, value|
14
+ if value[:public]
15
+ puts "Setting: #{key}"
16
+ if value[:type] == NewRelic::Agent::Configuration::Boolean
17
+ puts "Type: Boolean"
18
+ else
19
+ puts "Type: #{value[:type]}"
20
+ end
21
+ puts 'Description: ' + value[:description]
22
+ puts "-" * (value[:description].length + 14)
23
+ end
24
+ end
25
+ end
26
+ end
7
27
  end
data/newrelic_rpm.gemspec CHANGED
@@ -9,7 +9,7 @@ Gem::Specification.new do |s|
9
9
  s.name = "newrelic_rpm"
10
10
  s.version = NewRelic::VERSION::STRING
11
11
  s.required_rubygems_version = Gem::Requirement.new("> 1.3.1") if s.respond_to? :required_rubygems_version=
12
- s.authors = [ "Jason Clark", "Sam Goldstein", "Michael Granger", "Jon Guymon", "Ben Weintraub" ]
12
+ s.authors = [ "Jason Clark", "Sam Goldstein", "Michael Granger", "Jonan Scheffler", "Ben Weintraub" ]
13
13
  s.date = Time.now.strftime('%Y-%m-%d')
14
14
  s.description = <<-EOS
15
15
  New Relic is a performance management system, developed by New Relic,
@@ -50,6 +50,10 @@ EOS
50
50
  s.add_development_dependency 'activerecord-jdbcsqlite3-adapter' if RUBY_PLATFORM == 'java'
51
51
  s.add_development_dependency 'jruby-openssl' if RUBY_PLATFORM == 'java'
52
52
  s.add_development_dependency 'sequel', '~> 3.46.0'
53
+ s.add_development_dependency 'pry'
54
+ s.add_development_dependency 'guard'
55
+ s.add_development_dependency 'guard-test'
56
+ s.add_development_dependency 'rb-fsevent', '~> 0.9.1'
53
57
 
54
58
  # Only sign with our private key if you can find it
55
59
  signing_key_path = File.expand_path('~/.ssh/newrelic_rpm-private_key.pem')
data/test/agent_helper.rb CHANGED
@@ -295,15 +295,6 @@ ensure
295
295
  parent.const_set(const_name, removed_constant) if removed_constant
296
296
  end
297
297
 
298
- def internet_connection?
299
- if ENV['NO_INTERNET']
300
- puts " - No internet connection, skipping"
301
- false
302
- else
303
- true
304
- end
305
- end
306
-
307
298
  def with_debug_logging
308
299
  orig_logger = NewRelic::Agent.logger
309
300
  $stderr.puts '', '---', ''
@@ -313,3 +304,7 @@ def with_debug_logging
313
304
  ensure
314
305
  NewRelic::Agent.logger = orig_logger
315
306
  end
307
+
308
+ def create_agent_command(args = {})
309
+ NewRelic::Agent::Commands::AgentCommand.new([-1, { "name" => "command_name", "arguments" => args}])
310
+ end