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
data.tar.gz.sig CHANGED
Binary file
data/.gitignore CHANGED
@@ -22,4 +22,3 @@ lib/new_relic/build.rb
22
22
  .pryrc
23
23
  .tm_properties
24
24
  .bundle
25
- /bin/
data/CHANGELOG CHANGED
@@ -1,5 +1,43 @@
1
1
  # New Relic Ruby Agent Release Notes #
2
2
 
3
+ ## v3.6.7 ##
4
+
5
+ * Resque-pool support
6
+
7
+ Resque processes started via the resque-pool gem weren't recognized by the
8
+ Ruby agent. The agent now starts correctly in those worker processes.
9
+
10
+ * Environment-based configuration
11
+
12
+ All settings in newrelic.yml can now be configured via environment variables.
13
+ See https://newrelic.com/docs/ruby/ruby-agent-configuration for full details.
14
+
15
+ * Fix compatibility issues with excon and curb instrumentation
16
+
17
+ This release of the agent fixes a warning seen under certain circumstances
18
+ with the excon gem (most notably, when excon was used by fog), as well as
19
+ a bug with the curb instrumentation that conflicted with the feedzirra gem.
20
+
21
+ * Allow license key to be set by Capistrano variables
22
+
23
+ A license key can be passed via a Capistrano variable where previously it
24
+ could only be in newrelic.yml. Thanks Chris Marshall for the contribution!
25
+
26
+ * Make HTTP client instrumentation aware of "Host" request header
27
+
28
+ If a "Host" header is set explicitly on an HTTP request, that hostname will
29
+ be used for external metrics. Thanks Mislav Marohnić for the contribution!
30
+
31
+ * Fix ActiveSupport::Concern warnings with MethodTracer
32
+
33
+ Including NewRelic::Agent::MethodTracer in a class using Concerns could cause
34
+ deprecation warnings. Thanks Mike Połtyn for the contribution!
35
+
36
+ * Fix Authlogic constant name
37
+
38
+ Code checking for the Authlogic module was using in the wrong case. Thanks
39
+ Dharam Gollapudi for the contribution!
40
+
3
41
  ## v3.6.6 ##
4
42
 
5
43
  * HTTPClient and Curb support
@@ -152,7 +190,7 @@
152
190
 
153
191
  ## v3.6.0 ##
154
192
 
155
- * Sidekiq supprt
193
+ * Sidekiq support
156
194
 
157
195
  The Ruby agent now supports the Sidekiq background job framework. Traces from
158
196
  Sidekiq jobs will automatically show up in the Background tasks on New Relic
@@ -357,7 +395,7 @@
357
395
  * The host and the port that the agent reports to can now be set from environment vars
358
396
 
359
397
  The host can be set with NEW_RELIC_HOST and the port with NEW_RELIC_PORT. These setting
360
- will overrride any other settings in your newrelic.yml.
398
+ will override any other settings in your newrelic.yml.
361
399
 
362
400
  * Fix RUM reporting to multiple applications
363
401
 
@@ -369,16 +407,16 @@
369
407
  * Update the collector protocol to use JSON and Ruby primitives
370
408
 
371
409
  The communication between the agent and the NewRelic will not longer be
372
- marshalled Ruby objects, but rather JSON in the case of Ruby 1.9 and marshalled
410
+ marshaled Ruby objects, but rather JSON in the case of Ruby 1.9 and marshaled
373
411
  Ruby primitives in the case of 1.8. This results in greater harvest efficiency
374
412
  as well as feature parity with other New Relic agents.
375
413
 
376
414
  * Fix incorrect application of conditions in sinatra instrumentation
377
415
 
378
- The agent's sinatra instrumentation was causing sinatra's condidtions to
416
+ The agent's sinatra instrumentation was causing sinatra's conditions to
379
417
  be incorrectly applied in some obscure cases. The bug was triggered
380
418
  when a condition was present on a lower priority route that would match
