Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge branch 'master' of git@github.com:redinger/enki

Conflicts:
	config/.gitignore
	vendor/plugins/rpm/Rakefile
	vendor/plugins/rpm/init.rb
	vendor/plugins/rpm/lib/new_relic/agent.rb
	vendor/plugins/rpm/lib/new_relic/agent/agent.rb
	vendor/plugins/rpm/lib/new_relic/agent/collection_helper.rb
	vendor/plugins/rpm/lib/new_relic/agent/error_collector.rb
	vendor/plugins/rpm/lib/new_relic/agent/instrumentation/active_record_instrumentation.rb
	vendor/plugins/rpm/lib/new_relic/agent/instrumentation/controller_instrumentation.rb
	vendor/plugins/rpm/lib/new_relic/agent/instrumentation/dispatcher_instrumentation.rb
	vendor/plugins/rpm/lib/new_relic/agent/instrumentation/merb/dispatcher.rb
	vendor/plugins/rpm/lib/new_relic/agent/instrumentation/merb/errors.rb
	vendor/plugins/rpm/lib/new_relic/agent/instrumentation/rails/action_controller.rb
	vendor/plugins/rpm/lib/new_relic/agent/instrumentation/rails/dispatcher.rb
	vendor/plugins/rpm/lib/new_relic/agent/instrumentation/rails/errors.rb
	vendor/plugins/rpm/lib/new_relic/agent/method_tracer.rb
	vendor/plugins/rpm/lib/new_relic/agent/patch_const_missing.rb
	vendor/plugins/rpm/lib/new_relic/agent/stats_engine.rb
	vendor/plugins/rpm/lib/new_relic/agent/transaction_sampler.rb
	vendor/plugins/rpm/lib/new_relic/agent/worker_loop.rb
	vendor/plugins/rpm/lib/new_relic/commands/deployments.rb
	vendor/plugins/rpm/lib/new_relic/control/ruby.rb
	vendor/plugins/rpm/lib/new_relic/local_environment.rb
	vendor/plugins/rpm/lib/new_relic/noticed_error.rb
	vendor/plugins/rpm/lib/new_relic/recipes.rb
	vendor/plugins/rpm/lib/new_relic/stats.rb
	vendor/plugins/rpm/lib/new_relic/transaction_analysis.rb
	vendor/plugins/rpm/lib/new_relic/transaction_sample.rb
	vendor/plugins/rpm/lib/new_relic/version.rb
	vendor/plugins/rpm/lib/new_relic_api.rb
	vendor/plugins/rpm/lib/newrelic_rpm.rb
	vendor/plugins/rpm/newrelic.yml
	vendor/plugins/rpm/newrelic_rpm.gemspec
	vendor/plugins/rpm/test/config/newrelic.yml
	vendor/plugins/rpm/test/new_relic/agent/agent_test_controller.rb
	vendor/plugins/rpm/test/new_relic/agent/collection_helper_test.rb
	vendor/plugins/rpm/test/new_relic/agent/controller_test.rb
	vendor/plugins/rpm/test/new_relic/agent/transaction_sample_test.rb
	vendor/plugins/rpm/test/new_relic/agent/worker_loop_test.rb
	vendor/plugins/rpm/test/new_relic/metric_spec_test.rb
	vendor/plugins/rpm/test/test_helper.rb
	vendor/plugins/rpm/test/ui/newrelic_helper_test.rb
	vendor/plugins/rpm/ui/controllers/newrelic_controller.rb
	vendor/plugins/rpm/ui/helpers/newrelic_helper.rb
	vendor/plugins/rpm/ui/views/layouts/newrelic_default.rhtml
	vendor/plugins/rpm/ui/views/newrelic/_sample.rhtml
	vendor/plugins/rpm/ui/views/newrelic/_segment.rhtml
	vendor/plugins/rpm/ui/views/newrelic/_segment_row.rhtml
	vendor/plugins/rpm/ui/views/newrelic/_show_sample_detail.rhtml
	vendor/plugins/rpm/ui/views/newrelic/_show_sample_sql.rhtml
	vendor/plugins/rpm/ui/views/newrelic/explain_sql.rhtml
	vendor/plugins/rpm/ui/views/newrelic/index.rhtml
	vendor/plugins/rpm/ui/views/newrelic/show_sample.rhtml
	vendor/plugins/rpm/ui/views/newrelic/stylesheets/style.css
  • Loading branch information...
