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
metadata.gz.sig CHANGED
Binary file
@@ -1,157 +0,0 @@
1
- # encoding: utf-8
2
- # This file is distributed under New Relic's license terms.
3
- # See https://github.com/newrelic/rpm/blob/master/LICENSE for complete details.
4
-
5
- module NewRelic
6
- module Agent
7
- module Configuration
8
- # This is so we can easily differentiate between the actual
9
- # default source and a Hash that was simply pushed onto the
10
- # config stack.
11
- class DefaultSource < Hash; end
12
-
13
- DEFAULTS = DefaultSource[
14
- :config_path => Proc.new {
15
- # Check a sequence of file locations for newrelic.yml
16
- files = []
17
- files << File.join("config","newrelic.yml")
18
- files << File.join("newrelic.yml")
19
- if ENV["HOME"]
20
- files << File.join(ENV["HOME"], ".newrelic", "newrelic.yml")
21
- files << File.join(ENV["HOME"], "newrelic.yml")
22
- end
23
- files.detect do |file|
24
- File.expand_path(file) if File.exists? file
25
- end
26
- },
27
- :app_name => Proc.new { NewRelic::Control.instance.env },
28
- :dispatcher => Proc.new { NewRelic::Control.instance.local_env.discovered_dispatcher },
29
- :framework => Proc.new do
30
- case
31
- when defined?(::NewRelic::TEST) then :test
32
- when defined?(::Merb) && defined?(::Merb::Plugins) then :merb
33
- when defined?(::Rails)
34
- case Rails::VERSION::MAJOR
35
- when 0..2
36
- :rails
37
- when 3
38
- :rails3
39
- when 4
40
- :rails4
41
- else
42
- ::NewRelic::Agent.logger.error "Detected unsupported Rails version #{Rails::VERSION::STRING}"
43
- end
44
- when defined?(::Sinatra) && defined?(::Sinatra::Base) then :sinatra
45
- when defined?(::NewRelic::IA) then :external
46
- else :ruby
47
- end
48
- end,
49
- :enabled => true,
50
- :monitor_mode => Proc.new { self[:enabled] },
51
-
52
- # agent_enabled determines whether the agent should try to start and
53
- # report data.
54
- :agent_enabled => Proc.new do
55
- self[:enabled] &&
56
- (self[:developer_mode] || self[:monitor_mode] || self[:monitor_daemons]) &&
57
- ::NewRelic::Agent::Autostart.agent_should_start?
58
- end,
59
- # Don't autostart the agent if we're in IRB or Rails console.
60
- # This config option accepts a comma separated list of constants.
61
- :'autostart.blacklisted_constants' => 'Rails::Console',
62
- # Comma separated list of executables that you don't want to trigger
63
- # agents start. e.g. 'rake,my_ruby_script.rb'
64
- :'autostart.blacklisted_executables' => 'irb,rspec',
65
- :'autostart.blacklisted_rake_tasks' => 'about,assets:clean,assets:clobber,assets:environment,assets:precompile,db:create,db:drop,db:fixtures:load,db:migrate,db:migrate:status,db:rollback,db:schema:cache:clear,db:schema:cache:dump,db:schema:dump,db:schema:load,db:seed,db:setup,db:structure:dump,db:version,doc:app,log:clear,middleware,notes,notes:custom,rails:template,rails:update,routes,secret,spec,spec:controllers,spec:helpers,spec:models,spec:rcov,stats,test,test:all,test:all:db,test:recent,test:single,test:uncommitted,time:zones:all,tmp:clear,tmp:create',
66
- :developer_mode => Proc.new { self[:developer] },
67
- :developer => false,
68
- :apdex_t => 0.5,
69
- :monitor_daemons => false,
70
- :multi_homed => false,
71
- :high_security => false,
72
- # Strip messages from all exceptions that are not specified in the whitelist.
73
- :'strip_exception_messages.enabled' => Proc.new { self[:high_security] },
74
- # Comma separated list of exceptions that should show messages when
75
- # strip_exception_messages is enabled (e.g. 'NewException, RelicException').
76
- :'strip_exception_messages.whitelist' => '',
77
-
78
- :host => 'collector.newrelic.com',
79
- :api_host => 'rpm.newrelic.com',
80
- :port => Proc.new { self[:ssl] ? 443 : 80 },
81
- :api_port => Proc.new { self[:port] },
82
- :ssl => true,
83
- :sync_startup => false,
84
- :send_data_on_exit => true,
85
- :post_size_limit => 2 * 1024 * 1024, # 2 megs
86
- :timeout => 2 * 60, # 2 minutes
87
- :force_send => false,
88
- :send_environment_info => true,
89
- :start_channel_listener => false,
90
- :data_report_period => 60,
91
- :keep_retrying => true,
92
- :report_instance_busy => true,
93
-
94
- :log_file_name => 'newrelic_agent.log',
95
- :log_file_path => 'log/',
96
- :log_level => 'info',
97
-
98
- :'audit_log.enabled' => false,
99
- :'audit_log.path' => Proc.new {
100
- File.join(self[:log_file_path], 'newrelic_audit.log')
101
- },
102
-
103
- :disable_samplers => false,
104
- :disable_resque => false,
105
- :disable_dj => false,
106
- :disable_sinatra => false,
107
- :disable_sinatra_auto_middleware => false,
108
- :disable_view_instrumentation => false,
109
- :disable_backtrace_cleanup => false,
110
- :disable_harvest_thread => false,
111
- :skip_ar_instrumentation => false,
112
- :disable_activerecord_instrumentation => Proc.new { self[:skip_ar_instrumentation] },
113
- :disable_memcache_instrumentation => false,
114
- :disable_mobile_headers => true,
115
-
116
- :capture_params => false,
117
- :capture_memcache_keys => false,
118
- :textmate => false,
119
-
120
- :'transaction_tracer.enabled' => true,
121
- :'transaction_tracer.transaction_threshold' => Proc.new { self[:apdex_t] * 4 },
122
- :'transaction_tracer.stack_trace_threshold' => 0.5,
123
- :'transaction_tracer.explain_threshold' => 0.5,
124
- :'transaction_tracer.explain_enabled' => true,
125
- :'transaction_tracer.record_sql' => 'obfuscated',
126
- :'transaction_tracer.limit_segments' => 4000,
127
- :'transaction_tracer.random_sample' => false,
128
- :sample_rate => 10,
129
-
130
- :'slow_sql.enabled' => Proc.new { self[:'transaction_tracer.enabled'] },
131
- :'slow_sql.stack_trace_threshold' => Proc.new { self[:'transaction_tracer.stack_trace_threshold'] },
132
- :'slow_sql.explain_threshold' => Proc.new { self[:'transaction_tracer.explain_threshold'] },
133
- :'slow_sql.explain_enabled' => Proc.new { self[:'transaction_tracer.explain_enabled'] },
134
- :'slow_sql.record_sql' => Proc.new { self[:'transaction_tracer.record_sql'] },
135
-
136
- :'error_collector.enabled' => true,
137
- :'error_collector.capture_source' => true,
138
- :'error_collector.ignore_errors' => 'ActionController::RoutingError,Sinatra::NotFound',
139
-
140
- :'rum.enabled' => true,
141
- :'rum.jsonp' => true,
142
- :'rum.load_episodes_file' => true,
143
- :'browser_monitoring.auto_instrument' => Proc.new { self[:'rum.enabled'] },
144
-
145
- :trusted_account_ids => [],
146
- :"cross_application_tracer.enabled" => true,
147
-
148
- :'thread_profiler.enabled' => Proc.new { NewRelic::Agent::ThreadProfiler.is_supported? },
149
-
150
- :marshaller => Proc.new { NewRelic::Agent::NewRelicService::JsonMarshaller.is_supported? ? 'json' : 'pruby' },
151
-
152
- :'request_sampler.enabled' => true,
153
- :'request_sampler.sample_rate_ms' => 50
154
- ].freeze
155
- end
156
- end
157
- end
@@ -1,56 +0,0 @@
1
- # encoding: utf-8
2
- # This file is distributed under New Relic's license terms.
3
- # See https://github.com/newrelic/rpm/blob/master/LICENSE for complete details.
4
-
5
- module NewRelic
6
- module Agent
7
- module Instrumentation
8
- class BrowserMonitoringTimings
9
-
10
- def initialize(queue_time_in_seconds, transaction)
11
- @transaction = transaction
12
- @now = Time.now.to_i
13
- if @transaction.nil?
14
- @start_time_in_seconds = 0.0
15
- else
16
- @transaction_name = transaction.transaction.name
17
- @start_time_in_seconds = transaction.start_time.to_i
18
- end
19
-
20
- @queue_time_in_seconds = clamp_to_positive(queue_time_in_seconds)
21
- end
22
-
23
- attr_reader :transaction_name,
24
- :start_time_in_seconds, :queue_time_in_seconds
25
-
26
- def start_time_in_millis
27
- convert_to_milliseconds(@start_time_in_seconds)
28
- end
29
-
30
- def queue_time_in_millis
31
- convert_to_milliseconds(queue_time_in_seconds)
32
- end
33
-
34
- def app_time_in_millis
35
- convert_to_milliseconds(app_time_in_seconds)
36
- end
37
-
38
- def app_time_in_seconds
39
- @now - @start_time_in_seconds
40
- end
41
-
42
- private
43
-
44
- def convert_to_milliseconds(value_in_seconds)
45
- clamp_to_positive((value_in_seconds.to_f * 1000.0).round)
46
- end
47
-
48
- def clamp_to_positive(value)
49
- return 0.0 if value.nil? || value < 0
50
- value
51
- end
52
-
53
- end
54
- end
55
- end
56
- end
@@ -1,37 +0,0 @@
1
- # encoding: utf-8
2
- # This file is distributed under New Relic's license terms.
3
- # See https://github.com/newrelic/rpm/blob/master/LICENSE for complete details.
4
-
5
- module NewRelic
6
- module Agent
7
-
8
- class AgentThread < ::Thread
9
- def initialize(label)
10
- ::NewRelic::Agent.logger.debug("Creating New Relic thread: #{label}")
11
- self[:newrelic_label] = label
12
- super
13
- end
14
-
15
- def self.bucket_thread(thread, profile_agent_code)
16
- if thread.key?(:newrelic_label)
17
- return profile_agent_code ? :agent : :ignore
18
- elsif thread[:newrelic_transaction].respond_to?(:last) &&
19
- thread[:newrelic_transaction].last
20
- thread[:newrelic_transaction].last.request.nil? ? :background : :request
21
- else
22
- :other
23
- end
24
- end
25
-
26
- def self.scrub_backtrace(thread, profile_agent_code)
27
- begin
28
- bt = thread.backtrace
29
- rescue Exception => e
30
- ::NewRelic::Agent.logger.debug("Failed to backtrace #{thread.inspect}: #{e.class.name}: #{e.to_s}")
31
- end
32
- return nil unless bt
33
- profile_agent_code ? bt : bt.select { |t| t !~ /\/newrelic_rpm-\d/ }
34
- end
35
- end
36
- end
37
- end
@@ -1,323 +0,0 @@
1
- # encoding: utf-8
2
- # This file is distributed under New Relic's license terms.
3
- # See https://github.com/newrelic/rpm/blob/master/LICENSE for complete details.
4
-
5
- require 'new_relic/agent/thread'
6
- require 'new_relic/agent/worker_loop'
7
-
8
- module NewRelic
9
- module Agent
10
-
11
- class ThreadProfiler
12
-
13
- attr_reader :profile
14
-
15
- def self.is_supported?
16
- RUBY_VERSION >= "1.9.2"
17
- end
18
-
19
- def start(profile_id, duration, interval, profile_agent_code)
20
- if !ThreadProfiler.is_supported?
21
- ::NewRelic::Agent.logger.debug("Not starting thread profile as it isn't supported on this environment")
22
- @profile = nil
23
- else
24
- ::NewRelic::Agent.logger.debug("Starting thread profile. profile_id=#{profile_id}, duration=#{duration}")
25
- @profile = ThreadProfile.new(profile_id, duration, interval, profile_agent_code)
26
- @profile.run
27
- end
28
- end
29
-
30
- def stop(report_data)
31
- @profile.stop unless @profile.nil?
32
- @profile = nil if !report_data
33
- end
34
-
35
- def harvest
36
- profile = @profile
37
- @profile = nil
38
- profile
39
- end
40
-
41
- def respond_to_commands(commands, &notify_results)
42
- return if commands.empty? || commands.first.size < 2
43
-
44
- # Doesn't deal with multiple commands in the return set as
45
- # we currently only have start/stop of thread profiling
46
- command_id = commands.first[0]
47
- command = commands.first[1]
48
-
49
- name = command["name"]
50
- arguments = command["arguments"]
51
-
52
- if (ThreadProfiler.is_supported?)
53
- case name
54
- when "start_profiler"
55
- start_unless_running_and_notify(command_id, arguments, &notify_results)
56
-
57
- when "stop_profiler"
58
- stop_and_notify(command_id, arguments, &notify_results)
59
- end
60
- else
61
- msg = <<-EOF
62
- Thread profiling is only supported on 1.9.2 and greater versions of Ruby.
63
- We detected running agents capable of profiling, but the profile started with
64
- an agent running Ruby #{RUBY_VERSION}.
65
-
66
- Profiling again might select an appropriate agent, but we recommend running a
67
- consistent version of Ruby across your application for better results.
68
- EOF
69
- ::NewRelic::Agent.logger.debug(msg)
70
- notify_results.call(command_id, msg) if !notify_results.nil?
71
- end
72
- end
73
-
74
- def running?
75
- !@profile.nil?
76
- end
77
-
78
- def finished?
79
- @profile && @profile.finished?
80
- end
81
-
82
- private
83
-
84
- def start_unless_running_and_notify(command_id, arguments)
85
- profile_id = arguments.fetch("profile_id", -1)
86
- duration = arguments.fetch("duration", 120)
87
- interval = arguments.fetch("sample_period", 0.1)
88
- profile_agent_code = arguments.fetch("profile_agent_code", true)
89
-
90
- if running?
91
- msg = "Profile already in progress. Ignoring agent command to start another."
92
- ::NewRelic::Agent.logger.debug(msg)
93
- yield(command_id, msg) if block_given?
94
- else
95
- start(profile_id, duration, interval, profile_agent_code)
96
- yield(command_id) if block_given?
97
- end
98
- end
99
-
100
- def stop_and_notify(command_id, arguments)
101
- report_data = arguments.fetch("report_data", true)
102
- stop(report_data)
103
- yield(command_id) if block_given?
104
- end
105
-
106
- end
107
-
108
- class ThreadProfile
109
-
110
- attr_reader :profile_id,
111
- :traces,
112
- :profile_agent_code, :interval,
113
- :poll_count, :sample_count,
114
- :start_time, :stop_time
115
-
116
- def initialize(profile_id, duration, interval, profile_agent_code)
117
- @profile_id = profile_id
118
- @profile_agent_code = profile_agent_code
119
-
120
- @worker_loop = NewRelic::Agent::WorkerLoop.new(:duration => duration)
121
- @interval = interval
122
- @finished = false
123
-
124
- @traces = {
125
- :agent => [],
126
- :background => [],
127
- :other => [],
128
- :request => []
129
- }
130
- @flattened_nodes = []
131
-
132
- @poll_count = 0
133
- @sample_count = 0
134
- @failure_count = 0
135
- end
136
-
137
- def run
138
- AgentThread.new('Thread Profiler') do
139
- @start_time = now_in_millis
140
-
141
- @worker_loop.run(@interval) do
142
- NewRelic::Agent.instance.stats_engine.
143
- record_supportability_metric_timed("ThreadProfiler/PollingTime") do
144
-
145
- @poll_count += 1
146
- AgentThread.list.each do |t|
147
- bucket = AgentThread.bucket_thread(t, @profile_agent_code)
148
- if bucket != :ignore
149
- backtrace = AgentThread.scrub_backtrace(t, @profile_agent_code)
150
- if backtrace.nil?
151
- @failure_count += 1
152
- else
153
- @sample_count += 1
154
- aggregate(backtrace, @traces[bucket])
155
- end
156
- end
157
- end
158
- end
159
- end
160
-
161
- mark_done
162
- ::NewRelic::Agent.logger.debug("Finished thread profile. #{@sample_count} backtraces, #{@failure_count} failures. Will send with next harvest.")
163
- NewRelic::Agent.instance.stats_engine.
164
- record_supportability_metric_count("ThreadProfiler/BacktraceFailures", @failure_count)
165
- end
166
- end
167
-
168
- def stop
169
- @worker_loop.stop
170
- mark_done
171
- ::NewRelic::Agent.logger.debug("Stopping thread profile.")
172
- end
173
-
174
- def aggregate(trace, trees=@traces[:request], parent=nil)
175
- return nil if trace.nil? || trace.empty?
176
- node = Node.new(trace.last)
177
- existing = trees.find {|n| n == node}
178
-
179
- if existing.nil?
180
- existing = node
181
- @flattened_nodes << node
182
- end
183
-
184
- if parent
185
- parent.add_child(node)
186
- else
187
- trees << node unless trees.include? node
188
- end
189
-
190
- existing.runnable_count += 1
191
- aggregate(trace[0..-2], existing.children, existing)
192
-
193
- existing
194
- end
195
-
196
- def prune!(count_to_keep)
197
- @flattened_nodes.sort!(&:order_for_pruning)
198
-
199
- NewRelic::Agent.instance.stats_engine.
200
- record_supportability_metric_count("ThreadProfiler/NodeCount", @flattened_nodes.size)
201
-
202
- mark_for_pruning(@flattened_nodes, count_to_keep)
203
-
204
- traces.each { |_, nodes| Node.prune!(nodes) }
205
- end
206
-
207
- THREAD_PROFILER_NODES = 20_000
208
-
209
- include NewRelic::Coerce
210
-
211
- def to_collector_array(encoder)
212
- prune!(THREAD_PROFILER_NODES)
213
-
214
- traces = {
215
- "OTHER" => @traces[:other].map{|t| t.to_array },
216
- "REQUEST" => @traces[:request].map{|t| t.to_array },
217
- "AGENT" => @traces[:agent].map{|t| t.to_array },
218
- "BACKGROUND" => @traces[:background].map{|t| t.to_array }
219
- }
220
-
221
- [[
222
- int(@profile_id),
223
- float(@start_time),
224
- float(@stop_time),
225
- int(@poll_count),
226
- string(encoder.encode(traces)),
227
- int(@sample_count),
228
- 0
229
- ]]
230
- end
231
-
232
- def now_in_millis
233
- Time.now.to_f * 1_000
234
- end
235
-
236
- def finished?
237
- @finished
238
- end
239
-
240
- def mark_done
241
- @finished = true
242
- @stop_time = now_in_millis
243
- end
244
-
245
- def mark_for_pruning(nodes, count_to_keep)
246
- to_prune = nodes[count_to_keep..-1] || []
247
- to_prune.each { |n| n.to_prune = true }
248
- end
249
-
250
- def self.flattened_nodes(nodes)
251
- nodes.map { |n| [n, flattened_nodes(n.children)] }.flatten
252
- end
253
-
254
- def self.parse_backtrace(trace)
255
- trace.map do |line|
256
- line =~ /(.*)\:(\d+)\:in `(.*)'/
257
- { :method => $3, :line_no => $2.to_i, :file => $1 }
258
- end
259
- end
260
-
261
- class Node
262
- attr_reader :file, :method, :line_no, :children
263
- attr_accessor :runnable_count, :to_prune, :depth
264
-
265
- def initialize(line, parent=nil)
266
- line =~ /(.*)\:(\d+)\:in `(.*)'/
267
- @file = $1
268
- @method = $3
269
- @line_no = $2.to_i
270
- @children = []
271
- @runnable_count = 0
272
- @to_prune = false
273
- @depth = 0
274
-
275
- parent.add_child(self) if parent
276
- end
277
-
278
- def ==(other)
279
- @file == other.file &&
280
- @method == other.method &&
281
- @line_no == other.line_no
282
- end
283
-
284
- def total_count
285
- @runnable_count
286
- end
287
-
288
- # Descending order on count, ascending on depth of nodes
289
- def order_for_pruning(y)
290
- [-runnable_count, depth] <=> [-y.runnable_count, y.depth]
291
- end
292
-
293
- include NewRelic::Coerce
294
-
295
- def to_array
296
- [[
297
- string(@file),
298
- string(@method),
299
- int(@line_no)
300
- ],
301
- int(@runnable_count),
302
- 0,
303
- @children.map {|c| c.to_array}]
304
- end
305
-
306
- def add_child(child)
307
- child.depth = @depth + 1
308
- @children << child unless @children.include? child
309
- end
310
-
311
- def prune!
312
- Node.prune!(@children)
313
- end
314
-
315
- def self.prune!(kids)
316
- kids.delete_if { |child| child.to_prune }
317
- kids.each { |child| child.prune! }
318
- end
319
- end
320
-
321
- end
322
- end
323
- end