381
- the current request, except for the precense of a higher priority route.
419
+ the current request, except for the presence of a higher priority route.
382
420
 
383
421
  ## v3.5.2 ##
384
422
 
@@ -442,7 +480,7 @@
442
480
  dispatcher an INFO level log message it created that includes a link to New Relic
443
481
  online doc that has additional steps that may be required to get performance data reporting.
444
482
 
445
- * (Fix) In version 3.4.2 of the Ruby Agent the server side value for Apdex T was disgregarded
483
+ * (Fix) In version 3.4.2 of the Ruby Agent the server side value for Apdex T was disregarded
446
484
 
447
485
  With version 3.4.2 of the agent, the value set in the newrelic.yml file took precedence over the
448
486
  value set in the New Relic UI. As of version 3.5.0 only the value for Apdex T set in the
@@ -487,7 +525,7 @@
487
525
 
488
526
  * The RUM NRAGENT tk value gets more robustly sanitized to prevent potential XSS vulnerabilities
489
527
 
490
- The code that scrubes the token used in Real User Monitoring has been enhanced to be
528
+ The code that scrubs the token used in Real User Monitoring has been enhanced to be
491
529
  more robust.
492
530
 
493
531
  * Support for Apdex T in server side configuration
@@ -497,7 +535,7 @@
497
535
 
498
536
  * Refactoring of agent config code
499
537
 
500
- The code that reads the configuration information and confirgures the agent
538
+ The code that reads the configuration information and configures the agent
501
539
  got substantially reorganized, consolidated, simplified, and made more robust.
502
540
 
503
541
  ## v3.4.1 ##
@@ -530,7 +568,7 @@
530
568
 
531
569
  * corrupt marshal data from pipe children crashing agent
532
570
 
533
- If the agent receieved corrupted data from the Reqsue worker child agent
571
+ If the agent received corrupted data from the Reqsue worker child agent
534
572
  it could crash the agent itself. fixed.
535
573
 
536
574
  * should reset RubyBench GC counter between polls
@@ -583,7 +621,7 @@ v3.3.1
583
621
  * improved Ruby 1.8.6 support
584
622
  * fix for issues with RAILS_ROOT deprecation warnings
585
623
  * fixed incorrect 1.9 GC time reporting
586
- * obfusction for Slow SQL queries respects transaction trace config
624
+ * obfuscation for Slow SQL queries respects transaction trace config
587
625
  * fix for RUM instrumentation repoting bad timing info in some cases
588
626
  * refactored ActiveRecord instrumentation, no longer requires Rails
589
627
 
@@ -681,7 +719,7 @@ v2.13.3
681
719
  * Delete obsolete links to metric docs in developer mode
682
720
  * Detect gems when using Bundler
683
721
  * Fix newrelic_ignore in Rails 3
684
- * Break metric parser into a seperate vendored gem
722
+ * Break metric parser into a separate vendored gem
685
723
  * When using Unicorn, preload_app: true is recommended to get proper
686
724
  after_fork behavior.
687
725
 
@@ -712,7 +750,7 @@ v2.13.0
712
750
  * added record_transaction method to the api to allow recording
713
751
  details from web and background transactions occurring outside RPM
714
752
  * fixed a bug related to enabling a gold trial / upgrade not sending
715
- trasaction traces correctly
753
+ transaction traces correctly
716
754
 
717
755
  v2.12.3
718
756
  * fix regression in startup sequence
@@ -773,7 +811,7 @@ v2.10.8
773
811
  * preliminary support for rails3
774
812
 
775
813
  v2.10.6
776
- * fix missing URL and referer on some traced errors and transactions
814
+ * fix missing URL and referrer on some traced errors and transactions
777
815
  * gather traced errors *after* executing the rescue chain in ActionController
778
816
  * always load controller instrumentation
779
817
  * pick up token validation from newrelic.yml
@@ -833,7 +871,7 @@ v2.10.1.
833
871
  tasks and eventually things like rack, metal and Sinatra