commit 31ef043e415ca75d77f5cfe450debf19167038ec 2 parents c5b4c96 + 5e29f7f
root authored
Showing with 12,796 additions and 4,378 deletions.
  1. +4 −0 config/.gitignore
  2. +0 −37 vendor/plugins/newrelic_rpm/LICENSE
  3. +0 −136 vendor/plugins/newrelic_rpm/README
  4. +0 −4 vendor/plugins/newrelic_rpm/bin/newrelic_cmd
  5. +0 −30 vendor/plugins/newrelic_rpm/init.rb
  6. +0 −37 vendor/plugins/newrelic_rpm/install.rb
  7. +0 −29 vendor/plugins/newrelic_rpm/lib/new_relic/agent.rb
  8. +0 −13 vendor/plugins/newrelic_rpm/lib/new_relic/agent/chained_call.rb
  9. +0 −18 vendor/plugins/newrelic_rpm/lib/new_relic/agent/instrumentation/active_merchant.rb
  10. +0 −95 vendor/plugins/newrelic_rpm/lib/new_relic/agent/instrumentation/active_record_instrumentation.rb
  11. +0 −90 vendor/plugins/newrelic_rpm/lib/new_relic/agent/instrumentation/data_mapper.rb
  12. +0 −105 vendor/plugins/newrelic_rpm/lib/new_relic/agent/instrumentation/dispatcher_instrumentation.rb
  13. +0 −18 vendor/plugins/newrelic_rpm/lib/new_relic/agent/instrumentation/memcache.rb
  14. +0 −17 vendor/plugins/newrelic_rpm/lib/new_relic/agent/instrumentation/merb/controller.rb
  15. +0 −27 vendor/plugins/newrelic_rpm/lib/new_relic/agent/instrumentation/rails/action_web_service.rb
  16. +0 −30 vendor/plugins/newrelic_rpm/lib/new_relic/agent/instrumentation/rails/dispatcher.rb
  17. +0 −6 vendor/plugins/newrelic_rpm/lib/new_relic/agent/instrumentation/rails/rails.rb
  18. +0 −171 vendor/plugins/newrelic_rpm/lib/new_relic/agent/method_tracer.rb
  19. +0 −29 vendor/plugins/newrelic_rpm/lib/new_relic/agent/samplers/cpu.rb
  20. +0 −55 vendor/plugins/newrelic_rpm/lib/new_relic/agent/samplers/memory.rb
  21. +0 −26 vendor/plugins/newrelic_rpm/lib/new_relic/agent/samplers/mongrel.rb
  22. +0 −40 vendor/plugins/newrelic_rpm/lib/new_relic/agent/synchronize.rb
  23. +0 −30 vendor/plugins/newrelic_rpm/lib/new_relic/commands/new_relic_commands.rb
  24. +0 −278 vendor/plugins/newrelic_rpm/lib/new_relic/config.rb
  25. +0 −35 vendor/plugins/newrelic_rpm/lib/new_relic/config/merb.rb
  26. +0 −119 vendor/plugins/newrelic_rpm/lib/new_relic/config/rails.rb
  27. +0 −135 vendor/plugins/newrelic_rpm/lib/new_relic/local_environment.rb
  28. +0 −6 vendor/plugins/newrelic_rpm/lib/new_relic/merbtasks.rb
  29. +0 −26 vendor/plugins/newrelic_rpm/lib/new_relic/metric_data.rb
  30. +0 −39 vendor/plugins/newrelic_rpm/lib/new_relic/metric_spec.rb
  31. +0 −7 vendor/plugins/newrelic_rpm/lib/new_relic/metrics.rb
  32. +0 −95 vendor/plugins/newrelic_rpm/lib/new_relic/shim_agent.rb
  33. +0 −27 vendor/plugins/newrelic_rpm/lib/newrelic_rpm.rb
  34. +0 −17 vendor/plugins/newrelic_rpm/lib/tasks/agent_tests.rake
  35. +0 −4 vendor/plugins/newrelic_rpm/lib/tasks/all.rb
  36. +0 −7 vendor/plugins/newrelic_rpm/lib/tasks/install.rake
  37. +0 −9 vendor/plugins/newrelic_rpm/newrelic_spec.rb
  38. +0 −6 vendor/plugins/newrelic_rpm/recipes/newrelic.rb
  39. +0 −1  vendor/plugins/newrelic_rpm/spec_helper.rb
  40. +0 −40 vendor/plugins/newrelic_rpm/test/new_relic/agent/mock_ar_connection.rb
  41. +0 −23 vendor/plugins/newrelic_rpm/test/new_relic/agent/mock_scope_listener.rb
  42. +0 −15 vendor/plugins/newrelic_rpm/test/new_relic/agent/model_fixture.rb
  43. +0 −90 vendor/plugins/newrelic_rpm/test/new_relic/agent/tc_active_record.rb
  44. +0 −148 vendor/plugins/newrelic_rpm/test/new_relic/agent/tc_agent.rb
  45. +0 −52 vendor/plugins/newrelic_rpm/test/new_relic/agent/tc_dispatcher_instrumentation.rb
  46. +0 −127 vendor/plugins/newrelic_rpm/test/new_relic/agent/tc_error_collector.rb
  47. +0 −218 vendor/plugins/newrelic_rpm/test/new_relic/agent/tc_stats_engine.rb
  48. +0 −37 vendor/plugins/newrelic_rpm/test/new_relic/agent/tc_synchronize.rb
  49. +0 −302 vendor/plugins/newrelic_rpm/test/new_relic/agent/tc_transaction_sampler.rb
  50. +0 −13 vendor/plugins/newrelic_rpm/test/new_relic/agent/testable_agent.rb
  51. +0 −36 vendor/plugins/newrelic_rpm/test/new_relic/tc_config.rb
  52. +0 −94 vendor/plugins/newrelic_rpm/test/new_relic/tc_environment.rb
  53. +0 −141 vendor/plugins/newrelic_rpm/test/new_relic/tc_stats.rb
  54. +0 −55 vendor/plugins/newrelic_rpm/ui/helpers/google_pie_chart.rb
  55. +0 −27 vendor/plugins/newrelic_rpm/ui/views/newrelic/_explain_plans.rhtml
  56. +0 −14 vendor/plugins/newrelic_rpm/ui/views/newrelic/_segment_row.rhtml
  57. +0 −3  vendor/plugins/newrelic_rpm/ui/views/newrelic/_show_sample_summary.rhtml
  58. +0 −11 vendor/plugins/newrelic_rpm/ui/views/newrelic/_sql_row.rhtml
  59. +0 −30 vendor/plugins/newrelic_rpm/ui/views/newrelic/_stack_trace.rhtml
  60. +0 −12 vendor/plugins/newrelic_rpm/ui/views/newrelic/_table.rhtml
  61. BIN  vendor/plugins/newrelic_rpm/ui/views/newrelic/images/arrow-close.png
  62. BIN  vendor/plugins/newrelic_rpm/ui/views/newrelic/images/arrow-open.png
  63. BIN  vendor/plugins/newrelic_rpm/ui/views/newrelic/images/blue_bar.gif
  64. BIN  vendor/plugins/newrelic_rpm/ui/views/newrelic/images/gray_bar.gif
  65. +0 −107 vendor/plugins/newrelic_rpm/ui/views/newrelic/javascript/transaction_sample.js
  66. +0 −2  vendor/plugins/newrelic_rpm/ui/views/newrelic/sample_not_found.rhtml
  67. +0 −3  vendor/plugins/newrelic_rpm/ui/views/newrelic/show_source.rhtml
  68. +85 −29 vendor/plugins/{newrelic_rpm/lib/new_relic/version.rb → rpm/CHANGELOG}
  69. +3 −3 vendor/plugins/{newrelic_rpm → rpm}/Rakefile
  70. +33 −0 vendor/plugins/rpm/bin/mongrel_rpm
  71. +34 −0 vendor/plugins/rpm/cert/cacert.pem
  72. +38 −0 vendor/plugins/rpm/init.rb
  73. +201 −0 vendor/plugins/rpm/lib/new_relic/agent.rb
  74. +157 −341 vendor/plugins/{newrelic_rpm → rpm}/lib/new_relic/agent/agent.rb
  75. +11 −24 vendor/plugins/{newrelic_rpm → rpm}/lib/new_relic/agent/collection_helper.rb
  76. +29 −15 vendor/plugins/{newrelic_rpm → rpm}/lib/new_relic/agent/error_collector.rb
  77. +82 −0 vendor/plugins/rpm/lib/new_relic/agent/instrumentation/active_record_instrumentation.rb
  78. +56 −30 vendor/plugins/{newrelic_rpm → rpm}/lib/new_relic/agent/instrumentation/controller_instrumentation.rb
  79. +130 −0 vendor/plugins/rpm/lib/new_relic/agent/instrumentation/dispatcher_instrumentation.rb
  80. +5 −7 vendor/plugins/{newrelic_rpm → rpm}/lib/new_relic/agent/instrumentation/merb/dispatcher.rb
  81. +1 −1  vendor/plugins/{newrelic_rpm → rpm}/lib/new_relic/agent/instrumentation/merb/errors.rb
  82. +29 −3 vendor/plugins/{newrelic_rpm → rpm}/lib/new_relic/agent/instrumentation/rails/action_controller.rb
  83. +38 −0 vendor/plugins/rpm/lib/new_relic/agent/instrumentation/rails/dispatcher.rb
  84. +2 −3 vendor/plugins/{newrelic_rpm → rpm}/lib/new_relic/agent/instrumentation/rails/errors.rb
  85. +191 −0 vendor/plugins/rpm/lib/new_relic/agent/method_tracer.rb
  86. +46 −26 vendor/plugins/{newrelic_rpm → rpm}/lib/new_relic/agent/patch_const_missing.rb
  87. +12 −0 vendor/plugins/rpm/lib/new_relic/agent/sampler.rb
  88. +42 −0 vendor/plugins/rpm/lib/new_relic/agent/samplers/cpu_sampler.rb
  89. +126 −0 vendor/plugins/rpm/lib/new_relic/agent/samplers/memory_sampler.rb
  90. +22 −0 vendor/plugins/rpm/lib/new_relic/agent/samplers/mongrel_sampler.rb
  91. +11 −0 vendor/plugins/rpm/lib/new_relic/agent/shim_agent.rb
  92. +85 −45 vendor/plugins/{newrelic_rpm → rpm}/lib/new_relic/agent/stats_engine.rb
  93. +72 −38 vendor/plugins/{newrelic_rpm → rpm}/lib/new_relic/agent/transaction_sampler.rb
  94. +8 −18 vendor/plugins/{newrelic_rpm → rpm}/lib/new_relic/agent/worker_loop.rb
  95. +9 −9 vendor/plugins/{newrelic_rpm → rpm}/lib/new_relic/commands/deployments.rb
  96. +388 −0 vendor/plugins/rpm/lib/new_relic/control.rb
  97. +27 −0 vendor/plugins/rpm/lib/new_relic/control/merb.rb
  98. +139 −0 vendor/plugins/rpm/lib/new_relic/control/rails.rb
  99. +9 −2 vendor/plugins/{newrelic_rpm/lib/new_relic/config → rpm/lib/new_relic/control}/ruby.rb
  100. +259 −0 vendor/plugins/rpm/lib/new_relic/local_environment.rb
  101. +102 −0 vendor/plugins/rpm/lib/new_relic/metric_parser.rb
  102. +25 −0 vendor/plugins/rpm/lib/new_relic/metric_parser/active_merchant.rb
  103. +11 −0 vendor/plugins/rpm/lib/new_relic/metric_parser/active_record.rb
  104. +51 −0 vendor/plugins/rpm/lib/new_relic/metric_parser/controller.rb
  105. +38 −0 vendor/plugins/rpm/lib/new_relic/metric_parser/controller_cpu.rb
  106. +23 −0 vendor/plugins/rpm/lib/new_relic/metric_parser/database.rb
  107. +6 −0 vendor/plugins/rpm/lib/new_relic/metric_parser/errors.rb
  108. +12 −0 vendor/plugins/rpm/lib/new_relic/metric_parser/mem_cache.rb
  109. +61 −0 vendor/plugins/rpm/lib/new_relic/metric_parser/view.rb
  110. +9 −0 vendor/plugins/rpm/lib/new_relic/metric_parser/web_service.rb
  111. +5 −1 vendor/plugins/{newrelic_rpm → rpm}/lib/new_relic/noticed_error.rb
  112. +5 −0 vendor/plugins/rpm/lib/new_relic/rack.rb
  113. +57 −0 vendor/plugins/rpm/lib/new_relic/rack/metric_app.rb
  114. +25 −0 vendor/plugins/rpm/lib/new_relic/rack/newrelic.ru
  115. +25 −0 vendor/plugins/rpm/lib/new_relic/rack/newrelic.yml
  116. +10 −3 vendor/plugins/{newrelic_rpm → rpm}/lib/new_relic/recipes.rb
  117. +113 −139 vendor/plugins/{newrelic_rpm → rpm}/lib/new_relic/stats.rb
  118. +7 −8 vendor/plugins/{newrelic_rpm → rpm}/lib/new_relic/transaction_analysis.rb
  119. +87 −11 vendor/plugins/{newrelic_rpm → rpm}/lib/new_relic/transaction_sample.rb
  120. +46 −0 vendor/plugins/rpm/lib/new_relic/version.rb
  121. +7 −6 vendor/plugins/{newrelic_rpm → rpm}/lib/new_relic_api.rb
  122. +30 −0 vendor/plugins/rpm/lib/newrelic_rpm.rb
  123. +13 −0 vendor/plugins/rpm/lib/tasks/tests.rake
  124. +33 −12 vendor/plugins/{newrelic_rpm → rpm}/newrelic.yml
  125. +32 −0 vendor/plugins/rpm/newrelic_rpm.gemspec
  126. +55 −0 vendor/plugins/rpm/test/active_record_fixtures.rb
  127. +16 −2 vendor/plugins/{newrelic_rpm → rpm}/test/config/newrelic.yml
  128. +14 −10 vendor/plugins/{newrelic_rpm/test/config/test_config.rb → rpm/test/config/test_control.rb}
  129. +187 −0 vendor/plugins/rpm/test/new_relic/agent/active_record_instrumentation_test.rb
  130. +104 −0 vendor/plugins/rpm/test/new_relic/agent/agent_test.rb
  131. +8 −0 vendor/plugins/{newrelic_rpm → rpm}/test/new_relic/agent/agent_test_controller.rb
  132. +56 −0 vendor/plugins/rpm/test/new_relic/agent/classloader_patch_test.rb
  133. +28 −23 ...rpm/test/new_relic/agent/tc_collection_helper.rb → rpm/test/new_relic/agent/collection_helper_test.rb}
  134. +12 −11 ...ins/{newrelic_rpm/test/new_relic/agent/tc_controller.rb → rpm/test/new_relic/agent/controller_test.rb}
  135. +70 −0 vendor/plugins/rpm/test/new_relic/agent/dispatcher_instrumentation_test.rb
  136. +155 −0 vendor/plugins/rpm/test/new_relic/agent/error_collector_test.rb
  137. +6 −12 ...ewrelic_rpm/test/new_relic/agent/tc_method_tracer.rb → rpm/test/new_relic/agent/method_tracer_test.rb}
  138. +260 −0 vendor/plugins/rpm/test/new_relic/agent/stats_engine_test.rb
  139. +2 −2 .../agent/tc_transaction_sample_builder.rb → rpm/test/new_relic/agent/transaction_sample_builder_test.rb}
  140. +9 −13 ...m/test/new_relic/agent/tc_transaction_sample.rb → rpm/test/new_relic/agent/transaction_sample_test.rb}
  141. +317 −0 vendor/plugins/rpm/test/new_relic/agent/transaction_sampler_test.rb
  142. +1 −1  ...s/{newrelic_rpm/test/new_relic/agent/tc_worker_loop.rb → rpm/test/new_relic/agent/worker_loop_test.rb}
  143. +75 −0 vendor/plugins/rpm/test/new_relic/control_test.rb
  144. +8 −4 ...ugins/{newrelic_rpm/test/new_relic/tc_deployments_api.rb → rpm/test/new_relic/deployments_api_test.rb}
  145. +75 −0 vendor/plugins/rpm/test/new_relic/environment_test.rb
  146. +166 −0 vendor/plugins/rpm/test/new_relic/metric_parser_test.rb
  147. +28 −1 vendor/plugins/{newrelic_rpm/test/new_relic/tc_metric_spec.rb → rpm/test/new_relic/metric_spec_test.rb}
  148. +69 −0 vendor/plugins/rpm/test/new_relic/samplers_test.rb
  149. +1 −1  vendor/plugins/{newrelic_rpm/test/new_relic/tc_shim_agent.rb → rpm/test/new_relic/shim_agent_test.rb}
  150. +291 −0 vendor/plugins/rpm/test/new_relic/stats_test.rb
  151. +38 −0 vendor/plugins/rpm/test/new_relic/version_number_test.rb
  152. +4 −11 vendor/plugins/{newrelic_rpm → rpm}/test/test_helper.rb
  153. +14 −0 vendor/plugins/rpm/test/ui/newrelic_controller_test.rb
  154. +16 −7 vendor/plugins/{newrelic_rpm/test/ui/tc_newrelic_helper.rb → rpm/test/ui/newrelic_helper_test.rb}
  155. +16 −6 vendor/plugins/{newrelic_rpm → rpm}/ui/controllers/newrelic_controller.rb
  156. +44 −15 vendor/plugins/{newrelic_rpm → rpm}/ui/helpers/newrelic_helper.rb
  157. +5 −7 vendor/plugins/{newrelic_rpm → rpm}/ui/views/layouts/newrelic_default.rhtml
  158. +5 −2 vendor/plugins/{newrelic_rpm → rpm}/ui/views/newrelic/_sample.rhtml
  159. +1 −1  vendor/plugins/{newrelic_rpm → rpm}/ui/views/newrelic/_segment.rhtml
  160. +1 −0  vendor/plugins/rpm/ui/views/newrelic/_segment_limit_message.rhtml
  161. +14 −0 vendor/plugins/rpm/ui/views/newrelic/_segment_row.rhtml
  162. +3 −1 vendor/plugins/{newrelic_rpm → rpm}/ui/views/newrelic/_show_sample_detail.rhtml
  163. +2 −1  vendor/plugins/{newrelic_rpm → rpm}/ui/views/newrelic/_show_sample_sql.rhtml
  164. +2 −5 vendor/plugins/{newrelic_rpm → rpm}/ui/views/newrelic/explain_sql.rhtml
  165. BIN  vendor/plugins/rpm/ui/views/newrelic/images/file_icon.png
  166. BIN  vendor/plugins/rpm/ui/views/newrelic/images/new_relic_rpm_desktop.gif
  167. +21 −13 vendor/plugins/{newrelic_rpm → rpm}/ui/views/newrelic/index.rhtml
  168. +7,288 −0 vendor/plugins/rpm/ui/views/newrelic/javascript/prototype-scriptaculous.js
  169. +1 −1  vendor/plugins/{newrelic_rpm → rpm}/ui/views/newrelic/show_sample.rhtml
  170. +39 −0 vendor/plugins/{newrelic_rpm → rpm}/ui/views/newrelic/stylesheets/style.css
  171. +52 −0 vendor/plugins/rpm/ui/views/newrelic/threads.rhtml
View
4 config/.gitignore
@@ -1,3 +1,7 @@
database.yml
defensio.yml
+<<<<<<< HEAD:config/.gitignore
newrelic.yml
+=======
+newrelic.yml
+>>>>>>> 5e29f7f21b667ccc8f30e0e679fbe8f4033f38d5:config/.gitignore
View
37 vendor/plugins/newrelic_rpm/LICENSE
@@ -1,37 +0,0 @@
-Copyright (c) 2008 New Relic, Inc. All rights reserved.
-
-Certain inventions disclosed in this file may be claimed within
-patents owned or patent applications filed by New Relic, Inc. or third
-parties.
-
-Subject to the terms of this notice, New Relic grants you a
-nonexclusive, nontransferable license, without the right to
-sublicense, to (a) install and execute one copy of these files on any
-number of workstations owned or controlled by you and (b) distribute
-verbatim copies of these files to third parties. As a condition to the
-foregoing grant, you must provide this notice along with each copy you
-distribute and you must not remove, alter, or obscure this notice. All
-other use, reproduction, modification, distribution, or other
-exploitation of these files is strictly prohibited, except as may be set
-forth in a separate written license agreement between you and New
-Relic. The terms of any such license agreement will control over this
-notice. The license stated above will be automatically terminated and
-revoked if you exceed its scope or violate any of the terms of this
-notice.
-
-This License does not grant permission to use the trade names,
-trademarks, service marks, or product names of New Relic, except as
-required for reasonable and customary use in describing the origin of
-this file and reproducing the content of this notice. You may not
-mark or brand this file with any trade name, trademarks, service
-marks, or product names other than the original brand (if any)
-provided by New Relic.
-
-Unless otherwise expressly agreed by New Relic in a separate written
-license agreement, these files are provided AS IS, WITHOUT WARRANTY OF
-ANY KIND, including without any implied warranties of MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE, TITLE, or NON-INFRINGEMENT. As a
-condition to your use of these files, you are solely responsible for
-such use. New Relic will have no liability to you for direct,
-indirect, consequential, incidental, special, or punitive damages or
-for lost profits or data.
View
136 vendor/plugins/newrelic_rpm/README
@@ -1,136 +0,0 @@
-= New Relic RPM
-
-* http://www.newrelic.com
-
-New Relic RPM is a Ruby performance management system, developed by
-New Relic, Inc. RPM provides you with deep information about the
-performance of your Ruby on Rails or Merb application as it runs in
-production. The New Relic Agent is distributed as a either a Rails
-plugin or a Gem, both hosted on RubyForge.
-
-The New Relic Agent runs in one of two modes:
-
-* Developer Mode : Adds a web interface mapped to /newrelic to your
- application for showing detailed performance metrics on a page by
- page basis.
-
-* Production Mode : Low overhead instrumentation that captures
- detailed information on your application running in production and
- transmits them to rpm.newrelic.com where you can monitor them in
- real time.
-
-=== Developer Mode
-
-Developer mode is on by default when you run your application in the
-development environment (but not when it runs in other environments.)
-When running in developer mode, RPM will track the performance of
-every http request serviced by your application, and store in memory
-this information for the last 100 http transactions.
-
-When running in Developer Mode, the RPM will also add a few pages to
-your application that allow you to analyze this performance
-information. (Don't worry - those pages are not added to your
-application's routes when you run in production mode.)
-
-To view this performance information, including detailed SQL statement
-analysis, open '/newrelic' in your web application. For instance if
-you are running mongrel or thin on port 3000, enter the following into
-your browser:
-
-http://localhost:3000/newrelic
-
-=== Production Mode
-
-To monitor your applications in production, create an account at
-http://newrelic.com/get-RPM.html
-
-When your application runs in the production environment, the New
-Relic agent runs in production mode. It connects to the New Relic RPM
-service and sends deep performance data to the RPM service for your
-analysis. To view this data, login to http://rpm.newrelic.com.
-
-NOTE: You must have a valid account and license key to view this data
-online. When you sign up for an account at www.newrelic.com, you will
-be provided with a license key, as well as a default configuration
-file for New Relic RPM. You can either paste your license key into
-your existing configuration file, config/newrelic.yml, or you can
-replace that config file with the one included in your welcome email.
-
-== Installation
-
-RPM requires an agent be installed in the application as either a
-Rails plug-in or a gem. Both are available on RubyForge--instructions
-below.
-
-=== Git your RPM on!
-
-The agent is also available on Github under newrelic/rpm. As of March,
-2009, we keep the latest release on the master, the edge on a working
-branch, and previous releases with tags. Fork away!
-
-=== Requirements:
-
-Ruby 1.8.6
-Rails 1.2.6 or above
-Merb 1.0 or above
-
-=== Rails Plug-In Installation
-
- script/plugin install http://newrelic.rubyforge.org/svn/newrelic_rpm
-
-=== Gem Installation
-
- sudo gem install newrelic_rpm
-
-For Rails, edit environment.rb and add to the initalizer block:
-
- config.gem "newrelic_rpm"
-
-The Developer Mode is unavailable when using the gem on Rails versions
-prior to 2.0.
-
-== Merb Support
-
-To monitor a merb app install the newrelic_rpm gem and add
-
- dependency 'newrelic_rpm'
-
-to your init.rb file.
-
-Current features implemented:
-
- * Standard monitoring, overview pages
- * Error capturing
- * Full Active Record instrumentation, including SQL explains
- * Very limited Data Mapper instrumentation
- * Transaction Traces are implemented but will not be very useful
- with Data Mapper until more work is done with the Data Mapper
- instrumentation
-
-Still under development:
-
- * Developer Mode
- * Data Mapper bindings
-
-Also some of the instrumentation has been implemented with method
-chaining, a mechanism that truly goes against the merb way. This was
-necessary in some cases where the API’s were not yet available or
-understood well enough to use. Converting these to hook methods using
-the Merb public API is a work in progress.
-
-== Support
-
-Reach out to us--and to fellow RPM users--at
-http://support.newrelic.com. There you'll find documentation, FAQs,
-and forums where you can submit suggestions and discuss RPM with New
-Relic staff and other users.
-
-Find a bug? E-mail support@newrelic.com, or post it to
-support.newrelic.com.
-
-For other support channels, see http://www.newrelic.com/support.
-
-Thank you, and may your application scale to infinity plus one.
-
-Lew Cirne, Founder and CEO
-New Relic, Inc.
View
4 vendor/plugins/newrelic_rpm/bin/newrelic_cmd
@@ -1,4 +0,0 @@
-#!/usr/bin/env ruby
-# executes one of the commands in the new_relic/commands directory
-# pass the name of the command as an argument
-require File.dirname(__FILE__) + '/../lib/new_relic/commands/new_relic_commands'
View
30 vendor/plugins/newrelic_rpm/init.rb
@@ -1,30 +0,0 @@
-# This is the initialization for the RPM Rails plugin
-require 'new_relic/config'
-
-# If you are having problems seeing data, be sure and check the
-# newrelic_agent log files.
-#
-# If you can't find any log files and you don't see anything in your
-# application log files, try uncommenting these lines to verify
-# the plugin is being loaded, then contact support@newrelic.com
-# if you are unable to resolve the issue.
-# STDOUT.puts "RPM detected environment: #{NewRelic::Config.instance.local_env}, RAILS_ENV: #{RAILS_ENV}"
-
-# Initializer for the NewRelic Agent
-
-begin
- # JRuby's glassfish plugin is trying to run the Initializer twice,
- # which isn't a good thing so we ignore subsequent invocations here.
- if ! defined?(::NEWRELIC_STARTED)
- ::NEWRELIC_STARTED = "#{caller.join("\n")}"
- NewRelic::Config.instance.start_plugin (defined?(config) ? config : nil)
- else
- NewRelic::Config.instance.log.debug "Attempt to initialize the plugin twice!"
- NewRelic::Config.instance.log.debug "Original call: \n#{::NEWRELIC_STARTED}"
- NewRelic::Config.instance.log.debug "Here we are now: \n#{caller.join("\n")}"
- end
-rescue => e
- NewRelic::Config.instance.log! "Error initializing New Relic plugin (#{e})", :error
- NewRelic::Config.instance.log! e.backtrace.join("\n"), :error
- NewRelic::Config.instance.log! "Agent is disabled."
-end
View
37 vendor/plugins/newrelic_rpm/install.rb
@@ -1,37 +0,0 @@
-require 'ftools'
-require 'erb'
-
-# Install a newrelic.yml file into the local config directory.
-# If no such directory exists, install it in ~/.newrelic.
-#
-# If a config file already exists, print a warning and exit.
-#
-if File.directory? "config"
- dest_dir = "config"
-else
- dest_dir = File.join(ENV["HOME"],".newrelic") rescue nil
- FileUtils.mkdir(dest_dir) if dest_dir
-end
-
-src_config_file = File.join(File.dirname(__FILE__),"newrelic.yml")
-dest_config_file = File.join(dest_dir, "newrelic.yml") if dest_dir
-
-if !dest_dir
- STDERR.puts "Could not find a config or ~/.newrelic directory to locate the default newrelic.yml file"
-elsif File::exists? dest_config_file
- STDERR.puts "\nA config file already exists at #{dest_config_file}.\n"
-else
- generated_for_user = ""
- license_key = "PASTE_YOUR_KEY_HERE"
- yaml = ERB.new(File.read(src_config_file)).result(binding)
- File.open( dest_config_file, 'w' ) do |out|
- out.puts yaml
- end
-
- puts IO.read(File.join(File.dirname(__FILE__), 'README'))
- puts "\n--------------------------------------------------------\n"
- puts "Installing a default configuration file in #{dest_dir}."
- puts "To monitor your application in production mode, you must enter a license key."
- puts "See #{dest_config_file}"
- puts "For a license key, sign up at http://rpm.newrelic.com/signup."
-end
View
29 vendor/plugins/newrelic_rpm/lib/new_relic/agent.rb
@@ -1,29 +0,0 @@
-require 'new_relic/version'
-require 'new_relic/local_environment'
-require 'new_relic/stats'
-require 'new_relic/metric_spec'
-require 'new_relic/metric_data'
-require 'new_relic/transaction_analysis'
-require 'new_relic/transaction_sample'
-require 'new_relic/noticed_error'
-
-require 'new_relic/agent/chained_call'
-require 'new_relic/agent/agent'
-require 'new_relic/agent/method_tracer'
-require 'new_relic/agent/synchronize'
-require 'new_relic/agent/worker_loop'
-require 'new_relic/agent/stats_engine'
-require 'new_relic/agent/collection_helper'
-require 'new_relic/agent/transaction_sampler'
-require 'new_relic/agent/error_collector'
-
-require 'set'
-require 'sync'
-require 'thread'
-require 'resolv'
-require 'timeout'
-
-
-module NewRelic::Agent
-
-end
View
13 vendor/plugins/newrelic_rpm/lib/new_relic/agent/chained_call.rb
@@ -1,13 +0,0 @@
-# This is used to allow obfuscators to be chained.
-
-class NewRelic::ChainedCall
- def initialize(block1, block2)
- @block1 = block1
- @block2 = block2
- end
-
- def call(sql)
- sql = @block1.call(sql)
- @block2.call(sql)
- end
-end
View
18 vendor/plugins/newrelic_rpm/lib/new_relic/agent/instrumentation/active_merchant.rb
@@ -1,18 +0,0 @@
-# ActiveMerchant Instrumentation.
-
-if defined? ActiveMerchant
-
- ActiveMerchant::Billing::Gateway.implementations.each do |gateway|
- gateway.class_eval do
- implemented_methods = public_instance_methods(false)
- gateway_name = self.name.split('::').last
- [:authorize, :purchase, :credit, :void, :capture, :recurring].each do |operation|
- if implemented_methods.include?(operation.to_s)
- add_method_tracer operation, "ActiveMerchant/gateway/#{gateway_name}/#{operation}", :scoped_metric_only => true
- add_method_tracer operation, "ActiveMerchant/gateway/#{gateway_name}", :push_scope => false
- add_method_tracer operation, "ActiveMerchant/operation/#{operation}", :push_scope => false
- end
- end
- end
- end
-end
View
95 ...plugins/newrelic_rpm/lib/new_relic/agent/instrumentation/active_record_instrumentation.rb
@@ -1,95 +0,0 @@
-
-# NewRelic instrumentation for ActiveRecord
-if defined? ActiveRecord::Base
-
- ActiveRecord::Base.class_eval do
- class << self
- [:find_by_sql, :count].each do |find_method|
- add_method_tracer find_method, 'ActiveRecord/#{self.name}/find'
- add_method_tracer find_method, 'ActiveRecord/find', :push_scope => false
- add_method_tracer find_method, 'ActiveRecord/all', :push_scope => false
- end
- end
- [:save, :save!].each do |save_method|
- add_method_tracer save_method, 'ActiveRecord/#{self.class.name}/save'
- add_method_tracer save_method, 'ActiveRecord/save', :push_scope => false
- add_method_tracer save_method, 'ActiveRecord/all', :push_scope => false
- end
-
- add_method_tracer :destroy, 'ActiveRecord/#{self.class.name}/destroy'
- add_method_tracer :destroy, 'ActiveRecord/destroy', :push_scope => false
- add_method_tracer :destroy, 'ActiveRecord/all', :push_scope => false
- end
-
- # instrumentation to catch logged SQL statements in sampled transactions
-
- ActiveRecord::ConnectionAdapters::AbstractAdapter.class_eval do
- @@my_sql_defined = defined? ActiveRecord::ConnectionAdapters::MysqlAdapter
- @@postgres_defined = defined? ActiveRecord::ConnectionAdapters::PostgreSQLAdapter
-
- def log_with_newrelic_instrumentation(sql, name, &block)
- # if we aren't in a blamed context, then add one so that we can see that
- # controllers are calling SQL directly
- # we check scope_depth vs 2 since the controller is 1, and the
- #
- if NewRelic::Agent.instance.transaction_sampler.scope_depth < 2
- self.class.trace_method_execution_with_scope "Database/DirectSQL", true, true do
- log_with_capture_sql(sql, name, &block)
- end
- else
- log_with_capture_sql(sql, name, &block)
- end
- end
-
- def log_with_capture_sql(sql, name, &block)
- if @@my_sql_defined && self.is_a?(ActiveRecord::ConnectionAdapters::MysqlAdapter)
- config = @config
- elsif @@postgres_defined && self.is_a?(ActiveRecord::ConnectionAdapters::PostgreSQLAdapter)
- config = @config
- else
- config = nil
- end
-
- t0 = Time.now
- result = log_without_newrelic_instrumentation(sql, name, &block)
-
- NewRelic::Agent.instance.transaction_sampler.notice_sql(sql, config, Time.now - t0)
-
- result
- end
-
- # Compare with #alias_method_chain, which is not available in
- # Rails 1.1:
- alias_method :log_without_newrelic_instrumentation, :log
- alias_method :log, :log_with_newrelic_instrumentation
- protected :log
-
- add_method_tracer :log, 'Database/#{adapter_name}/#{args[1]}', :metric => false
- add_method_tracer :log, 'Database/all', :push_scope => false
-
- end
- ActiveRecord::Associations::ClassMethods.class_eval do
- add_method_tracer :find_with_associations, 'ActiveRecord/#{self.name}/find'
- add_method_tracer :find_with_associations, 'ActiveRecord/find', :push_scope => false
- add_method_tracer :find_with_associations, 'ActiveRecord/all', :push_scope => false
- end
-
- # instrumentation for associations
- ActiveRecord::Associations::AssociationCollection.class_eval do
- add_method_tracer :delete, 'ActiveRecord/#{@owner.class.name}/association delete'
- end
-=begin
- # Consider enabling these in the future
- class HasAndBelongsToManyAssociation
- add_method_tracer :find, 'ActiveRecord/#{@owner.class.name}/association find'
- add_method_tracer :create_record, 'ActiveRecord/#{@owner.class.name}/association create'
- add_method_tracer :insert_record, 'ActiveRecord/#{@owner.class.name}/association insert'
- end
-
- class HasManyAssociation
- add_method_tracer :find, 'ActiveRecord/#{@owner.class.name}/association find'
- add_method_tracer :insert_record, 'ActiveRecord/#{@owner.class.name}/association insert'
- add_method_tracer :create_record, 'ActiveRecord/#{@owner.class.name}/association create'
- end
-=end
-end
View
90 vendor/plugins/newrelic_rpm/lib/new_relic/agent/instrumentation/data_mapper.rb
@@ -1,90 +0,0 @@
-
-# NewRelic instrumentation for DataMapper
-# For now, we have to refer to all db metrics as "ActiveRecord"
-if defined? DataMapper
-
- DataMapper::Model.class_eval do
- add_method_tracer :get, 'ActiveRecord/#{self.name}/find'
- add_method_tracer :first, 'ActiveRecord/#{self.name}/find'
- add_method_tracer :first_or_create, 'ActiveRecord/#{self.name}/find'
- add_method_tracer :all, 'ActiveRecord/#{self.name}/find_all'
- end
- DataMapper::Adapters::DataObjectsAdapter.class_eval do
-
- @@my_sql_defined = defined? ActiveRecord::ConnectionAdapters::MysqlAdapter
- @@postgres_defined = defined? ActiveRecord::ConnectionAdapters::PostgreSQLAdapter
-
- for method in [:read_many, :read_one] do
- add_method_tracer method, 'ActiveRecord/#{self.class.name[/[^:]*$/]}/find' # Need to get the model somehow
- add_method_tracer method, 'ActiveRecord/find', :push_scope => false
- add_method_tracer method, 'ActiveRecord/all', :push_scope => false
- end
- for method in [:execute, :query] do
- add_method_tracer method, 'ActiveRecord/#{self.class.name[/[^:]*$/]}/execute' # Need to get the model somehow
- add_method_tracer method, 'ActiveRecord/all', :push_scope => false
- end
- for method in [:create, :update]do
- add_method_tracer method, 'ActiveRecord/#{self.class.name[/[^:]*$/]}/save'
- add_method_tracer method, 'ActiveRecord/save', :push_scope => false
- end
- add_method_tracer :delete, 'ActiveRecord/#{self.class.name[/[^:]*$/]}/destroy'
- add_method_tracer :delete, 'ActiveRecord/destroy', :push_scope => false
-
- def log_with_newrelic_instrumentation(sql, name, &block)
- # if we aren't in a blamed context, then add one so that we can see that
- # controllers are calling SQL directly
- # we check scope_depth vs 2 since the controller is 1, and the
- #
- if NewRelic::Agent.instance.transaction_sampler.scope_depth < 2
- self.class.trace_method_execution "Database/DirectSQL", true, true do
- log_with_capture_sql(sql, name, &block)
- end
- else
- log_with_capture_sql(sql, name, &block)
- end
- end
-
- def log_with_capture_sql(sql, name, &block)
- if @@my_sql_defined && self.is_a?(ActiveRecord::ConnectionAdapters::MysqlAdapter)
- config = @config
- elsif @@postgres_defined && self.is_a?(ActiveRecord::ConnectionAdapters::PostgreSQLAdapter)
- config = @config
- else
- config = nil
- end
-
- t0 = Time.now
- result = log_without_newrelic_instrumentation(sql, name, &block)
-
- NewRelic::Agent.instance.transaction_sampler.notice_sql(sql, config, Time.now - t0)
-
- result
- end
-
- # Compare with #alias_method_chain, which is not available in
- # Rails 1.1:
- #alias_method :log_without_newrelic_instrumentation, :log
- #alias_method :log, :log_with_newrelic_instrumentation
-
-=begin
- # instrumentation for associations
- module Associations
- class AssociationCollection
- add_method_tracer :delete, 'ActiveRecord/#{@owner.class.name}/association delete'
- end
-
- def HasAndBelongsToManyAssociation
- add_method_tracer :find, 'ActiveRecord/#{@owner.class.name}/association find'
- add_method_tracer :create_record, 'ActiveRecord/#{@owner.class.name}/association create'
- add_method_tracer :insert_record, 'ActiveRecord/#{@owner.class.name}/association insert'
- end
-
- class HasManyAssociation
- # add_method_tracer :find, 'ActiveRecord/#{@owner.class.name}/association find'
- # add_method_tracer :insert_record, 'ActiveRecord/#{@owner.class.name}/association insert'
- # add_method_tracer :create_record, 'ActiveRecord/#{@owner.class.name}/association create'
- end
- end
-=end
- end
-end
View
105 ...or/plugins/newrelic_rpm/lib/new_relic/agent/instrumentation/dispatcher_instrumentation.rb
@@ -1,105 +0,0 @@
-# We have to patch the mongrel dispatcher live since the classes
-# aren't defined when our instrumentation loads
-module NewRelic::Agent::Instrumentation
- module DispatcherInstrumentation
-
- @@newrelic_agent = NewRelic::Agent.agent
- @@newrelic_rails_dispatch_stat = @@newrelic_agent.stats_engine.get_stats 'Rails/HTTP Dispatch'
- @@newrelic_mongrel_queue_stat = @@newrelic_agent.stats_engine.get_stats('WebFrontend/Mongrel/Average Queue Time')
-
- def newrelic_dispatcher_start
- # Put the current time on the thread. Can't put in @ivar because this could
- # be a class or instance context
- t0 = Time.now.to_f
- NewRelic::Config.instance.log.warn "Recursive entry into dispatcher_start!\n#{caller.join("\n ")}" if Thread.current[:newrelic_t0]
- Thread.current[:newrelic_t0] = t0
- NewRelic::Agent::Instrumentation::DispatcherInstrumentation::BusyCalculator.dispatcher_start t0
- # capture the time spent in the mongrel queue, if running in mongrel. This is the
- # current time less the timestamp placed in 'started_on' by mongrel.
- mongrel_start = Thread.current[:started_on]
- @@newrelic_mongrel_queue_stat.trace_call(t0 - mongrel_start.to_f) if mongrel_start
- @@newrelic_agent.start_transaction
-
- # Reset the flag indicating the controller action should be ignored.
- # It may be set by the action to either true or false or left nil meaning false
- Thread.current[:controller_ignored] = nil
- end
-
- def newrelic_dispatcher_finish
- t0 = Thread.current[:newrelic_t0]
- if t0.nil?
- NewRelic::Config.instance.log.warn "Dispatcher finish called twice!\n#{caller.join("\n ")}"
- return
- end
- t1 = Time.now.to_f
- @@newrelic_agent.end_transaction
- @@newrelic_rails_dispatch_stat.trace_call(t1 - t0) unless Thread.current[:controller_ignored]
- NewRelic::Agent::Instrumentation::DispatcherInstrumentation::BusyCalculator.dispatcher_finish t1
- Thread.current[:newrelic_t0] = nil
- end
-
- def dispatch_newrelic(*args)
- newrelic_dispatcher_start
- begin
- dispatch_without_newrelic(*args)
- ensure
- newrelic_dispatcher_finish
- end
- end
-
- # This won't work with Rails 2.2 multi-threading
- module BusyCalculator
- extend self
- # the fraction of the sample period that the dispatcher was busy
- @instance_busy = NewRelic::Agent.agent.stats_engine.get_stats('Instance/Busy')
- @harvest_start = Time.now.to_f
- @accumulator = 0
- @dispatcher_start = nil
- def dispatcher_start(time)
- Thread.critical = true
- @dispatcher_start = time
- Thread.critical = false
- end
-
- def dispatcher_finish(time)
- Thread.critical = true
- @accumulator += (time - @dispatcher_start)
- @dispatcher_start = nil
-
- Thread.critical = false
- end
-
- def is_busy?
- @dispatcher_start
- end
-
- def harvest_busy
- Thread.critical = true
-
- busy = @accumulator
- @accumulator = 0
-
- t0 = Time.now.to_f
-
- if @dispatcher_start
- busy += (t0 - @dispatcher_start)
- @dispatcher_start = t0
- end
-
-
- Thread.critical = false
-
- busy = 0.0 if busy < 0.0 # don't go below 0%
-
- time_window = (t0 - @harvest_start)
- time_window = 1.0 if time_window == 0.0 # protect against divide by zero
-
- busy = busy / time_window
-
- busy = 1.0 if busy > 1.0 # cap at 100%
- @instance_busy.record_data_point busy
- @harvest_start = t0
- end
- end
- end
-end
View
18 vendor/plugins/newrelic_rpm/lib/new_relic/agent/instrumentation/memcache.rb
@@ -1,18 +0,0 @@
-# NOTE there are multiple implementations of the MemCache client in Ruby,
-# each with slightly different API's and semantics.
-# Currently we only cover memcache-client. Need to cover Ruby-MemCache.
-# See:
-# http://www.deveiate.org/code/Ruby-MemCache/ (Gem: Ruby-MemCache)
-# http://dev.robotcoop.com/Libraries/memcache-client/ (Gem: memcache-client)
-MemCache.class_eval do
- add_method_tracer :get, 'MemCache/read' if self.method_defined? :get
- add_method_tracer :set, 'MemCache/write' if self.method_defined? :set
- add_method_tracer :get_multi, 'MemCache/read' if self.method_defined? :get_multi
-end if defined? MemCache
-
-# Support for libmemcached through Evan Weaver's memcached wrapper
-# http://blog.evanweaver.com/files/doc/fauna/memcached/classes/Memcached.html
-Memcached.class_eval do
- add_method_tracer :get, 'Memcached/read' if self.method_defined? :get
- add_method_tracer :set, 'Memcached/write' if self.method_defined? :set
-end if defined? Memcached
View
17 vendor/plugins/newrelic_rpm/lib/new_relic/agent/instrumentation/merb/controller.rb
@@ -1,17 +0,0 @@
-require 'set'
-require 'merb-core/controller/merb_controller'
-
-Merb::Controller.class_eval do
- include NewRelic::Agent::Instrumentation::ControllerInstrumentation
-
- class_inheritable_accessor :newrelic_ignore_attr
-
- protected
- # determine the path that is used in the metric name for
- # the called controller action
- def newrelic_metric_path(action)
- "#{controller_name}/#{action}"
- end
- alias_method :perform_action_without_newrelic_trace, :_dispatch
- alias_method :_dispatch, :perform_action_with_newrelic_trace
-end
View
27 vendor/plugins/newrelic_rpm/lib/new_relic/agent/instrumentation/rails/action_web_service.rb
@@ -1,27 +0,0 @@
-# NewRelic Agent instrumentation for WebServices
-
-# Note Action Web Service is removed from default package in rails 2.0
-if defined? ActionWebService
-
- # instrumentation for Web Service martialing - XML RPC
- ActionWebService::Protocol::XmlRpc::XmlRpcProtocol.class_eval do
- add_method_tracer :decode_request, "WebService/Xml Rpc/XML Decode"
- add_method_tracer :encode_request, "WebService/Xml Rpc/XML Encode"
- add_method_tracer :decode_response, "WebService/Xml Rpc/XML Decode"
- add_method_tracer :encode_response, "WebService/Xml Rpc/XML Encode"
- end
-
- # instrumentation for Web Service martialing - Soap
- ActionWebService::Protocol::Soap::SoapProtocol.class_eval do
- add_method_tracer :decode_request, "WebService/Soap/XML Decode"
- add_method_tracer :encode_request, "WebService/Soap/XML Encode"
- add_method_tracer :decode_response, "WebService/Soap/XML Decode"
- add_method_tracer :encode_response, "WebService/Soap/XML Encode"
- end
-
- ActionController::Base.class_eval do
- if method_defined? :perform_invocation
- add_method_tracer :perform_invocation, 'WebService/#{controller_name}/#{args.first}'
- end
- end if defined? ActionController::Base
-end
View
30 vendor/plugins/newrelic_rpm/lib/new_relic/agent/instrumentation/rails/dispatcher.rb
@@ -1,30 +0,0 @@
-require 'dispatcher'
-
-# NewRelic RPM instrumentation for http request dispatching (Routes mapping)
-# Note, the dispatcher class from no module into into the ActionController module
-# in Rails 2.0. Thus we need to check for both
-if defined? ActionController::Dispatcher
- target = ActionController::Dispatcher
-elsif defined? Dispatcher
- target = Dispatcher
-else
- target = nil
-end
-
-if target
- NewRelic::Agent.instance.log.debug "Adding #{target} instrumentation"
-
- # in Rails 2.3 (Rack-based) we don't want to add instrumentation on class level
- unless defined? ::Rails::Rack
- target = target.class_eval { class << self; self; end }
- end
-
- target.class_eval do
- include NewRelic::Agent::Instrumentation::DispatcherInstrumentation
-
- alias_method :dispatch_without_newrelic, :dispatch
- alias_method :dispatch, :dispatch_newrelic
- end
-else
- NewRelic::Agent.instance.log.debug "WARNING: Dispatcher instrumentation not added"
-end
View
6 vendor/plugins/newrelic_rpm/lib/new_relic/agent/instrumentation/rails/rails.rb
@@ -1,6 +0,0 @@
-# Instrument the compilation of ERB files.
-ERB::Compiler.class_eval do
- add_method_tracer :compile, 'View/.rhtml Processing'
-end
-
-
View
171 vendor/plugins/newrelic_rpm/lib/new_relic/agent/method_tracer.rb
@@ -1,171 +0,0 @@
-
-class Module
-
- # Original method preserved for API backward compatibility
- def trace_method_execution (metric_name, push_scope, produce_metric, deduct_call_time_from_parent, &block)
- if push_scope
- trace_method_execution_with_scope(metric_name, produce_metric, deduct_call_time_from_parent, &block)
- else
- trace_method_execution_no_scope(metric_name, &block)
- end
- end
-
- # This is duplicated inline in add_method_tracer
- def trace_method_execution_no_scope(metric_name)
- t0 = Time.now.to_f
- stats = @@newrelic_stats_engine.get_stats_no_scope metric_name
-
- result = yield
- duration = Time.now.to_f - t0 # for some reason this is 3 usec faster than Time - Time
- stats.trace_call(duration, duration)
- result
- end
-
- def trace_method_execution_with_scope(metric_name, produce_metric, deduct_call_time_from_parent)
-
- t0 = Time.now.to_f
- stats = nil
-
- begin
- # Keep a reference to the scope we are pushing so we can do a sanity check making
- # sure when we pop we get the one we 'expected'
- expected_scope = @@newrelic_stats_engine.push_scope(metric_name, t0, deduct_call_time_from_parent)
-
- stats = @@newrelic_stats_engine.get_stats metric_name, true if produce_metric
- rescue => e
- NewRelic::Config.instance.log.error("Caught exception in trace_method_execution header. Metric name = #{metric_name}, exception = #{e}")
- NewRelic::Config.instance.log.error(e.backtrace.join("\n"))
- end
-
- begin
- yield
- ensure
- t1 = Time.now.to_f
- duration = t1 - t0
-
- begin
- if expected_scope
- scope = @@newrelic_stats_engine.pop_scope expected_scope, duration, t1
-
- exclusive = duration - scope.children_time
- stats.trace_call(duration, exclusive) if stats
- end
- rescue => e
- NewRelic::Config.instance.log.error("Caught exception in trace_method_execution footer. Metric name = #{metric_name}, exception = #{e}")
- NewRelic::Config.instance.log.error(e.backtrace.join("\n"))
- end
- end
- end
-
- # Add a method tracer to the specified method.
- # metric_name_code is ruby code that determines the name of the
- # metric to be collected during tracing. As such, the code
- # should be provided in 'single quote' strings rather than
- # "double quote" strings, so that #{} evaluation happens
- # at traced method execution time.
- # Example: tracing a method :foo, where the metric name is
- # the first argument converted to a string
- # add_method_tracer :foo, '#{args.first.to_s}'
- # statically defined metric names can be specified as regular strings
- # push_scope specifies whether this method tracer should push
- # the metric name onto the scope stack.
- def add_method_tracer (method_name, metric_name_code, options = {})
- return unless NewRelic::Agent.agent.config.tracers_enabled?
-
- @@newrelic_stats_engine ||= NewRelic::Agent.agent.stats_engine
-
- if !options.is_a?(Hash)
- options = {:push_scope => options}
- end
- # options[:push_scope] true if we are noting the scope of this for
- # stats collection as well as the transaction tracing
- options[:push_scope] = true if options[:push_scope].nil?
- # options[:metric] true if you are tracking stats for a metric, otherwise
- # it's just for transaction tracing.
- options[:metric] = true if options[:metric].nil?
- options[:deduct_call_time_from_parent] = false if options[:deduct_call_time_from_parent].nil? && !options[:metric]
- options[:deduct_call_time_from_parent] = true if options[:deduct_call_time_from_parent].nil?
- options[:code_header] ||= ""
- options[:code_footer] ||= ""
-
- klass = (self === Module) ? "self" : "self.class"
-
- unless method_defined?(method_name) || private_method_defined?(method_name)
- NewRelic::Config.instance.log.warn("Did not trace #{self}##{method_name} because that method does not exist")
- return
- end
-
- traced_method_name = _traced_method_name(method_name, metric_name_code)
- if method_defined? traced_method_name
- NewRelic::Config.instance.log.warn("Attempt to trace a method twice with the same metric: Method = #{method_name}, Metric Name = #{metric_name_code}")
- return
- end
-
- fail "Can't add a tracer where push_scope is false and metric is false" if options[:push_scope] == false && !options[:metric]
-
- if options[:push_scope] == false
- class_eval "@@newrelic_stats_engine = NewRelic::Agent.agent.stats_engine"
- code = <<-CODE
- def #{_traced_method_name(method_name, metric_name_code)}(*args, &block)
- #{options[:code_header]}
-
- t0 = Time.now.to_f
- stats = @@newrelic_stats_engine.get_stats_no_scope "#{metric_name_code}"
-
- result = #{_untraced_method_name(method_name, metric_name_code)}(*args, &block)
- duration = Time.now.to_f - t0
- stats.trace_call(duration, duration) # for some reason this is 3 usec faster than Time - Time
- #{options[:code_footer]}
- result
- end
- CODE
- else
- code = <<-CODE
- def #{_traced_method_name(method_name, metric_name_code)}(*args, &block)
- #{options[:code_header]}
- result = #{klass}.trace_method_execution_with_scope("#{metric_name_code}", #{options[:metric]}, #{options[:deduct_call_time_from_parent]}) do
- #{_untraced_method_name(method_name, metric_name_code)}(*args, &block)
- end
- #{options[:code_footer]}
- result
- end
- CODE
- end
-
- class_eval code, __FILE__, __LINE__
-
- alias_method _untraced_method_name(method_name, metric_name_code), method_name
- alias_method method_name, _traced_method_name(method_name, metric_name_code)
-
- NewRelic::Config.instance.log.debug("Traced method: class = #{self}, method = #{method_name}, "+
- "metric = '#{metric_name_code}', options: #{options}, ")
- end
-
- # Not recommended for production use, because tracers must be removed in reverse-order
- # from when they were added, or else other tracers that were added to the same method
- # may get removed as well.
- def remove_method_tracer(method_name, metric_name_code)
- return unless NewRelic::Agent.agent.config.tracers_enabled?
-
- if method_defined? "#{_traced_method_name(method_name, metric_name_code)}"
- alias_method method_name, "#{_untraced_method_name(method_name, metric_name_code)}"
- undef_method "#{_traced_method_name(method_name, metric_name_code)}"
- else
- raise "No tracer for '#{metric_name_code}' on method '#{method_name}'"
- end
- end
-
-private
-
- def _untraced_method_name(method_name, metric_name)
- "#{_sanitize_name(method_name)}_without_trace_#{_sanitize_name(metric_name)}"
- end
-
- def _traced_method_name(method_name, metric_name)
- "#{_sanitize_name(method_name)}_with_trace_#{_sanitize_name(metric_name)}"
- end
-
- def _sanitize_name(name)
- name.to_s.tr('^a-z,A-Z,0-9', '_')
- end
-end
View
29 vendor/plugins/newrelic_rpm/lib/new_relic/agent/samplers/cpu.rb
@@ -1,29 +0,0 @@
-module NewRelic::Agent
- class CPUSampler
- def initialize
-
- agent = NewRelic::Agent.instance
-
- agent.stats_engine.add_sampled_metric("CPU/User Time") do | stats |
- t = Process.times
- @last_utime ||= t.utime
-
- utime = t.utime
- stats.record_data_point(utime - @last_utime) if (utime - @last_utime) >= 0
- @last_utime = utime
- end
-
- agent.stats_engine.add_sampled_metric("CPU/System Time") do | stats |
- t = Process.times
- @last_stime ||= t.stime
-
- stime = t.stime
- stats.record_data_point(stime - @last_stime) if (stime - @last_stime) >= 0
- @last_stime = stime
- end
- end
- end
-end
-
-# CPU sampling like this doesn't work for jruby
-NewRelic::Agent::CPUSampler.new unless defined? Java
View
55 vendor/plugins/newrelic_rpm/lib/new_relic/agent/samplers/memory.rb
@@ -1,55 +0,0 @@
-module NewRelic::Agent
- class MemorySampler
- def initialize
- if RUBY_PLATFORM =~ /java/
- platform = %x[uname -s].downcase
- else
- platform = RUBY_PLATFORM.downcase
- end
-
- # macos, linux, solaris
- if platform =~ /darwin|linux/
- @ps = "ps -o rsz"
- elsif platform =~ /freebsd/
- @ps = "ps -o rss"
- elsif platform =~ /solaris/
- @ps = "/usr/bin/ps -o rss -p"
- end
- if !@ps
- raise "Unsupported platform for getting memory: #{platform}"
- end
-
- if @ps
- @broken = false
-
- agent = NewRelic::Agent.instance
- agent.stats_engine.add_sampled_metric("Memory/Physical") do |stats|
- if !@broken
- begin
- process = $$
- memory = `#{@ps} #{process}`.split("\n")[1].to_f / 1024
-
- # if for some reason the ps command doesn't work on the resident os,
- # then don't execute it any more.
- if memory >= 0
- stats.record_data_point memory
- else
- NewRelic::Agent.instance.log.error "Error attempting to determine resident memory for pid #{process} (got result of #{memory}, this process = #{$$}). Disabling this metric."
- NewRelic::Agent.instance.log.error "Faulty command: `#{@ps}`"
- @broken = true
- end
- rescue Exception => e
- if e.is_a? Errno::ENOMEM
- NewRelic::Agent.instance.log.error "Got OOM trying to determine process memory usage"
- else
- raise e
- end
- end
- end
- end
- end
- end
- end
-end
-
-NewRelic::Agent::MemorySampler.new
View
26 vendor/plugins/newrelic_rpm/lib/new_relic/agent/samplers/mongrel.rb
@@ -1,26 +0,0 @@
-# NewRelic Instrumentation for Mongrel - tracks the queue length of the mongrel server
-if defined? Mongrel::HttpServer
-
- agent = NewRelic::Agent.instance
- mongrel = nil;
- ObjectSpace.each_object(Mongrel::HttpServer) do |mongrel_instance|
- # should only be one mongrel instance in the vm
- if mongrel
- agent.log.info("Discovered multiple mongrel instances in one Ruby VM. "+
- "This is unexpected and might affect the Accuracy of the Mongrel Request Queue metric.")
- end
-
- mongrel = mongrel_instance
- end
-
-
- if mongrel
- agent.stats_engine.add_sampled_metric("Mongrel/Queue Length") do |stats|
- qsize = mongrel.workers.list.length
- qsize -= 1 if NewRelic::Agent::Instrumentation::DispatcherInstrumentation::BusyCalculator.is_busy?
- qsize = 0 if qsize < 0
- stats.record_data_point qsize
- end
- end
-
-end
View
40 vendor/plugins/newrelic_rpm/lib/new_relic/agent/synchronize.rb
@@ -1,40 +0,0 @@
-
-module NewRelic::Agent
-
- module Synchronize
- def synchronize_sync
- @_local_sync ||= Sync.new
-
- @_local_sync.synchronize(:EX) do
- yield
- end
- end
-
-
- def synchronize_mutex
- @_local_mutex ||= Mutex.new
-
- @_local_mutex.synchronize do
- yield
- end
- end
-
-
- def synchronize_thread
- old_val = Thread.critical
-
- Thread.critical = true
-
- begin
- yield
- ensure
- Thread.critical = old_val
- end
- end
-
-
- alias synchronize synchronize_mutex
- alias synchronize_quick synchronize_mutex
- alias synchronized_long synchronize_mutex
- end
-end
View
30 vendor/plugins/newrelic_rpm/lib/new_relic/commands/new_relic_commands.rb
@@ -1,30 +0,0 @@
-require 'optparse'
-
-# Run the command given by the first argument. Right
-# now all we have is deployments. We hope to have other
-# kinds of events here later.
-
-libdir = File.expand_path(File.join(File.dirname(__FILE__), '..','..'))
-command_list = Dir[File.join(libdir,'new_relic','commands','*.rb')].map{|command| command =~ /.*\/(.*)\.rb/ && $1}
-command_list.delete 'new_relic_commands'
-extra = []
-options = ARGV.options do |opts|
- script_name = File.basename($0)
- opts.banner = "Usage: #{__FILE__} #{ command_list.join(" | ")} [options]"
- opts.separator "use -h to see detailed command options"
- opts
-end
-extra = options.order!
-command = extra.shift
-if !command_list.include?(command)
- STDERR.puts options
-else
- require File.join(libdir, 'new_relic','commands', command + ".rb")
- command_class = NewRelic::Commands.const_get(command.capitalize)
- begin
- command_class.new(extra).run
- rescue NewRelic::Commands::CommandFailure => failure
- STDERR.puts failure.message
- exit failure.exit_code
- end
-end
View
278 vendor/plugins/newrelic_rpm/lib/new_relic/config.rb
@@ -1,278 +0,0 @@
-require 'yaml'
-require 'new_relic/local_environment'
-require 'singleton'
-require 'erb'
-require 'net/https'
-require 'logger'
-
-# Configuration supports the behavior of the agent which is dependent
-# on what environment is being monitored: rails, merb, ruby, etc
-# It is an abstract factory with concrete implementations under
-# the config folder.
-module NewRelic
-
- class Config
-
- attr_accessor :log_file, :env
-
- # Structs holding info for the remote server and proxy server
- class Server < Struct.new :host, :port
- def to_s; "#{host}:#{port}"; end
- end
-
- ProxyServer = Struct.new :host, :port, :user, :password
-
- def self.instance
- @instance ||= new_instance
- end
-
-
-
- @settings = nil
-
- # Initialize the agent: install instrumentation and start the agent if
- # appropriate. Subclasses may have different arguments for this when
- # they are being called from different locations.
- def start_plugin(*args)
- if tracers_enabled?
- start_agent
- else
- require 'new_relic/shim_agent'
- end
- end
-
- # Get the app config info. It should already have been collected but
- # if not we will memoize it to be safe.
- def app_config_info
- @app_config_info ||= gather_info
- end
-
- def [](key)
- fetch(key)
- end
- ####################################
- def settings
- if @settings.nil?
- @settings = (@yaml && @yaml[env]) || {}
- @settings['apdex_t'] ||= 1.0
- end
- @settings
- end
-
- def []=(key, value)
- settings[key] = value
- end
-
- def set_config(key,value)
- self[key]=value
- end
-
- def fetch(key, default=nil)
- settings[key].nil? ? default : settings[key]
- end
-
- ###################################
- # Agent config conveniences
-
- def newrelic_root
- File.expand_path(File.join(__FILE__, "..","..",".."))
- end
- def connect_to_server?
- fetch('enabled', nil)
- end
- def developer_mode?
- fetch('developer', nil)
- end
- def tracers_enabled?
- !(ENV['NEWRELIC_ENABLE'].to_s =~ /false|off|no/i) &&
- (developer_mode? || connect_to_server?)
- end
- def app_name
- fetch('app_name', nil)
- end
-
- def use_ssl?
- @use_ssl ||= fetch('ssl', false)
- end
-
- def server
- @remote_server ||=
- NewRelic::Config::Server.new convert_to_ip_address(fetch('host', 'collector.newrelic.com')), fetch('port', use_ssl? ? 443 : 80).to_i
- end
-
- def api_server
- @api_server ||=
- NewRelic::Config::Server.new fetch('api_host', 'rpm.newrelic.com'), fetch('api_port', fetch('port', use_ssl? ? 443 : 80)).to_i
- end
-
- def proxy_server
- @proxy_server ||=
- NewRelic::Config::ProxyServer.new convert_to_ip_address(fetch('proxy_host', nil)), fetch('proxy_port', nil),
- fetch('proxy_user', nil), fetch('proxy_pass', nil)
- end
-
-
- # Return the Net::HTTP with proxy configuration given the NewRelic::Config::Server object.
- # Default is the collector but for api calls you need to pass api_server
- def http_connection(host = server)
- # Proxy returns regular HTTP if @proxy_host is nil (the default)
- http = Net::HTTP::Proxy(proxy_server.host, proxy_server.port,
- proxy_server.user, proxy_server.password).new(host.host, host.port)
- if use_ssl?
- http.use_ssl = true
- http.verify_mode = OpenSSL::SSL::VERIFY_NONE
- end
- http
- end
-
- def to_s
- puts self.inspect
- "Config[#{self.app}]"
- end
-
- def log
- # If we try to get a log before one has been set up, return a stdout log
- unless @log
- @log = Logger.new(STDOUT)
- @log.level = Logger::WARN
- end
- @log
- end
-
- def setup_log(identifier)
- @log_file = "#{log_path}/#{log_file_name(identifier)}"
- @log = Logger.new @log_file
-
- # change the format just for our logger
-
- def @log.format_message(severity, timestamp, progname, msg)
- "[#{timestamp.strftime("%m/%d/%y %H:%M:%S")} (#{$$})] #{severity} : #{msg}\n"
- end
-
- # set the log level as specified in the config file
- case fetch("log_level","info").downcase
- when "debug"; @log.level = Logger::DEBUG
- when "info"; @log.level = Logger::INFO
- when "warn"; @log.level = Logger::WARN
- when "error"; @log.level = Logger::ERROR
- when "fatal"; @log.level = Logger::FATAL
- else @log.level = Logger::INFO
- end
- @log
- end
-
- def local_env
- @local_env ||= NewRelic::LocalEnvironment.new
- end
-
- # send the given message to STDERR so that it shows
- # up in the console. This should be used for important informational messages at boot.
- # The to_stderr may be implemented differently by different config subclasses.
- # This will NOT print anything if the environment is unknown because this is
- # probably not an environment the agent will be running in.
- def log!(msg, level=:info)
- return if @settings && !tracers_enabled?
- to_stderr msg
- log.send level, msg if log
- end
-
- protected
-
- def convert_to_ip_address(host)
- return nil unless host
- if host.downcase == "localhost"
- ip_address = host
- else
- begin
- ip_address = Resolv.getaddress(host)
- rescue => e
- log.debug "DNS Error caching with Resolv: #{e}"
- begin
- ip_address = IPSocket::getaddress host
- rescue => e
- log.warn "DNS Error looking up IP address: #{e}"
- raise NewRelic::Agent::IgnoreSilentlyException.new
- end
- end
- end
- log.info "Resolved #{host} to #{ip_address}"
- ip_address
- end
-
- # Collect miscellaneous interesting info about the environment
- # Called when the agent is started
- def gather_info
- [[:app, app]]
- end
-
- def to_stderr(msg)
- STDERR.puts "** [NewRelic] " + msg
- end
-
- def start_agent
- require 'new_relic/agent.rb'
- NewRelic::Agent::Agent.instance.start(local_env.environment, local_env.identifier)
- end
-
- def config_file
- File.expand_path(File.join(root,"config","newrelic.yml"))
- end
-
- def log_path
- path = File.join(root,'log')
- unless File.directory? path
- path = '.'
- end
- File.expand_path(path)
- end
-
- def log_file_name(identifier="")
- identifier ||= ""
- "newrelic_agent.#{identifier.gsub(/[^-\w.]/, '_')}.log"
- end
-
- # Create the concrete class for environment specific behavior:
- def self.new_instance
- case
- when defined? NewRelic::TEST
- require 'config/test_config'
- NewRelic::Config::Test.new
- when defined? Merb::Plugins then
- require 'new_relic/config/merb'
- NewRelic::Config::Merb.new
- when defined? Rails then
- require 'new_relic/config/rails'
- NewRelic::Config::Rails.new
- else
- require 'new_relic/config/ruby'
- NewRelic::Config::Ruby.new
- end
- end
-
- # Return a hash of settings you want to override in the newrelic.yml
- # file. Maybe just for testing.
-
- def initialize
- newrelic_file = config_file
- # Next two are for populating the newrelic.yml via erb binding, necessary
- # when using the default newrelic.yml file
- generated_for_user = ''
- license_key=''
- if !File.exists?(config_file)
- yml_file = File.expand_path(File.join(__FILE__,"..","..","..","newrelic.yml"))
- yaml = ::ERB.new(File.read(yml_file)).result(binding)
- log! "Cannot find newrelic.yml file at #{config_file}."
- log! "Be sure to run this from the app root dir."
- log! "Using #{yml_file} file."
- log! "Signup at rpm.newrelic.com to get a newrelic.yml file configured for a free Lite account."
- else
- yaml = ERB.new(File.read(config_file)).result(binding)
- end
- @yaml = YAML.load(yaml)
- rescue ScriptError, StandardError => e
- puts e
- puts e.backtrace.join("\n")
- raise "Error reading newrelic.yml file: #{e}"
- end
- end
-end
View
35 vendor/plugins/newrelic_rpm/lib/new_relic/config/merb.rb
@@ -1,35 +0,0 @@
-class NewRelic::Config::Merb < NewRelic::Config
-
- def app; :merb; end
-
- def env
- @env ||= ::Merb.env
- end
- def root
- ::Merb.root
- end
-
- def to_stderr(msg)
- STDERR.puts "NewRelic ~ " + msg
- end
-
- def start_plugin
- ::Merb::Plugins.add_rakefiles File.join(newrelic_root,"lib/tasks/all.rb")
-
- # Merb gives you a Merb::Plugins.config hash...feel free to put your stuff in your piece of it
- ::Merb::Plugins.config[:newrelic] = {
- :config => self
- }
-
- ::Merb::BootLoader.before_app_loads do
- # require code that must be loaded before the application
- end
-
- if tracers_enabled?
- ::Merb::BootLoader.after_app_loads do
- start_agent
- end
- end
-
- end
-end
View
119 vendor/plugins/newrelic_rpm/lib/new_relic/config/rails.rb
@@ -1,119 +0,0 @@
-class NewRelic::Config::Rails < NewRelic::Config
-
- def app; :rails; end
-
- def env
- @env ||= RAILS_ENV
- end
- def root
- RAILS_ROOT
- end
-
- def log_path
- path = ::RAILS_DEFAULT_LOGGER.instance_eval do
- File.dirname(@log.path) rescue File.dirname(@logdev.filename)
- end rescue "#{root}/log"
- File.expand_path(path)
- end
-
- def start_plugin(rails_config=nil)
- if !tracers_enabled?
- require 'new_relic/shim_agent'
- return
- end
- app_config_info
- start_agent
- install_developer_mode rails_config if developer_mode?
- end
-
- def install_developer_mode(rails_config)
- controller_path = File.join(newrelic_root, 'ui', 'controllers')
- helper_path = File.join(newrelic_root, 'ui', 'helpers')
- $LOAD_PATH << controller_path
- $LOAD_PATH << helper_path
-
- if defined? ActiveSupport::Dependencies
- ActiveSupport::Dependencies.load_paths << controller_path
- ActiveSupport::Dependencies.load_paths << helper_path
- elsif defined? Dependencies.load_paths
- Dependencies.load_paths << controller_path
- Dependencies.load_paths << helper_path
- else
- to_stderr "ERROR: Rails version #{(RAILS_GEM_VERSION) ? RAILS_GEM_VERSION : ''} too old for developer mode to work."
- return
- end
-
- install_devmode_route
-
-
- # If we have the config object then add the controller path to the list.
- # Otherwise we have to assume the controller paths have already been
- # set and we can just append newrelic.
-
- if rails_config
- rails_config.controller_paths << controller_path
- else
- current_paths = ActionController::Routing.controller_paths
- if current_paths.nil? || current_paths.empty?
- to_stderr "WARNING: Unable to modify the routes in this version of Rails. Developer mode not available."
- end
- current_paths << controller_path
- end
-
- #ActionController::Routing::Routes.reload! unless NewRelic::Config.instance['skip_developer_route']
-
- # inform user that the dev edition is available if we are running inside
- # a webserver process
- if local_env.identifier
- port = local_env.identifier.to_s =~ /^\d+/ ? ":#{local_env.identifier}" : ":port"
- to_stderr "NewRelic Agent Developer Mode enabled."
- to_stderr "To view performance information, go to http://localhost#{port}/newrelic"
- end
- end
-
- protected
-
- def install_devmode_route
- # This is a monkey patch to inject the developer tool route into the
- # parent app without requiring users to modify their routes. Of course this
- # has the effect of adding a route indiscriminately which is frowned upon by
- # some: http://www.ruby-forum.com/topic/126316#563328
- ActionController::Routing::RouteSet.class_eval do
- return false if self.instance_methods.include? 'draw_with_newrelic_map'
- def draw_with_newrelic_map
- draw_without_newrelic_map do | map |
- map.named_route 'newrelic_developer', '/newrelic/:action/:id', :controller => 'newrelic' unless NewRelic::Config.instance['skip_developer_route']
- yield map
- end
- end
- alias_method_chain :draw, :newrelic_map
- end
- return true
- end
-
- # Collect the Rails::Info into an associative array as well as the list of plugins
- def gather_info
- i = [[:app, app]]
- begin
- begin
- require 'rails/info'
- rescue LoadError
- require 'builtin/rails_info/rails/info'
- end
- i += ::Rails::Info.properties
- rescue SecurityError, ScriptError, StandardError => e
- log.debug "Unable to get the Rails info: #{e.inspect}"
- end
-
- # Would like to get this from config, but how?
- plugins = Dir[File.join(File.expand_path(__FILE__+"/../../../../.."),"/*")].collect { |p| File.basename p }
- i << ['Plugin List', plugins]
-
- # Look for a capistrano file indicating the current revision:
- rev_file = File.expand_path(File.join(RAILS_ROOT, "REVISION"))
- if File.readable?(rev_file) && File.size(rev_file) < 64
- File.open(rev_file) { | file | i << ['Revision', file.read] } rescue nil
- end
- i
- end
-end
View
135 vendor/plugins/newrelic_rpm/lib/new_relic/local_environment.rb
@@ -1,135 +0,0 @@
-# An instance of LocalEnvironment will provide the environment name
-# and locally unique identifier for this agent's host.
-# If the environment can't be determined, it will be set to
-# :unknown and identifier will have nil
-module NewRelic
- class LocalEnvironment
-
- attr_reader :environment, :identifier
-
- # determine the environment we are running in (one of :webrick,
- # :mongrel, :thin, or :unknown) and if the process is listening
- # on a port, use the port # that we are listening on.
- def initialize
- # Note: log won't be available yet.
- @identifier = nil
- @environment = :unknown
- environments = %w[merb jruby webrick thin mongrel litespeed passenger fastcgi daemon]
- while environments.any? && @identifier.nil?
- send 'check_for_'+(environments.shift)
- end
- end
- def to_s
- "LocalEnvironment[#{environment}:#{identifier}]"
- end
- def check_for_fastcgi
- return unless defined? FCGI
- @environment = :fastcgi
- @identifier = 'fastcgi'
- end
- def check_for_merb
- if config.app == :merb
- @identifier = 'merb'
- end
- end
- def check_for_webrick
- # This will not succeed on rails 2.2 and later
- if defined?(WEBrick) && defined?(OPTIONS) && ::OPTIONS.respond_to?(:fetch)
- # OPTIONS is set by script/server
- @identifier = default_port unless @identifier
- @identifier = OPTIONS.fetch(:port)
- end
- end
- # this case covers starting by mongrel_rails
- def check_for_mongrel
- return unless defined?(Mongrel::HttpServer)
- @environment = :mongrel
-
- # Get the port from the server if it's started
- ObjectSpace.each_object(Mongrel::HttpServer) do |mongrel|
- next if not mongrel.respond_to? :port
- @identifier = mongrel.port.to_s
- end
-
- # Get the port from the configurator if one was created
- if @identifier.nil? && defined?(Mongrel::Configurator)
- ObjectSpace.each_object(Mongrel::Configurator) do |mongrel|
- @identifier = mongrel.defaults[:port] && mongrel.defaults[:port].to_s
- end
- end
-
- # Still can't find the port. Let's look at ARGV to fall back
- @identifier = default_port if @identifier.nil?
- end
-
- def check_for_thin
- if defined? Thin::Server
- # This case covers the thin web server
- # Same issue as above- we assume only one instance per process
- ObjectSpace.each_object(Thin::Server) do |thin_server|
- @environment = :thin
- backend = thin_server.backend
- # We need a way to uniquely identify and distinguish agents. The port
- # works for this. When using sockets, use the socket file name.
- if backend.respond_to? :port
- @identifier = backend.port
- elsif backend.respond_to? :socket
- @identifier = backend.socket
- else
- raise "Unknown thin backend: #{backend}"
- end
- end # each thin instance
- end
- end
-
- def check_for_jruby
- if RUBY_PLATFORM =~ /java/
- # Check for JRuby environment. Not sure how this works in different appservers
- require 'java'
- require 'jruby'
- @environment = :jruby
- @identifier = 'jruby'
- @identifier += ":#{config['app_name']}" if config['app_name']
- end
- end
-
- def check_for_litespeed
- if caller.pop =~ /fcgi-bin\/RailsRunner\.rb/
- @environment = :litespeed
- @identifier = 'litespeed'
- @identifier += ":#{config['app_name']}" if config['app_name']
- end
- end
-
- def check_for_passenger
- if defined?(Passenger::AbstractServer) || defined?(IN_PHUSION_PASSENGER)
- @environment = :passenger
- @identifier = 'passenger'
- @identifier += ":#{config['app_name']}" if config['app_name']
- end
- end
-
- def check_for_daemon
- if config['monitor_daemons']
- @environment = :daemon
- # return the base part of the file name
- @identifier = File.basename($0).split(".").first
- end
- end
- private
- def config
- NewRelic::Config.instance
- end
-
- def default_port
- require 'optparse'
- # If nothing else is found, use the 3000 default
- default_port = 3000
- ARGV.clone.options do |opts|
- opts.on("-p", "--port=port", String) { | default_port | }
- opts.parse!
- end
- default_port
- end
- end
-end
View
6 vendor/plugins/newrelic_rpm/lib/new_relic/merbtasks.rb
@@ -1,6 +0,0 @@
-namespace :newrelic do
- desc "Install the developer mode newrelic.yml file"
- task :default do
- load File.expand_path(File.join(__FILE__,"..","..","install.rb"))
- end
-end
View
26 vendor/plugins/newrelic_rpm/lib/new_relic/metric_data.rb
@@ -1,26 +0,0 @@
-module NewRelic
- class MetricData
- attr_accessor :metric_spec
- attr_accessor :metric_id
- attr_accessor :stats
-
- def initialize(metric_spec, stats, metric_id)
- self.metric_spec = metric_spec
- self.stats = stats
- self.metric_id = metric_id
- end
-
- def eql?(o)
- (metric_spec.eql? o.metric_spec) && (stats.eql? o.stats)
- end
-
- def hash
- metric_spec.hash + stats.hash
- end
-
- def to_s
- "#{metric_spec.name}(#{metric_spec.scope}): #{stats}" if metric_spec
- "#{metric_id}: #{stats}" if metric_spec.nil?
- end
- end
-end
View
39 vendor/plugins/newrelic_rpm/lib/new_relic/metric_spec.rb
@@ -1,39 +0,0 @@
-# this struct uniquely defines a metric, optionally inside
-# the call scope of another metric
-class NewRelic::MetricSpec
- attr_accessor :name
- attr_accessor :scope
-
- def initialize (name, scope = '')
- self.name = name
- self.scope = scope
- end
-
- def eql? (o)
- scope_equal = scope.nil? ? o.scope.nil? : scope.eql?(o.scope)
- name.eql?(o.name) && scope_equal
- end
-
- def hash
- h = name.hash
- h += scope.hash unless scope.nil?
- h
- end
-
- def <=>(o)
- namecmp = name <=> o.name
- return namecmp if namecmp != 0
-
- # i'm sure there's a more elegant way to code this correctly, but at least this passes
- # my unit test
- if scope.nil? && o.scope.nil?
- return 0
- elsif scope.nil?
- return -1
- elsif o.scope.nil?
- return 1
- else
- return scope <=> o.scope
- end
- end
-end
View
7 vendor/plugins/newrelic_rpm/lib/new_relic/metrics.rb
@@ -1,7 +0,0 @@
-module NewRelic::Metrics
- CONTROLLER = "Controller"
- DISPATCHER = "Rails/HTTP Dispatch"
- ACTIVE_RECORD = "ActiveRecord"
- USER_TIME = "CPU/User Time"
- MEMORY = "Memory/Physical"
-end
View
95 vendor/plugins/newrelic_rpm/lib/new_relic/shim_agent.rb
@@ -1,95 +0,0 @@
-require 'new_relic/stats'
-
-# This agent is loaded by the plug when the plug-in is disabled
-# It recreates just enough of the API to not break any clients that
-# invoke the Agent
-
-
-# from method_tracer.rb
-
-class Module
-
- def trace_method_execution (*args)
- yield
- end
-
- def add_method_tracer (*args)
- end
-
- def remove_method_tracer(*args)
- end
-
-end
-
-
-# from agent.rb
-
-module NewRelic
- module Agent
-
- class << self
- @@dummy_stats = NewRelic::MethodTraceStats.new
- def agent
- NewRelic::Agent::Agent.instance
- end
-
- alias instance agent
-
- def get_stats(*args)
- @@dummy_stats
- end
- def get_stats_no_scope(*args)
- @@dummy_stats
- end
-
- def manual_start(*args)
- end
-
- def set_sql_obfuscator(*args)
- end
-
- def disable_sql_recording
- yield
- end
-
- def disable_transaction_tracing
- yield
- end
-
- def add_request_parameters(*args)
- end
-
- def should_ignore_error
- end
- end
-
- class Agent
-
- def initialize
- @error_collector = ErrorCollector.new
- end
- def self.instance
- @@agent ||= new
- end
- end
-
- class ErrorCollector
- def notice_error(*args)
- end
- end
-
- end
-end
-
-
-module ActionController
- class Base
- def newrelic_notice_error(*args); end
- def self.newrelic_ignore(*args); end
- def new_relic_trace_controller_action(name); yield; end
- def newrelic_metric_path; end
- def perform_action_with_newrelic_trace(path=nil)
- yield
- end
- end
-end if defined? ActionController::Base
View
27 vendor/plugins/newrelic_rpm/lib/newrelic_rpm.rb
@@ -1,27 +0,0 @@
-# Initialization script for the gem.
-# Add
-# config.gem 'newrelic_rpm'
-# to your initialization sequence.
-#
-require 'new_relic/config'
-
-def log!(message)
- STDERR.puts "[NewRelic] #{message}"
-end
-
-# START THE AGENT
-# We install the shim agent unless the tracers are enabled, the plugin
-# env setting is not false, and the agent started okay.
-if !NewRelic::Config.instance.tracers_enabled?
- require 'new_relic/shim_agent'
-else
- # After verison 2.0 of Rails we can access the configuration directly.
- # We need it to add dev mode routes after initialization finished.
- if defined? Rails.configuration
- Rails.configuration.after_initialize do
- NewRelic::Config.instance.start_plugin Rails.configuration
- end
- else
- NewRelic::Config.instance.start_plugin
- end
-end
View
17 vendor/plugins/newrelic_rpm/lib/tasks/agent_tests.rake
@@ -1,17 +0,0 @@
-# run unit tests for the NewRelic Agent
-if defined? Rake::TestTask
-
-namespace :test do
- AGENT_HOME = File.expand_path(File.join(File.dirname(__FILE__), "..",".."))
- Rake::TestTask.new(:agent) do |t|
- t.libs << "#{AGENT_HOME}/test"
- t.libs << "#{AGENT_HOME}/lib"
- t.pattern = "#{AGENT_HOME}/test/**/tc_*.rb"
- t.verbose = true
- end
- Rake::Task['test:agent'].comment = "Run the unit tests for the Agent"
-
- Rake::TestTask.new(:all => ["test", "test:agent"])
- Rake::Task['test:all'].comment = "Run all tests including agent code"
-end
-end
View
4 vendor/plugins/newrelic_rpm/lib/tasks/all.rb
@@ -1,4 +0,0 @@
-# This is required to load in task definitions from merb
-Dir.glob(File.join(File.dirname(__FILE__),'*.rake')) do |file|
- load file
-end
View
7 vendor/plugins/newrelic_rpm/lib/tasks/install.rake
@@ -1,7 +0,0 @@
-# run unit tests for the NewRelic Agent
-namespace :newrelic do
- desc "install a default config/newrelic.yml file"
- task :install do
- load File.expand_path(File.join(File.dirname(__FILE__), "..", "..", "install.rb"))
- end
-end
View
9 vendor/plugins/newrelic_rpm/newrelic_spec.rb
@@ -1,9 +0,0 @@
-# Specs not currently implemented. Unit tests may only run when this is installed
-# as a plugin in a Rails application.
-require File.dirname(__FILE__) + '/spec_helper'
-
-describe "newrelic" do
- it "should do nothing" do
- true.should == true
- end
-end
View
6 vendor/plugins/newrelic_rpm/recipes/newrelic.rb
@@ -1,6 +0,0 @@
-# The capistrano recipes in plugins are automatically
-# loaded from here. From gems, they are available from
-# the lib directory. We have to make them available from
-# both locations
-
-require File.join(File.dirname(__FILE__),'..','lib','new_relic','recipes')
View
1  vendor/plugins/newrelic_rpm/spec_helper.rb
@@ -1 +0,0 @@
-$:.push File.join(File.dirname(__FILE__), '..', 'lib')
View
40 vendor/plugins/newrelic_rpm/test/new_relic/agent/mock_ar_connection.rb
@@ -1,40 +0,0 @@
-module ActiveRecord
- class Base
- class << self
- def test_connection(config)
- @connect ||= Connection.new
- end
- end
- end
-
- class Connection
- attr_accessor :throw
- attr_reader :disconnected
-
- def initialize
- @disconnected = false
- @throw = false
- end
-
- def disconnect!()
- @disconnected = true
- end
-
- def find()
- # used to test that we've instrumented this...
- end