834
872
  * adjusted apdex scores to reflect time spent in the mongrel queue
835
873
  * fixed incompatibility with JRuby on startup
836
- * implmented CPU measure for JRuby which reflects the cpu burn for
874
+ * implemented CPU measure for JRuby which reflects the cpu burn for
837
875
  all controller actions (does not include background tasks)
838
876
  * fixed scope issue with GC instrumentation, subtracting time from caller
839
877
  * added # of GC calls to GC instrumentation
@@ -846,7 +884,7 @@ v2.10.0.
846
884
  * support unicorn
847
885
  * instrumentation of GC for REE and MRE with GC patch
848
886
  * support agent restarting when changes are made to the account
849
- * removed #newrelic_notice_error from Object class, replaced by NewRelic::Agent#notic_error
887
+ * removed #newrelic_notice_error from Object class, replaced by NewRelic::Agent#notice_error
850
888
  * collect histogram statistics
851
889
  * add custom parameters to newrelic_notice_error call to display
852
890
  extra info for errors
@@ -957,7 +995,7 @@ v2.9.0.
957
995
  Agent improvements to support future RPM enhancements
958
996
  * add instrumentation to capture metrics on response codes; not yet
959
997
  working in rails 2.3.*
960
- * added http referer to traced errors
998
+ * added http referrer to traced errors
961
999
  * capture gem requirements from rails
962
1000
  * capture cpu utilization adjusted for processor count
963
1001
  * transaction sampling
@@ -1099,7 +1137,7 @@ v2.3.6.
1099
1137
  * bugfixes
1100
1138
 
1101
1139
  v2.3.5.
1102
- * bugfixes: pie chart data, rails 1.1 compability
1140
+ * bugfixes: pie chart data, rails 1.1 compatibility
1103
1141
 
1104
1142
  v2.3.4.
1105
1143
  * bugfix
data/Guardfile ADDED
@@ -0,0 +1,7 @@
1
+ guard :test, :test_paths => ['test/new_relic'], :all_after_pass => false do
2
+ watch(%r{^lib/(.+)\.rb$}) { |m| "test/#{m[1]}_test.rb" }
3
+ watch(%r{^test/.+_test\.rb$})
4
+ watch(%r{^test/rum/.*}) { "test/new_relic/rack/browser_monitoring_test.rb" }
5
+ watch('test/test_helper.rb') { "test" }
6
+ watch('test/agent_helper.rb') { "test" }
7
+ end
data/Rakefile CHANGED
@@ -49,6 +49,12 @@ namespace :test do
49
49
  Performance::Runner.new(options).run_and_report
50
50
  end
51
51
 
52
+ desc "Run agent within existing mini environments"
53
+ task :env, [:env1, :env2, :env3, :env4, :env5, :env6] => [] do |t, args|
54
+ require File.expand_path(File.join(File.dirname(__FILE__), 'test', 'environments', 'lib', 'environments', 'runner'))
55
+ Environments::Runner.new(args.map{|_,v| v}).run_and_report
56
+ end
57
+
52
58
  Rake::TestTask.new(:intentional_fail) do |t|
53
59
  t.libs << "#{agent_home}/test"
54
60
  t.libs << "#{agent_home}/lib"
data/bin/mongrel_rpm ADDED
@@ -0,0 +1,33 @@
1
+ #!/usr/bin/env ruby
2
+ require 'rubygems'
3
+ require 'rack'
4
+ require 'rack/handler/mongrel'
5
+ require 'optparse'
6
+
7
+ port = 3000
8
+ options = { }
9
+ appname = nil
10
+ OptionParser.new do |opts|
11
+ opts.banner = "Usage: #{File.basename($0)} [options] [app_name]"
12
+ opts.on("-p", "--port=port", Integer, "default: #{port}") { | port | }
13
+ opts.on("--[no-]logging", "turn off request logging" ) { | l | options[:logging] = l }
14
+ opts.on("--license=license_key", "override license key" ) { | l | options[:license_key] = l }
15
+ opts.on("--install", "install a newrelic.yml template" ) { | l | options[:install] = true }
16
+ opts.separator ""
17
+ opts.separator "app_name is the name of the application where the metrics will be stored"
18
+ opts.separator ""
19
+ # The rackup file references this var
20
+ appname = opts.parse!(ARGV.clone).first
21
+ end
22
+
23
+ options[:app_name] = appname if appname
24
+
25
+ ru_file = File.expand_path(File.join(File.dirname(__FILE__), "..", "lib", "new_relic", "rack", "mongrel_rpm.ru"))
26
+ rackup_code = File.read ru_file
27
+ builder = Rack::Builder.new { eval rackup_code, binding, ru_file }
28
+
29
+ options = { :Host => '127.0.0.1', :Port => port }
30
+ Rack::Handler::Mongrel.run(builder.to_app, options) do | server |
31
+ NewRelic::Agent.logger.info "Started Mongrel listening for '#{NewRelic::Control.instance.app_names.join(" and ")}' data at #{server.host}:#{server.port}"
32
+ end
33
+
data/bin/newrelic ADDED
@@ -0,0 +1,13 @@
1
+ #!/usr/bin/env ruby
2
+ # executes one of the commands in the new_relic/commands directory
3
+ # pass the name of the command as an argument
4
+
5
+ $LOAD_PATH << File.expand_path(File.join(File.dirname(__FILE__), '..','lib'))
6
+ require 'new_relic/cli/command'
7
+ begin
8
+ NewRelic::Cli::Command.run
9
+ rescue NewRelic::Cli::Command::CommandFailure => failure
10
+ STDERR.puts failure.message
11
+ STDERR.puts failure.options if failure.options
12
+ exit 1
13
+ end
data/bin/newrelic_cmd ADDED
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+ # This command has been renamed "newrelic"
3
+ # executes one of the commands in the new_relic/commands directory
4
+ # pass the name of the command as an argument
5
+ load File.dirname(__FILE__) + '/newrelic'
data/bin/nrdebug ADDED
@@ -0,0 +1,273 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ # encoding: utf-8
4
+ # This file is distributed under New Relic's license terms.
5
+ # See https://github.com/newrelic/rpm/blob/master/LICENSE for complete details.
6
+
7
+ require 'tempfile'
8
+ require 'rbconfig'
9
+
10
+ def fail(msg, opts={})
11
+ $stderr.puts(msg)
12
+ usage() if opts[:usage]
13
+ exit(-1)
14
+ end
15
+
16
+ def usage
17
+ $stderr.puts("Usage: #{$0} <target_pid>")
18
+ end
19
+
20
+ class Logger
21
+ def self.log(msg)
22
+ @messages ||= []
23
+ @messages << [Time.now, msg]
24
+ end
25
+
26
+ def self.messages
27
+ @messages
28
+ end
29
+ end
30
+
31
+ class ShellWrapper
32
+ def self.execute(cmd)
33
+ Logger.log("Executing '#{cmd}'")
34
+ `#{cmd} 2>&1`
35
+ end
36
+ end
37
+
38
+ class ProcessDataProvider
39
+ attr_reader :pid
40
+
41
+ def initialize(pid)
42
+ @pid = pid
43
+ end
44
+
45
+ def attachable?
46
+ begin
47
+ my_uid = Process.uid
48
+ (my_uid == 0 || uid == my_uid)
49
+ rescue
50
+ return false
51
+ end
52
+ end
53
+
54
+ def alive?
55
+ Process.kill(0, @pid.to_i)
56
+ return true
57
+ rescue Errno::ESRCH
58
+ return false
59
+ end
60
+
61
+ def uid
62
+ ShellWrapper.execute("ps -o uid #{pid}").split("\n").last.strip.to_i
63
+ end
64
+
65
+ def user
66
+ ShellWrapper.execute("ps -o user #{pid}").split("\n").last.strip
67
+ end
68
+
69
+ def ppid
70
+ ShellWrapper.execute("ps -o ppid #{pid}").split("\n").last
71
+ end
72
+
73
+ def rss
74
+ ShellWrapper.execute("ps -o rss #{pid}").split("\n").last.to_i
75
+ end
76
+
77
+ def cpu
78
+ ShellWrapper.execute("ps -o cpu #{pid}").split("\n").last
79
+ end
80
+
81
+ def open_files
82
+ ShellWrapper.execute("lsof -p #{pid}")
83
+ end
84
+
85
+ def self.for_process(pid)
86
+ case RbConfig::CONFIG['target_os']
87
+ when /linux/ then LinuxProcessDataProvider.new(pid)
88
+ when /darwin/ then DarwinProcessDataProvider.new(pid)
89
+ end
90
+ end
91
+ end
92
+
93
+ class LinuxProcessDataProvider < ProcessDataProvider
94
+ def proc_path(item)
95
+ File.join("/proc/#{pid}", item)
96
+ end
97
+
98
+ def procline
99
+ File.read(proc_path('cmdline')).gsub("\000", " ")
100
+ end
101
+
102
+ def environment
103
+ File.read(proc_path('environ')).gsub("\000", "\n")
104
+ end
105
+ end
106
+
107
+ class DarwinProcessDataProvider < ProcessDataProvider
108
+ def procline
109
+ ShellWrapper.execute("ps -o command #{pid}").split("\n").last
110
+ end
111
+
112
+ def environment
113
+ cmd = "ps -o command -E #{pid}"
114
+ ShellWrapper.execute(cmd).split("\n").last.gsub(procline, '').strip
115
+ end
116
+ end
117
+
118
+ class RubyProcess
119
+ attr_accessor :pid
120
+
121
+ def initialize(pid)
122
+ @pid = pid
123
+ @provider = ProcessDataProvider.for_process(pid)
124
+ end
125
+
126
+ [:uid, :ppid, :rss, :cpu, :open_files, :procline, :environment, :alive?, :attachable?].each do |m|
127
+ define_method(m) do
128
+ @provider.send(m)
129
+ end
130
+ end
131
+
132
+ def gather_backtraces
133
+ backtrace_file = Tempfile.new('nrdebug_ruby_bt')
134
+ File.chmod(0666, backtrace_file.path)
135
+
136
+ gdb_script_body = <<-END
137
+ attach #{pid}
138
+ t a a bt
139
+ call (void)close(1)
140
+ call (void)close(2)
141
+ call (int)open("#{backtrace_file.path}", 2, 0)
142
+ call (int)open("#{backtrace_file.path}", 2, 0)
143
+ call (void)rb_backtrace()
144
+ call (void)fflush(0)
145
+ quit
146
+ END
147
+ Logger.log("Using gdb script:\n#{gdb_script_body}")
148
+
149
+ script_file = Tempfile.new('nrdebug_gdb_script')
150
+ script_file.write(gdb_script_body)
151
+ script_file.close
152
+
153
+ gdb_stderr = Tempfile.new('nrdebug_gdb_stderr')
154
+
155
+ gdb_cmd = "gdb -batch -x #{script_file.path} 2>#{gdb_stderr.path}"
156
+ gdb_output = ShellWrapper.execute(gdb_cmd)
157
+ ruby_backtrace = File.read(backtrace_file.path)
158
+
159
+ script_file.close!
160
+ backtrace_file.close!
161
+ gdb_stderr.close!
162
+
163
+ [gdb_output, ruby_backtrace]
164
+ end
165
+ end
166
+
167
+ class ProcessReport
168
+ attr_reader :target, :path
169
+
170
+ def initialize(target, path=nil)
171
+ @target = target
172
+ @path = path
173
+ end
174
+
175
+ def open
176
+ if @path
177
+ File.open(@path, "w") do |f|
178
+ yield f
179
+ end
180
+ else
181
+ yield $stdout
182
+ end
183
+ end
184
+
185
+ def section(f, name=nil)
186
+ content = begin
187
+ yield
188
+ rescue StandardError => e
189
+ "<Error: #{e}>, backtrace =\n#{e.backtrace.join("\n")}"
190
+ end
191
+ if name
192
+ f.puts("#{name}:")
193
+ f.puts(content)
194
+ f.puts ''
195
+ end
196
+ end
197
+
198
+ def generate
199
+ open do |f|
200
+ section(f, "Time") { Time.now }
201
+ section(f, "PID") { @target.pid }
202
+ section(f, "Command") { @target.procline }
203
+ section(f, "RSS") { @target.rss }
204
+ section(f, "CPU") { @target.cpu }
205
+ section(f, "Parent PID") { @target.ppid }
206
+ section(f, "OS") { ShellWrapper.execute('uname -a') }
207
+ section(f, "Environment") { @target.environment }
208
+
209
+ section(f) do
210
+ c_backtraces, ruby_backtraces = @target.gather_backtraces
211
+ if c_backtraces.match(/could not attach/i)
212
+ fail("Failed to attach to target process. Please try again with sudo.")
213
+ end
214
+ section(f, "C Backtraces") { c_backtraces }
215
+ section(f, "Ruby Backtrace") { ruby_backtraces }
216
+ end
217
+
218
+ section(f, "Open files") { @target.open_files }
219
+ section(f, "Log") do
220
+ commands = Logger.messages.map { |(_,msg)| msg }
221
+ commands.join("\n")
222
+ end
223
+ end
224
+ end
225
+ end
226
+
227
+ def prompt_for_confirmation(target_pid, target_cmd)
228
+ puts "Are you sure you want to attach to PID #{target_pid} ('#{target_cmd}')}?"
229
+ puts ''
230
+ puts "Extracting debug information from this process may cause it to hang, crash,"
231
+ puts "or otherwise malfunction. It is highly recommended that you only run this"
232
+ puts "script against processes that are already unresponsive."
233
+ puts ''
234
+ puts "Additionally, the output may contain sensitive information from the program's"
235
+ puts "command line arguments, environment, or open file list. Please examine the"
236
+ puts "output before sharing it."
237
+ puts ''
238
+ puts "To continue, type 'continue':"
239
+
240
+ until ($stdin.gets.strip == 'continue') do
241
+ puts "Please type 'continue' to continue, or ctrl-c to abort."
242
+ end
243
+ end
244
+
245
+ target_pid = ARGV[0]
246
+ fail("Please provide a PID for the target process", :usage => true) unless target_pid
247
+
248
+ gdb_path = `which gdb`
249
+ fail("Could not find gdb, please ensure it is installed and in your PATH") if gdb_path.empty?
250
+
251
+ target = RubyProcess.new(target_pid)
252
+ if !target.attachable?
253
+ fail("You do not appear to have permissions to attach to the target process.\nPlease check the process owner and try again with sudo if necessary")
254
+ end
255
+ if !target.alive?
256
+ fail("Could not find process with PID #{target_pid}")
257
+ end
258
+ target_cmd = target.procline
259
+
260
+ prompt_for_confirmation(target_pid, target_cmd)
261
+
262
+ puts ''
263
+ puts "Attaching to PID #{target_pid} ('#{target_cmd}')"
264
+
265
+ timestamp = Time.now.to_i
266
+ report_filename = "nrdebug-#{target_pid}-#{timestamp}.log"
267
+ report = ProcessReport.new(target, report_filename)
268
+ report.generate
269
+
270
+ puts "Generated '#{report_filename}'"
271
+ puts ''
272
+ puts "Please examine the output file for potentially sensitive information and"
273
+ puts "remove it before sharing this file with anyone."