Skip to content
Browse files

remove vendored new relic plugin

  • Loading branch information...
1 parent 0ca4e54 commit aa2411e4d91781e9042d4aebb635dbd697a7e84c @sudara committed Oct 9, 2011
Showing with 1 addition and 19,378 deletions.
  1. +1 −1 config/unicorn.rb
  2. +0 −279 vendor/plugins/newrelic_rpm/CHANGELOG
  3. +0 −37 vendor/plugins/newrelic_rpm/LICENSE
  4. +0 −138 vendor/plugins/newrelic_rpm/README.md
  5. +0 −22 vendor/plugins/newrelic_rpm/Rakefile
  6. +0 −33 vendor/plugins/newrelic_rpm/bin/mongrel_rpm
  7. +0 −4 vendor/plugins/newrelic_rpm/bin/newrelic_cmd
  8. +0 −34 vendor/plugins/newrelic_rpm/cert/cacert.pem
  9. +0 −38 vendor/plugins/newrelic_rpm/init.rb
  10. +0 −37 vendor/plugins/newrelic_rpm/install.rb
  11. +0 −208 vendor/plugins/newrelic_rpm/lib/new_relic/agent.rb
  12. +0 −618 vendor/plugins/newrelic_rpm/lib/new_relic/agent/agent.rb
  13. +0 −13 vendor/plugins/newrelic_rpm/lib/new_relic/agent/chained_call.rb
  14. +0 −61 vendor/plugins/newrelic_rpm/lib/new_relic/agent/collection_helper.rb
  15. +0 −119 vendor/plugins/newrelic_rpm/lib/new_relic/agent/error_collector.rb
  16. +0 −18 vendor/plugins/newrelic_rpm/lib/new_relic/agent/instrumentation/active_merchant.rb
  17. +0 −81 vendor/plugins/newrelic_rpm/lib/new_relic/agent/instrumentation/active_record_instrumentation.rb
  18. +0 −193 vendor/plugins/newrelic_rpm/lib/new_relic/agent/instrumentation/controller_instrumentation.rb
  19. +0 −90 vendor/plugins/newrelic_rpm/lib/new_relic/agent/instrumentation/data_mapper.rb
  20. +0 −127 vendor/plugins/newrelic_rpm/lib/new_relic/agent/instrumentation/dispatcher_instrumentation.rb
  21. +0 −14 vendor/plugins/newrelic_rpm/lib/new_relic/agent/instrumentation/error_instrumentation.rb
  22. +0 −18 vendor/plugins/newrelic_rpm/lib/new_relic/agent/instrumentation/memcache.rb
  23. +0 −26 vendor/plugins/newrelic_rpm/lib/new_relic/agent/instrumentation/merb/controller.rb
  24. +0 −13 vendor/plugins/newrelic_rpm/lib/new_relic/agent/instrumentation/merb/dispatcher.rb
  25. +0 −8 vendor/plugins/newrelic_rpm/lib/new_relic/agent/instrumentation/merb/errors.rb
  26. +0 −20 vendor/plugins/newrelic_rpm/lib/new_relic/agent/instrumentation/passenger_instrumentation.rb
  27. +0 −58 vendor/plugins/newrelic_rpm/lib/new_relic/agent/instrumentation/rails/action_controller.rb
  28. +0 −27 vendor/plugins/newrelic_rpm/lib/new_relic/agent/instrumentation/rails/action_web_service.rb
  29. +0 −38 vendor/plugins/newrelic_rpm/lib/new_relic/agent/instrumentation/rails/dispatcher.rb
  30. +0 −24 vendor/plugins/newrelic_rpm/lib/new_relic/agent/instrumentation/rails/errors.rb
  31. +0 −195 vendor/plugins/newrelic_rpm/lib/new_relic/agent/method_tracer.rb
  32. +0 −125 vendor/plugins/newrelic_rpm/lib/new_relic/agent/patch_const_missing.rb
  33. +0 −12 vendor/plugins/newrelic_rpm/lib/new_relic/agent/sampler.rb
  34. +0 −44 vendor/plugins/newrelic_rpm/lib/new_relic/agent/samplers/cpu_sampler.rb
  35. +0 −130 vendor/plugins/newrelic_rpm/lib/new_relic/agent/samplers/memory_sampler.rb
  36. +0 −22 vendor/plugins/newrelic_rpm/lib/new_relic/agent/samplers/mongrel_sampler.rb
  37. +0 −11 vendor/plugins/newrelic_rpm/lib/new_relic/agent/shim_agent.rb
  38. +0 −286 vendor/plugins/newrelic_rpm/lib/new_relic/agent/stats_engine.rb
  39. +0 −309 vendor/plugins/newrelic_rpm/lib/new_relic/agent/transaction_sampler.rb
  40. +0 −118 vendor/plugins/newrelic_rpm/lib/new_relic/agent/worker_loop.rb
  41. +0 −147 vendor/plugins/newrelic_rpm/lib/new_relic/commands/deployments.rb
  42. +0 −30 vendor/plugins/newrelic_rpm/lib/new_relic/commands/new_relic_commands.rb
  43. +0 −428 vendor/plugins/newrelic_rpm/lib/new_relic/control.rb
  44. +0 −22 vendor/plugins/newrelic_rpm/lib/new_relic/control/merb.rb
  45. +0 −141 vendor/plugins/newrelic_rpm/lib/new_relic/control/rails.rb
  46. +0 −33 vendor/plugins/newrelic_rpm/lib/new_relic/control/ruby.rb
  47. +0 −266 vendor/plugins/newrelic_rpm/lib/new_relic/local_environment.rb
  48. +0 −6 vendor/plugins/newrelic_rpm/lib/new_relic/merbtasks.rb
  49. +0 −33 vendor/plugins/newrelic_rpm/lib/new_relic/metric_data.rb
  50. +0 −111 vendor/plugins/newrelic_rpm/lib/new_relic/metric_parser.rb
  51. +0 −9 vendor/plugins/newrelic_rpm/lib/new_relic/metric_parser/action_mailer.rb
  52. +0 −26 vendor/plugins/newrelic_rpm/lib/new_relic/metric_parser/active_merchant.rb
  53. +0 −11 vendor/plugins/newrelic_rpm/lib/new_relic/metric_parser/active_record.rb
  54. +0 −51 vendor/plugins/newrelic_rpm/lib/new_relic/metric_parser/controller.rb
  55. +0 −38 vendor/plugins/newrelic_rpm/lib/new_relic/metric_parser/controller_cpu.rb
  56. +0 −23 vendor/plugins/newrelic_rpm/lib/new_relic/metric_parser/database.rb
  57. +0 −6 vendor/plugins/newrelic_rpm/lib/new_relic/metric_parser/errors.rb
  58. +0 −12 vendor/plugins/newrelic_rpm/lib/new_relic/metric_parser/mem_cache.rb
  59. +0 −61 vendor/plugins/newrelic_rpm/lib/new_relic/metric_parser/view.rb
  60. +0 −9 vendor/plugins/newrelic_rpm/lib/new_relic/metric_parser/web_service.rb
  61. +0 −48 vendor/plugins/newrelic_rpm/lib/new_relic/metric_spec.rb
  62. +0 −7 vendor/plugins/newrelic_rpm/lib/new_relic/metrics.rb
  63. +0 −25 vendor/plugins/newrelic_rpm/lib/new_relic/noticed_error.rb
  64. +0 −5 vendor/plugins/newrelic_rpm/lib/new_relic/rack.rb
  65. +0 −57 vendor/plugins/newrelic_rpm/lib/new_relic/rack/metric_app.rb
  66. +0 −25 vendor/plugins/newrelic_rpm/lib/new_relic/rack/newrelic.ru
  67. +0 −25 vendor/plugins/newrelic_rpm/lib/new_relic/rack/newrelic.yml
  68. +0 −82 vendor/plugins/newrelic_rpm/lib/new_relic/recipes.rb
  69. +0 −345 vendor/plugins/newrelic_rpm/lib/new_relic/stats.rb
  70. +0 −121 vendor/plugins/newrelic_rpm/lib/new_relic/transaction_analysis.rb
  71. +0 −575 vendor/plugins/newrelic_rpm/lib/new_relic/transaction_sample.rb
  72. +0 −47 vendor/plugins/newrelic_rpm/lib/new_relic/version.rb
  73. +0 −256 vendor/plugins/newrelic_rpm/lib/new_relic_api.rb
  74. +0 −40 vendor/plugins/newrelic_rpm/lib/newrelic_rpm.rb
  75. +0 −4 vendor/plugins/newrelic_rpm/lib/tasks/all.rb
  76. +0 −7 vendor/plugins/newrelic_rpm/lib/tasks/install.rake
  77. +0 −13 vendor/plugins/newrelic_rpm/lib/tasks/tests.rake
  78. +0 −189 vendor/plugins/newrelic_rpm/newrelic.yml
  79. +0 −6 vendor/plugins/newrelic_rpm/recipes/newrelic.rb
  80. +0 −55 vendor/plugins/newrelic_rpm/test/active_record_fixtures.rb
  81. +0 −46 vendor/plugins/newrelic_rpm/test/config/newrelic.yml
  82. +0 −39 vendor/plugins/newrelic_rpm/test/config/test_control.rb
  83. +0 −192 vendor/plugins/newrelic_rpm/test/new_relic/agent/active_record_instrumentation_test.rb
  84. +0 −104 vendor/plugins/newrelic_rpm/test/new_relic/agent/agent_test.rb
  85. +0 −42 vendor/plugins/newrelic_rpm/test/new_relic/agent/agent_test_controller.rb
  86. +0 −56 vendor/plugins/newrelic_rpm/test/new_relic/agent/classloader_patch_test.rb
  87. +0 −118 vendor/plugins/newrelic_rpm/test/new_relic/agent/collection_helper_test.rb
  88. +0 −107 vendor/plugins/newrelic_rpm/test/new_relic/agent/controller_test.rb
  89. +0 −70 vendor/plugins/newrelic_rpm/test/new_relic/agent/dispatcher_instrumentation_test.rb
  90. +0 −155 vendor/plugins/newrelic_rpm/test/new_relic/agent/error_collector_test.rb
  91. +0 −300 vendor/plugins/newrelic_rpm/test/new_relic/agent/method_tracer_test.rb
  92. +0 −56 vendor/plugins/newrelic_rpm/test/new_relic/agent/metric_data_test.rb
  93. +0 −40 vendor/plugins/newrelic_rpm/test/new_relic/agent/mock_ar_connection.rb
  94. +0 −23 vendor/plugins/newrelic_rpm/test/new_relic/agent/mock_scope_listener.rb
  95. +0 −266 vendor/plugins/newrelic_rpm/test/new_relic/agent/stats_engine_test.rb
  96. +0 −13 vendor/plugins/newrelic_rpm/test/new_relic/agent/testable_agent.rb
  97. +0 −195 vendor/plugins/newrelic_rpm/test/new_relic/agent/transaction_sample_builder_test.rb
  98. +0 −171 vendor/plugins/newrelic_rpm/test/new_relic/agent/transaction_sample_test.rb
  99. +0 −317 vendor/plugins/newrelic_rpm/test/new_relic/agent/transaction_sampler_test.rb
  100. +0 −101 vendor/plugins/newrelic_rpm/test/new_relic/agent/worker_loop_test.rb
  101. +0 −97 vendor/plugins/newrelic_rpm/test/new_relic/control_test.rb
  102. +0 −68 vendor/plugins/newrelic_rpm/test/new_relic/deployments_api_test.rb
  103. +0 −75 vendor/plugins/newrelic_rpm/test/new_relic/environment_test.rb
  104. +0 −142 vendor/plugins/newrelic_rpm/test/new_relic/metric_parser_test.rb
  105. +0 −177 vendor/plugins/newrelic_rpm/test/new_relic/metric_spec_test.rb
  106. +0 −71 vendor/plugins/newrelic_rpm/test/new_relic/samplers_test.rb
  107. +0 −9 vendor/plugins/newrelic_rpm/test/new_relic/shim_agent_test.rb
  108. +0 −291 vendor/plugins/newrelic_rpm/test/new_relic/stats_test.rb
  109. +0 −46 vendor/plugins/newrelic_rpm/test/new_relic/version_number_test.rb
  110. +0 −17 vendor/plugins/newrelic_rpm/test/test_helper.rb
  111. +0 −14 vendor/plugins/newrelic_rpm/test/ui/newrelic_controller_test.rb
  112. +0 −53 vendor/plugins/newrelic_rpm/test/ui/newrelic_helper_test.rb
  113. +0 −212 vendor/plugins/newrelic_rpm/ui/controllers/newrelic_controller.rb
  114. +0 −55 vendor/plugins/newrelic_rpm/ui/helpers/google_pie_chart.rb
  115. +0 −315 vendor/plugins/newrelic_rpm/ui/helpers/newrelic_helper.rb
  116. +0 −47 vendor/plugins/newrelic_rpm/ui/views/layouts/newrelic_default.rhtml
  117. +0 −27 vendor/plugins/newrelic_rpm/ui/views/newrelic/_explain_plans.rhtml
  118. +0 −15 vendor/plugins/newrelic_rpm/ui/views/newrelic/_sample.rhtml
  119. +0 −28 vendor/plugins/newrelic_rpm/ui/views/newrelic/_segment.rhtml
  120. +0 −1 vendor/plugins/newrelic_rpm/ui/views/newrelic/_segment_limit_message.rhtml
  121. +0 −14 vendor/plugins/newrelic_rpm/ui/views/newrelic/_segment_row.rhtml
  122. +0 −24 vendor/plugins/newrelic_rpm/ui/views/newrelic/_show_sample_detail.rhtml
  123. +0 −20 vendor/plugins/newrelic_rpm/ui/views/newrelic/_show_sample_sql.rhtml
  124. +0 −3 vendor/plugins/newrelic_rpm/ui/views/newrelic/_show_sample_summary.rhtml
  125. +0 −11 vendor/plugins/newrelic_rpm/ui/views/newrelic/_sql_row.rhtml
  126. +0 −30 vendor/plugins/newrelic_rpm/ui/views/newrelic/_stack_trace.rhtml
  127. +0 −12 vendor/plugins/newrelic_rpm/ui/views/newrelic/_table.rhtml
  128. +0 −42 vendor/plugins/newrelic_rpm/ui/views/newrelic/explain_sql.rhtml
  129. BIN vendor/plugins/newrelic_rpm/ui/views/newrelic/images/arrow-close.png
  130. BIN vendor/plugins/newrelic_rpm/ui/views/newrelic/images/arrow-open.png
  131. BIN vendor/plugins/newrelic_rpm/ui/views/newrelic/images/blue_bar.gif
  132. BIN vendor/plugins/newrelic_rpm/ui/views/newrelic/images/file_icon.png
  133. BIN vendor/plugins/newrelic_rpm/ui/views/newrelic/images/gray_bar.gif
  134. BIN vendor/plugins/newrelic_rpm/ui/views/newrelic/images/new_relic_rpm_desktop.gif
  135. +0 −45 vendor/plugins/newrelic_rpm/ui/views/newrelic/index.rhtml
  136. +0 −7,288 vendor/plugins/newrelic_rpm/ui/views/newrelic/javascript/prototype-scriptaculous.js
  137. +0 −107 vendor/plugins/newrelic_rpm/ui/views/newrelic/javascript/transaction_sample.js
  138. +0 −2 vendor/plugins/newrelic_rpm/ui/views/newrelic/sample_not_found.rhtml
  139. +0 −77 vendor/plugins/newrelic_rpm/ui/views/newrelic/show_sample.rhtml
  140. +0 −3 vendor/plugins/newrelic_rpm/ui/views/newrelic/show_source.rhtml
  141. +0 −433 vendor/plugins/newrelic_rpm/ui/views/newrelic/stylesheets/style.css
  142. +0 −52 vendor/plugins/newrelic_rpm/ui/views/newrelic/threads.rhtml
View
2 config/unicorn.rb
@@ -22,7 +22,7 @@
# Not good for some apps, this causes the master to use slighty more ram than a
# worker process. Otherwise it is about 14MB
- preload_app true
+preload_app true
# REE - http://www.rubyenterpriseedition.com/faq.html#adapt_apps_for_cow
if config['APP_RUBY'] == 'ree'
View
279 vendor/plugins/newrelic_rpm/CHANGELOG
@@ -1,279 +0,0 @@
-v2.9.5
- * Fix memory sampling on Snow Leopard (No more ps rsz option)
-
-v2.9.4
- * Clamp size of data sent to server
- * Reset statistics for passenger when forking to avoid erroneous data
- * Fix problem deserializing errors from the server
- * Fix incompatibility with postgres introduced in 2.9.
-
-v2.9.3.
- * Fix startup failure in Windows due to memory sampler
- * Add JRuby environment information
-v2.9.2.
- * change default apdex_t to 0.5 seconds
- * fix bug in deployments introduced by multi_homed setting
- * support overriding the log in the agent api
- * fix JRuby problem using objectspace
- * display custom parameters when looking at transactions in dev mode
- * display count of sql statements on the list of transactions in dev mode
- * fixes for merb--thanks to Carl Lerche
-
-v2.9.1.
- * add newrelic_ignore_apdex method to controller classes to allow
- you to omit some actions from apdex statistics
- * Add hook for Passenger shutdown events to get more timely shutdown
- notices; this will help in more accurate memory readings in
- Passenger
- * add newrelic_notice_error to Object class
- * optional ability to verify SSL certificates, note that this has some
- performance and reliability implications
- * support multi-homed host with multiple apps running on duplicate
- ports
-
-v2.9.0.
- Noteworthy Enhancements
- * give visibility to templates and partials in Rails 2.1 and later, in
- dev mode and production
- * change active record metrics to capture statistics in adapter log()
- call, resulting in lower overhead and improved visibility into
- different DB operations; only AR operations that are not hitting the
- query cache will be measured to avoid overhead
- * added mongrel_rpm to the gem, a standalone daemon listening for custom
- metric values sent from local processes (experimental); do mongrel_rpm
- --help
- * add API for system monitoring daemons (refer to KB articles); changed
- API for manual starting of the agent; refer to
- NewRelic::Agent.manual_start for details
- * do certificate verification on ssl connections to
- collector.newrelic.com
- * support instances appearing in more than one application by allowing a
- semicolon separated list of names for the newrelic.yml app_name
- setting.
- * combined agent logfiles into a single logfile
- * use rpm server time for transaction traces rather than agent time
-
- Developer Mode (only) Enhancements
- * show partial rendering in traces
- * improved formatting of metric names in traces
- * added number of queries to transactions in the transaction list
- * added some sorting options for the transaction list
- * added a page showing the list of active threads
-
- Compatibility Enhancements
- * ruby 1.9.1 compatibility
- * support concurrency when determining busy times, for 2.2 compatibility
- * in jruby, use Java used heap for memory sampling if the system memory
- is not accessible from an unsupported platform
- * jruby will no longer start the agent now when running the console or
- rake tasks
- * API support for RPM as a footnote add-in
- * webrick support restored
-
- Noteworthy bugfixes
- * sample memory on linux by reading /proc/#{$$}/status file
- * fixed ambiguous 'View' metrics showing up in controller breakdown
- * removed Numeric extensions, including round_to, and to_ms
- * using a different timeout mechanism when we post data to RPM
- * remove usage of Rails::Info which had a side effect of enabling
- ActiveRecord even when it wasn't an active framework
- * moved CPU sampler off background thread and onto the harvest thread
- * tests now run cleanly in any rails app using test:newrelic or
- test:plugins
-
- Agent improvements to support future RPM enhancements
- * add instrumentation to capture metrics on response codes; not yet
- working in rails 2.3.*
- * added http referer to traced errors
- * capture gem requirements from rails
- * capture cpu utilization adjusted for processor count
- * transaction sampling
-
-v2.8.10.
- * fix thin support with rails 2.3.2 when using script/server
- * fix incompatibility with rails 2.3.2 and script/server options
- processing
- * minor tweak to environment gathering for gem mode
-
-v2.8.9
- * fix problem finding the newrelic controller in dev mode
- * fix incompatibility with older versions of optparse
- * fix potential jvm problem with jruby
- * remove test:all task definition to avoid conflicts
- * change error message about window sampler in windows not supported to a
- warning message
-
-v2.8.8
- * fix error with jruby on windows
- * fix problem where webrick was being incorrectly detected causing some
- problems with mongrel application assignments--had to disable webrick
- for now
-
-v2.8.7
- * fix for ssl connection hanging problems
- * fix problem recognizing mongrel in rails 2.3.2
- * fastcgi support in rails 2.3.2
- * put back webrick support
-
-v2.8.6
- * fix for capture_params when using file uploads in controller actions
- * use pure ruby NS lookup for collector host to eliminate possibly
- blocking applications
-
-v2.8.5
- * fix reference to CommandError which was breaking some cap scripts
- * fix incompatibility with Rails 2.0 in the server API
- * fix problem with litespeed with Lite accounts
- * fix problem when ActiveRecord is disabled
- * moved merb instrumentation to Merb::Controller instead of
- AbstractController to address incompatibility with MailController
- * fix problem in devmode displaying sql with embedded urls
-
-v2.8.4
- * fix bug in capistrano recipe causing cap commands to fail with error
- about not finding Version class
-
-v2.8.3
- * refactor unit tests so they will run in a generic rails environment
- * require classes in advance to avoid autoloading. this is to address
- incompatibilities with desert as well as more flexibility in gem
- initialization
- * fixed newrelic_helper.rb 1.9 incompatibility
-
-v2.8.2
- * fix Ruby 1.9 syntax compatibility errors
- * update the class loading sanity check, will notify server of errors
- * fix agent output on script and rake task execution
-
-v2.8.1
- * Convert the deployment information upload script to an executable and
- put in the bin directory. When installed as a gem this command is
- symlinked to /usr/bin. Usage: newrelic_cmd deployments --help
- * Fix issue invoking api when host is not set in newrelic.yml
- * Fix deployments api so it will work from a gem
- * Fix thin incompatibility in developer mode
-
-v2.8.0
- * add beta of api in new_relic_api.rb
- * instrumented dynamic finders in ActiveRecord
- * preliminary support for capturing deployment information via capistrano
- * change memory sampler for solaris to use /usr/bin/ps
- * allow ERB in newrelic.yml file
- * merged support for merb into this version
- * fix incompatibility in the developer mode with the safe_erb plugin
- * fix module namespace issue causing an error accessing
- NewRelic::Instrumentation modules
- * fix issue where the agent sometimes failed to start up if there was a
- transient network problem
- * fix IgnoreSilentlyException message
-
-v2.7.4
- * fix error when trying to serialize some kinds of Enumerable objects
- * added extra debug logging
- * added app_name to app mapping
-
-v2.7.3
- * fix compatibility issue with 1.8.5 causing error with Dir.glob
-
-v2.7.2
- * fix problem with passenger edge not being a detected environment
-
-v2.7.1
- * fix problem with skipped dispatcher instrumentation
-
-v2.7.0
- * Repackage to support both plugin and Gem installation
- * Support passenger/litespeed/jruby application naming
- * Update method for calculating dispatcher queue time
- * Show stack traces in RPM Transaction Traces
- * Capture error source for TemplateErrors
- * Clean up error stack traces.
- * Support query plans from postgres
- * Performance tuning
- * bugfixes
-
-v2.5.3
- * fix error in transaction tracing causing traces not to show up
-
-v2.5.2
- * fixes for postgres explain plan support
-
-v2.5.1
- * bugfixes
-
-v2.5.0
- * add agent support for rpm 1.1 features
- * Fix regression error with thin support
-
-v2.4.3
- * added 'newrelic_ignore' controller class method with :except and :only options for finer grained control
- over the blocking of instrumentation in controllers.
- * bugfixes
-
-v2.4.2
- * error reporting in early access
-
-v2.4.1
- * bugfix: initializing developer mode
-
-v2.4.0
- * Beta support for LiteSpeed and Passenger
-
-v2.3.7
- * bugfixes
-
-v2.3.6
- * bugfixes
-
-v2.3.5
- * bugfixes: pie chart data, rails 1.1 compability
-
-v2.3.4
- * bugfix
-
-v2.3.3
- * bugfix for non-mysql databases
-
-v2.3.2
- * bugfixes
- * Add enhancement for Transaction Traces early access feature
-
-v2.3.1
- * bugfixes
-
-v2.3.0
- + Add support for Transaction Traces early access feature
-
-v2.2.2
- * bugfixes
-
-v2.2.1
- + Add rails 2.1 support for Developer Mode
- + Changes to memory sampler: Add support for JRuby and fix Solaris support.
- * Stop catching exceptions and start catching StandardError; other exception cleanup
- * Add protective exception catching to the stats engine
- * Improved support for thin domain sockets
- * Support JRuby environments
-
-v2.1.6
- * bugfixes
-
-v2.1.5
- * bugfixes
-
-v2.1.4
- * bugfixes
-
-v2.1.3
- * bugfixes
-
-v2.1.2
- * bugfixes
-
-v2.1.1
- * bugfixes
-
-v2.1.0
- * release for private beta
-
-
View
37 vendor/plugins/newrelic_rpm/LICENSE
@@ -1,37 +0,0 @@
-Copyright (c) 2008-2009 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
138 vendor/plugins/newrelic_rpm/README.md
@@ -1,138 +0,0 @@
-New Relic RPM
-=============
-
-New Relic RPM is a Ruby performance management system, developed by
-[New Relic, Inc](http://www.newrelic.com). 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
-dual-purposed as a either a Rails plugin or a Gem, hosted on
-[github](http://github.com/newrelic/rpm/tree/master) and 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.
-
-### Supported Environments
-
-* Ruby 1.8.6, 1.8.7 or 1.9.1
-* JRuby
-* Rails 1.2.6 or above
-* Merb 1.0 or above
-
-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
----------------
-
-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](http://rpm.newrelic.com).
-
-NOTE: You must have a valid account and license key to view this data
-online. Refer to instructions in *Getting Started*, below.
-
-Getting Started
-===============
-
-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.
-
-To use Developer Mode, simply install the gem or plugin into your
-application and follow the instructions below.
-
-To monitor your applications in production, create an account at
-[www.newrelic.com](http://newrelic.com/get-RPM.html). There you can
-sign up for a free Lite account or one of our paid subscriptions.
-
-Once you receive the welcome e-mail with a license key and
-`newrelic.yml` file, copy the `newrelic.yml` file into your app config
-directory.
-
-### 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
-
-### Github
-
-The agent is also available on Github under newrelic/rpm. Fork away!
-
-### Support
-
-Reach out to us--and to fellow RPM users--at
-[support.newrelic.com](http://support.newrelic.com/discussions/support).
-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](http://support.newrelic.com/discussions/support).
-
-Refer to [our website](http://www.newrelic.com/support) for other
-support channels.
-
-Thank you, and may your application scale to infinity plus one.
-
-Lew Cirne, Founder and CEO<br/>
-New Relic, Inc.
View
22 vendor/plugins/newrelic_rpm/Rakefile
@@ -1,22 +0,0 @@
-require 'rubygems'
-require 'lib/new_relic/version.rb'
-require 'echoe'
-
-GEM_NAME = "newrelic_rpm"
-GEM_VERSION = NewRelic::VERSION::STRING
-AUTHOR = "Bill Kayser"
-EMAIL = "bkayser@newrelic.com"
-HOMEPAGE = "http://www.newrelic.com"
-SUMMARY = "New Relic Ruby Performance Monitoring Agent"
-
-Echoe.new(GEM_NAME) do |p|
- p.author = AUTHOR
- p.summary = SUMMARY
- p.url = HOMEPAGE
- p.email = EMAIL
- p.project = 'newrelic'
- p.need_tar_gz = false
- p.need_gem = true
- p.ignore_pattern = %w[]
-end
-
View
33 vendor/plugins/newrelic_rpm/bin/mongrel_rpm
@@ -1,33 +0,0 @@
-#!/usr/bin/env ruby
-require 'rubygems'
-require 'rack'
-require 'rack/handler/mongrel'
-require 'optparse'
-
-port = 3000
-options = { }
-appname = nil
-OptionParser.new do |opts|
- opts.banner = "Usage: #{File.basename($0)} [options] [app_name]"
- opts.on("-p", "--port=port", Integer, "default: #{port}") { | port | }
- opts.on("--[no-]logging", "turn off request logging" ) { | l | options[:logging] = l }
- opts.on("--license=rpm_license_key", "override license key" ) { | l | options[:license_key] = l }
- opts.on("--install", "install a newrelic.yml template" ) { | l | options[:install] = true }
- opts.separator ""
- opts.separator "app_name is the name of the application where the metrics will be stored"
- opts.separator ""
- # The rackup file references this var
- appname = opts.parse!(ARGV.clone).first
-end
-
-options[:app_name] = appname if appname
-
-ru_file = File.expand_path(File.join(File.dirname(__FILE__), "..", "lib", "new_relic", "rack", "newrelic.ru"))
-rackup_code = File.read ru_file
-builder = Rack::Builder.new { eval rackup_code, binding, ru_file }
-
-options = { :Host => '127.0.0.1', :Port => port }
-Rack::Handler::Mongrel.run(builder.to_app, options) do | server |
- NewRelic::Control.instance.log! "Started Mongrel listening for '#{NewRelic::Control.instance.app_names.join(" and ")}' data at #{server.host}:#{server.port}"
-end
-
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
34 vendor/plugins/newrelic_rpm/cert/cacert.pem
@@ -1,34 +0,0 @@
------BEGIN CERTIFICATE-----
-MIIC5zCCAlACAQEwDQYJKoZIhvcNAQEFBQAwgbsxJDAiBgNVBAcTG1ZhbGlDZXJ0IFZhbGlkYXRp
-b24gTmV0d29yazEXMBUGA1UEChMOVmFsaUNlcnQsIEluYy4xNTAzBgNVBAsTLFZhbGlDZXJ0IENs
-YXNzIDEgUG9saWN5IFZhbGlkYXRpb24gQXV0aG9yaXR5MSEwHwYDVQQDExhodHRwOi8vd3d3LnZh
-bGljZXJ0LmNvbS8xIDAeBgkqhkiG9w0BCQEWEWluZm9AdmFsaWNlcnQuY29tMB4XDTk5MDYyNTIy
-MjM0OFoXDTE5MDYyNTIyMjM0OFowgbsxJDAiBgNVBAcTG1ZhbGlDZXJ0IFZhbGlkYXRpb24gTmV0
-d29yazEXMBUGA1UEChMOVmFsaUNlcnQsIEluYy4xNTAzBgNVBAsTLFZhbGlDZXJ0IENsYXNzIDEg
-UG9saWN5IFZhbGlkYXRpb24gQXV0aG9yaXR5MSEwHwYDVQQDExhodHRwOi8vd3d3LnZhbGljZXJ0
-LmNvbS8xIDAeBgkqhkiG9w0BCQEWEWluZm9AdmFsaWNlcnQuY29tMIGfMA0GCSqGSIb3DQEBAQUA
-A4GNADCBiQKBgQDYWYJ6ibiWuqYvaG9YLqdUHAZu9OqNSLwxlBfw8068srg1knaw0KWlAdcAAxIi
-GQj4/xEjm84H9b9pGib+TunRf50sQB1ZaG6m+FiwnRqP0z/x3BkGgagO4DrdyFNFCQbmD3DD+kCm
-DuJWBQ8YTfwggtFzVXSNdnKgHZ0dwN0/cQIDAQABMA0GCSqGSIb3DQEBBQUAA4GBAFBoPUn0LBwG
-lN+VYH+Wexf+T3GtZMjdd9LvWVXoP+iOBSoh8gfStadS/pyxtuJbdxdA6nLWI8sogTLDAHkY7FkX
-icnGah5xyf23dKUlRWnFSKsZ4UWKJWsZ7uW7EvV/96aNUcPwnXS3qT6gpf+2SQMT2iLM7XGCK5nP
-Orf1LXLI
------END CERTIFICATE-----
-
------BEGIN CERTIFICATE-----
-MIIC5zCCAlACAQEwDQYJKoZIhvcNAQEFBQAwgbsxJDAiBgNVBAcTG1ZhbGlDZXJ0IFZhbGlkYXRp
-b24gTmV0d29yazEXMBUGA1UEChMOVmFsaUNlcnQsIEluYy4xNTAzBgNVBAsTLFZhbGlDZXJ0IENs
-YXNzIDIgUG9saWN5IFZhbGlkYXRpb24gQXV0aG9yaXR5MSEwHwYDVQQDExhodHRwOi8vd3d3LnZh
-bGljZXJ0LmNvbS8xIDAeBgkqhkiG9w0BCQEWEWluZm9AdmFsaWNlcnQuY29tMB4XDTk5MDYyNjAw
-MTk1NFoXDTE5MDYyNjAwMTk1NFowgbsxJDAiBgNVBAcTG1ZhbGlDZXJ0IFZhbGlkYXRpb24gTmV0
-d29yazEXMBUGA1UEChMOVmFsaUNlcnQsIEluYy4xNTAzBgNVBAsTLFZhbGlDZXJ0IENsYXNzIDIg
-UG9saWN5IFZhbGlkYXRpb24gQXV0aG9yaXR5MSEwHwYDVQQDExhodHRwOi8vd3d3LnZhbGljZXJ0
-LmNvbS8xIDAeBgkqhkiG9w0BCQEWEWluZm9AdmFsaWNlcnQuY29tMIGfMA0GCSqGSIb3DQEBAQUA
-A4GNADCBiQKBgQDOOnHK5avIWZJV16vYdA757tn2VUdZZUcOBVXc65g2PFxTXdMwzzjsvUGJ7SVC
-CSRrCl6zfN1SLUzm1NZ9WlmpZdRJEy0kTRxQb7XBhVQ7/nHk01xC+YDgkRoKWzk2Z/M/VXwbP7Rf
-ZHM047QSv4dk+NoS/zcnwbNDu+97bi5p9wIDAQABMA0GCSqGSIb3DQEBBQUAA4GBADt/UG9vUJSZ
-SWI4OB9L+KXIPqeCgfYrx+jFzug6EILLGACOTb2oWH+heQC1u+mNr0HZDzTuIYEZoDJJKPTEjlbV
-UjP9UNV+mWwD5MlM/Mtsq2azSiGM5bUMMj4QssxsodyamEwCW/POuZ6lcg5Ktz885hZo+L7tdEy8
-W9ViH0Pd
------END CERTIFICATE-----
-
View
38 vendor/plugins/newrelic_rpm/init.rb
@@ -1,38 +0,0 @@
-# This is the initialization for the RPM Rails plugin
-require 'new_relic/control'
-
-# 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 the two lines at the
-# bottom of this file to verify the plugin is being loaded,
-# then send the output to support@newrelic.com if you are unable to
-# resolve the issue.
-
-# Initializer for the NewRelic Agent
-
-# We use this to test the agent to ensure it's not loading classes inappropriately
-#require 'new_relic/agent/patch_const_missing'
-#ClassLoadingWatcher.flag_const_missing = true
-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::Control.instance.init_plugin(defined?(config) ? {:config => config} : {})
- else
- NewRelic::Control.instance.log.debug "Attempt to initialize the plugin twice!"
- NewRelic::Control.instance.log.debug "Original call: \n#{::NEWRELIC_STARTED}"
- NewRelic::Control.instance.log.debug "Here we are now: \n#{caller.join("\n")}"
- end
-rescue => e
- NewRelic::Control.instance.log! "Error initializing New Relic plugin (#{e})", :error
- NewRelic::Control.instance.log! e.backtrace.join("\n"), :error
- NewRelic::Control.instance.log! "Agent is disabled."
-end
-#ClassLoadingWatcher.flag_const_missing = nil
-
-# ::RAILS_DEFAULT_LOGGER.warn "RPM detected environment: #{NewRelic::Control.instance.local_env.to_s}, RAILS_ENV: #{RAILS_ENV}"
-# ::RAILS_DEFAULT_LOGGER.warn "Enabled? #{NewRelic::Control.instance.agent_enabled?}"
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
208 vendor/plugins/newrelic_rpm/lib/new_relic/agent.rb
@@ -1,208 +0,0 @@
-# = New Relic Agent
-#
-# New Relic RPM is a performance monitoring application for Ruby applications running
-# in production. For more information on RPM please visit http://www.newrelic.com.
-#
-# The New Relic Agent can be installed in Ruby applications to gather runtime performance
-# metrics, traces, and errors for display in a Developer Mode UI (mapped to /newrelic in your application
-# server) or for monitoring and analysis at http://rpm.newrelic.com.
-#
-# For detailed information on configuring or customizing the RPM Agent please visit our
-# {support and documentation site}[http://support.newrelic.com].
-#
-# == Starting the Agent as a Gem
-#
-# For Rails, add:
-# config.gem 'newrelic_rpm'
-# to your initialization sequence.
-#
-# For merb, do
-# dependency 'newrelic_rpm'
-# in the Merb config/init.rb
-#
-# For other frameworks, or to manage the agent manually, invoke NewRelic::Agent#manual_start
-# directly.
-#
-# == Configuring the Agent
-#
-# All agent configuration is done in the +newrelic.yml+ file. This file is by
-# default read from the +config+ directory of the application root and is subsequently
-# searched for in the application root directory, and then in a +~/.newrelic+ directory
-#
-# == Agent APIs
-#
-# The agent has some APIs available for extending and customizing.
-#
-# :main: lib/new_relic/agent.rb
-module NewRelic
-
- # Methods in the Agent module are delegated to the NewRelic::Agent::Agent
- # singleton instance.
- module Agent
- extend self
-
- 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/metric_parser'
- 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/shim_agent'
- require 'new_relic/agent/method_tracer'
- 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 'new_relic/agent/sampler'
-
- require 'new_relic/agent/samplers/cpu_sampler'
- require 'new_relic/agent/samplers/memory_sampler'
- require 'new_relic/agent/samplers/mongrel_sampler'
- require 'set'
- require 'sync'
- require 'thread'
- require 'resolv'
- require 'timeout'
-
- # An exception that is thrown by the server if the agent license is invalid.
- class LicenseException < StandardError; end
-
- # An exception that forces an agent to stop reporting until its mongrel is restarted.
- class ForceDisconnectException < StandardError; end
-
- # Used to blow out of a periodic task without logging a an error, such as for routine
- # failures.
- class IgnoreSilentlyException < StandardError; end
-
- # Used for when a transaction trace or error report has too much
- # data, so we reset the queue to clear the extra-large item
- class PostTooBigException < IgnoreSilentlyException; end
-
- # Reserved for future use. Meant to represent a problem on the server side.
- class ServerError < StandardError; end
-
- class BackgroundLoadingError < StandardError; end
-
- @@agent = nil
-
- # The singleton Agent instance.
- def agent
- raise "Plugin not initialized!" if @@agent.nil?
- @@agent
- end
-
- def agent= new_instance
- @@agent = new_instance
- end
-
- alias instance agent
-
- # Get or create a statistics gatherer that will aggregate numerical data
- # under a metric name.
- #
- # +metric_name+ should follow a slash separated path convention. Application
- # specific metrics should begin with "Custom/".
- #
- # Return a NewRelic::Stats that accepts data
- # via calls to add_data_point(value).
- def get_stats(metric_name, use_scope=false)
- @@agent.stats_engine.get_stats(metric_name, use_scope)
- end
-
- def get_stats_no_scope(metric_name)
- @@agent.stats_engine.get_stats_no_scope(metric_name)
- end
-
- # Call this to manually start the Agent in situations where the Agent does
- # not auto-start.
- #
- # When the app environment loads, so does the Agent. However, the Agent will
- # only connect to RPM if a web front-end is found. If you want to selectively monitor
- # ruby processes that don't use web plugins, then call this method in your
- # code and the Agent will fire up and start reporting to RPM.
- #
- # Options are passed in as overrides for values in the newrelic.yml, such
- # as app_name. In addition, the option +log+ will take a logger that
- # will be used instead of the standard file logger. The setting for
- # the newrelic.yml section to use (ie, RAILS_ENV) can be overridden
- # with an :env argument.
- #
- def manual_start(options={})
- raise unless Hash === options
- # Ignore all args but hash options
- options.merge! :agent_enabled => true
- NewRelic::Control.instance.init_plugin options
- end
-
- # This method sets the block sent to this method as a sql obfuscator.
- # The block will be called with a single String SQL statement to obfuscate.
- # The method must return the obfuscated String SQL.
- # If chaining of obfuscators is required, use type = :before or :after
- #
- # type = :before, :replace, :after
- #
- # Example:
- #
- # NewRelic::Agent.set_sql_obfuscator(:replace) do |sql|
- # my_obfuscator(sql)
- # end
- #
- def set_sql_obfuscator(type = :replace, &block)
- agent.set_sql_obfuscator type, &block
- end
-
-
- # This method sets the state of sql recording in the transaction
- # sampler feature. Within the given block, no sql will be recorded
- #
- # usage:
- #
- # NewRelic::Agent.disable_sql_recording do
- # ...
- # end
- #
- def disable_sql_recording
- state = agent.set_record_sql(false)
- begin
- yield
- ensure
- agent.set_record_sql(state)
- end
- end
-
- # This method disables the recording of transaction traces in the given
- # block.
- def disable_transaction_tracing
- state = agent.set_record_tt(false)
- begin
- yield
- ensure
- agent.set_record_tt(state)
- end
- end
-
- # This method allows a filter to be applied to errors that RPM will track.
- # The block should return the exception to track (which could be different from
- # the original exception) or nil to ignore this exception
- #
- def ignore_error_filter(&block)
- agent.error_collector.ignore_error_filter(&block)
- end
-
- # Add parameters to the current transaction trace
- #
- def add_custom_parameters(params)
- agent.add_custom_parameters(params)
- end
-
- alias add_request_parameters add_custom_parameters
-
- end
-end
View
618 vendor/plugins/newrelic_rpm/lib/new_relic/agent/agent.rb
@@ -1,618 +0,0 @@
-require 'socket'
-require 'net/https'
-require 'net/http'
-require 'logger'
-require 'zlib'
-require 'stringio'
-
-# The NewRelic Agent collects performance data from ruby applications
-# in realtime as the application runs, and periodically sends that
-# data to the NewRelic server.
-module NewRelic::Agent
-
- # The Agent is a singleton that is instantiated when the plugin is
- # activated.
- class Agent
-
- # Specifies the version of the agent's communication protocol with
- # the NewRelic hosted site.
-
- PROTOCOL_VERSION = 5
-
- attr_reader :obfuscator
- attr_reader :stats_engine
- attr_reader :transaction_sampler
- attr_reader :error_collector
- attr_reader :worker_loop
- attr_reader :record_sql
-
- # Should only be called by NewRelic::Control
- def self.instance
- @instance ||= self.new
- end
- # This method is deprecated. Use NewRelic::Agent.manual_start
- def manual_start(ignored=nil, also_ignored=nil)
- raise "This method no longer supported. Instead use the class method NewRelic::Agent.manual_start"
- end
-
- # this method makes sure that the agent is running. it's important
- # for passenger where processes are forked and the agent is
- # dormant
- #
- def ensure_worker_thread_started
- return unless control.agent_enabled? && control.monitor_mode? && !@invalid_license
- if !running?
- launch_worker_thread
- @stats_engine.spawn_sampler_thread
- end
- end
-
- # True if the worker thread has been started. Doesn't necessarily
- # mean we are connected
- def running?
- control.agent_enabled? && control.monitor_mode? && @worker_loop && @worker_loop.pid == $$
- end
-
- # True if we have initialized and completed 'start'
- def started?
- @started
- end
-
- # Attempt a graceful shutdown of the agent.
- def shutdown
- return if not started?
- if @worker_loop
- @worker_loop.stop
-
- log.debug "Starting Agent shutdown"
-
- # if litespeed, then ignore all future SIGUSR1 - it's
- # litespeed trying to shut us down
-
- if control.dispatcher == :litespeed
- Signal.trap("SIGUSR1", "IGNORE")
- Signal.trap("SIGTERM", "IGNORE")
- end
-
- begin
- graceful_disconnect
- rescue => e
- log.error e
- log.error e.backtrace.join("\n")
- end
- end
- @started = nil
- end
-
- def start_transaction
- Thread::current[:custom_params] = nil
- @stats_engine.start_transaction
- end
-
- def end_transaction
- Thread::current[:custom_params] = nil
- @stats_engine.end_transaction
- end
-
- def set_record_sql(should_record)
- prev = Thread::current[:record_sql]
- Thread::current[:record_sql] = should_record
-
- prev || true
- end
-
- def set_record_tt(should_record)
- prev = Thread::current[:record_tt]
- Thread::current[:record_tt] = should_record
-
- prev || true
- end
-
- def add_custom_parameters(params)
- p = Thread::current[:custom_params] || (Thread::current[:custom_params] = {})
-
- p.merge!(params)
- end
-
- def custom_params
- Thread::current[:custom_params] || {}
- end
-
- def set_sql_obfuscator(type, &block)
- if type == :before
- @obfuscator = NewRelic::ChainedCall.new(block, @obfuscator)
- elsif type == :after
- @obfuscator = NewRelic::ChainedCall.new(@obfuscator, block)
- elsif type == :replace
- @obfuscator = block
- else
- fail "unknown sql_obfuscator type #{type}"
- end
- end
-
- def log
- NewRelic::Control.instance.log
- end
-
- # Start up the agent. This verifies that the agent_enabled? is
- # true and initializes the sampler based on the current
- # controluration settings. Then it will fire up the background
- # thread for sending data to the server if applicable.
- def start
- if started?
- control.log! "Agent Started Already!", :error
- return
- end
- return if !control.agent_enabled?
-
- @local_host = determine_host
-
- log.info "Web container: #{control.dispatcher.to_s}"
-
- if control.dispatcher == :passenger
- log.warn "Phusion Passenger has been detected. Some RPM memory statistics may have inaccuracies due to short process lifespans."
- end
-
- @started = true
-
- sampler_config = control.fetch('transaction_tracer', {})
- @use_transaction_sampler = sampler_config.fetch('enabled', true)
-
- @record_sql = sampler_config.fetch('record_sql', :obfuscated).to_sym
-
- # use transaction_threshold: 4.0 to force the TT collection
- # threshold to 4 seconds
- # use transaction_threshold: apdex_f to use your apdex t value
- # multiplied by 4
- # undefined transaction_threshold defaults to 2.0
- apdex_f = 4 * NewRelic::Control.instance['apdex_t'].to_f
- @slowest_transaction_threshold = sampler_config.fetch('transaction_threshold', 2.0)
- if @slowest_transaction_threshold =~ /apdex_f/i
- @slowest_transaction_threshold = apdex_f
- end
- @slowest_transaction_threshold = @slowest_transaction_threshold.to_f
-
- if @use_transaction_sampler
- log.info "Transaction tracing threshold is #{@slowest_transaction_threshold} seconds."
- else
- log.info "Transaction tracing not enabled."
- end
- @explain_threshold = sampler_config.fetch('explain_threshold', 0.5).to_f
- @explain_enabled = sampler_config.fetch('explain_enabled', true)
- @random_sample = sampler_config.fetch('random_sample', false)
- log.warn "Agent is configured to send raw SQL to RPM service" if @record_sql == :raw
- # Initialize transaction sampler
- @transaction_sampler.random_sampling = @random_sample
-
- if control.monitor_mode?
- # make sure the license key exists and is likely to be really a license key
- # by checking it's string length (license keys are 40 character strings.)
- if !control.license_key
- @invalid_license = true
- control.log! "No license key found. Please edit your newrelic.yml file and insert your license key.", :error
- elsif control.license_key.length != 40
- @invalid_license = true
- control.log! "Invalid license key: #{control.license_key}", :error
- else
- launch_worker_thread
- # When the VM shuts down, attempt to send a message to the
- # server that this agent run is stopping, assuming it has
- # successfully connected
- at_exit { shutdown }
- end
- end
- control.log! "New Relic RPM Agent #{NewRelic::VERSION::STRING} Initialized: pid = #{$$}"
- control.log! "Agent Log found in #{NewRelic::Control.instance.log_file}" if NewRelic::Control.instance.log_file
- end
-
- private
- def collector
- @collector ||= control.server
- end
-
- # Connect to the server, and run the worker loop forever.
- # Will not return.
- def run_worker_loop
-
- # connect to the server. this will keep retrying until
- # successful or it determines the license is bad.
- connect
-
- # We may not be connected now but keep going for dev mode
- if @connected
- begin
- # determine the reporting period (server based)
- # note if the agent attempts to report more frequently than
- # the specified report data, then it will be ignored.
-
- control.log! "Reporting performance data every #{@report_period} seconds."
- @worker_loop.add_task(@report_period) do
- harvest_and_send_timeslice_data
- end
-
- if @should_send_samples && @use_transaction_sampler
- @worker_loop.add_task(@report_period) do
- harvest_and_send_slowest_sample
- end
- elsif !control.developer_mode?
- # We still need the sampler for dev mode.
- @transaction_sampler.disable
- end
-
- if @should_send_errors && @error_collector.enabled
- @worker_loop.add_task(@report_period) do
- harvest_and_send_errors
- end
- end
- @worker_loop.run
- rescue StandardError
- @connected = false
- raise
- end
- end
- end
-
- def launch_worker_thread
- if (control.dispatcher == :passenger && $0 =~ /ApplicationSpawner/)
- log.debug "Process is passenger spawner - don't connect to RPM service"
- return
- end
-
- @worker_loop = WorkerLoop.new(log)
-
- if control['check_bg_loading']
- log.warn "Agent background loading checking turned on"
- require 'new_relic/agent/patch_const_missing'
- ClassLoadingWatcher.enable_warning
- end
-
- @worker_thread = Thread.new do
- begin
- ClassLoadingWatcher.background_thread=Thread.current if control['check_bg_loading']
-
- run_worker_loop
- rescue IgnoreSilentlyException
- control.log! "Unable to establish connection with the server. Run with log level set to debug for more information."
- rescue StandardError => e
- control.log! e, :error
- control.log! e.backtrace.join("\n "), :error
- end
- end
- @worker_thread['newrelic_label'] = 'Worker Loop'
-
- # This code should be activated to check that no dependency
- # loading is occuring in the background thread by stopping the
- # foreground thread after the background thread is created. Turn
- # on dependency loading logging and make sure that no loading
- # occurs.
- #
- # control.log! "FINISHED AGENT INIT"
- # while true
- # sleep 1
- # end
- end
-
- def control
- NewRelic::Control.instance
- end
-
- def initialize
- @connected = false
- @launch_time = Time.now
-
- @metric_ids = {}
-
- @stats_engine = NewRelic::Agent::StatsEngine.new
- @transaction_sampler = NewRelic::Agent::TransactionSampler.new(self)
- @error_collector = NewRelic::Agent::ErrorCollector.new(self)
-
- @request_timeout = NewRelic::Control.instance.fetch('timeout', 2 * 60)
-
- @invalid_license = false
-
- @last_harvest_time = Time.now
- end
-
- # Connect to the server and validate the license. If successful,
- # @connected has true when finished. If not successful, you can
- # keep calling this. Return false if we could not establish a
- # connection with the server and we should not retry, such as if
- # there's a bad license key.
- def connect
- # wait a few seconds for the web server to boot, necessary in development
- connect_retry_period = 5
- connect_attempts = 0
- @agent_id = nil
- begin
- sleep connect_retry_period.to_i
- @agent_id ||= invoke_remote :start, @local_host, {
- :pid => $$,
- :launch_time => @launch_time.to_f,
- :agent_version => NewRelic::VERSION::STRING,
- :environment => control.local_env.snapshot,
- :settings => control.settings }
-
- host = invoke_remote(:get_redirect_host) rescue nil
-
- @collector = control.server_from_host(host) if host
-
- @report_period = invoke_remote :get_data_report_period, @agent_id
-
- control.log! "Connected to NewRelic Service at #{@collector}"
- log.debug "Agent ID = #{@agent_id}."
-
- # Ask the server for permission to send transaction samples.
- # determined by subscription license.
- @should_send_samples = invoke_remote :should_collect_samples, @agent_id
-
- if @should_send_samples
- sampling_rate = invoke_remote :sampling_rate, @agent_id if @random_sample
- @transaction_sampler.sampling_rate = sampling_rate
-
- log.info "Transaction sample rate: #{@transaction_sampler.sampling_rate}"
- end
-
- # Ask for permission to collect error data
- @should_send_errors = invoke_remote :should_collect_errors, @agent_id
-
- log.info "Transaction traces will be sent to the RPM service" if @use_transaction_sampler && @should_send_samples
- log.info "Errors will be sent to the RPM service" if @error_collector.enabled && @should_send_errors
-
- @connected = true
-
- rescue LicenseException => e
- control.log! e.message, :error
- control.log! "Visit NewRelic.com to obtain a valid license key, or to upgrade your account."
- @invalid_license = true
- return false
-
- rescue Timeout::Error, StandardError => e
- log.info "Unable to establish connection with New Relic RPM Service at #{control.server}"
- unless e.instance_of? IgnoreSilentlyException
- log.error e.message
- log.debug e.backtrace.join("\n")
- end
- # retry logic
- connect_attempts += 1
- case connect_attempts
- when 1..2
- connect_retry_period, period_msg = 60, "1 minute"
- when 3..5 then
- connect_retry_period, period_msg = 60 * 2, "2 minutes"
- else
- connect_retry_period, period_msg = 10*60, "10 minutes"
- end
- log.info "Will re-attempt in #{period_msg}"
- retry
- end
- end
-
- def determine_host
- Socket.gethostname
- end
-
- def determine_home_directory
- control.root
- end
-
- def harvest_and_send_timeslice_data
-
- NewRelic::Agent::Instrumentation::DispatcherInstrumentation::BusyCalculator.harvest_busy
-
- now = Time.now
-
- # Fixme: remove the harvest thread tracking
- @harvest_thread ||= Thread.current
-
- if @harvest_thread != Thread.current
- log.error "Two harvest threads are running (current=#{Thread.current}, harvest=#{@harvest_thread}"
- @harvest_thread = Thread.current
- end
-
- @unsent_timeslice_data ||= {}
- @unsent_timeslice_data = @stats_engine.harvest_timeslice_data(@unsent_timeslice_data, @metric_ids)
-
- begin
- metric_ids = invoke_remote(:metric_data, @agent_id,
- @last_harvest_time.to_f,
- now.to_f,
- @unsent_timeslice_data.values)
-
- rescue Timeout::Error
- # assume that the data was received. chances are that it was
- metric_ids = nil
- end
-
- @metric_ids.merge! metric_ids if metric_ids
-
- log.debug "#{now}: sent #{@unsent_timeslice_data.length} timeslices (#{@agent_id}) in #{Time.now - now} seconds"
-
- # if we successfully invoked this web service, then clear the unsent message cache.
- @unsent_timeslice_data = {}
- @last_harvest_time = now
-
- # handle_messages
-
- # note - exceptions are logged in invoke_remote. If an exception is encountered here,
- # then the metric data is downsampled for another timeslices
- end
-
- def harvest_and_send_slowest_sample
- @traces = @transaction_sampler.harvest(@traces, @slowest_transaction_threshold)
-
- unless @traces.empty?
- now = Time.now
- log.debug "Sending (#{@traces.length}) transaction traces"
- begin
- # take the traces and prepare them for sending across the
- # wire. This includes gathering SQL explanations, stripping
- # out stack traces, and normalizing SQL. note that we
- # explain only the sql statements whose segments' execution
- # times exceed our threshold (to avoid unnecessary overhead
- # of running explains on fast queries.)
- traces = @traces.collect {|trace| trace.prepare_to_send(:explain_sql => @explain_threshold, :record_sql => @record_sql, :keep_backtraces => true, :explain_enabled => @explain_enabled)}
-
-
- invoke_remote :transaction_sample_data, @agent_id, traces
- rescue PostTooBigException
- # we tried to send too much data, drop the first trace and
- # try again
- @traces.shift
- retry
- end
-
- log.debug "#{now}: sent slowest sample (#{@agent_id}) in #{Time.now - now} seconds"
- end
-
- # if we succeed sending this sample, then we don't need to keep
- # the slowest sample around - it has been sent already and we
- # can collect the next one
- @traces = nil
-
- # note - exceptions are logged in invoke_remote. If an
- # exception is encountered here, then the slowest sample of is
- # determined of the entire period since the last reported
- # sample.
- end
-
- def harvest_and_send_errors
- @unsent_errors = @error_collector.harvest_errors(@unsent_errors)
- if @unsent_errors && @unsent_errors.length > 0
- log.debug "Sending #{@unsent_errors.length} errors"
- begin
- invoke_remote :error_data, @agent_id, @unsent_errors
- rescue PostTooBigException
- @unsent_errors.shift
- retry
- end
- # if the remote invocation fails, then we never clear
- # @unsent_errors, and therefore we can re-attempt to send on
- # the next heartbeat. Note the error collector maxes out at
- # 20 instances to prevent leakage
- @unsent_errors = []
- end
- end
-
- def compress_data(object)
- dump = Marshal.dump(object)
-
- # we currently optimize for CPU here since we get roughly a 10x
- # reduction in message size with this, and CPU overhead is at a
- # premium. For extra-large posts, we use the higher compression
- # since otherwise it actually errors out.
-
- dump_size = dump.size
-
- # small payloads don't need compression
- return [dump, 'identity'] if dump_size < 2000
-
- # medium payloads get fast compression, to save CPU
- # big payloads get all the compression possible, to stay under
- # the 2,000,000 byte post threshold
- compression = dump_size < 2000000 ? Zlib::BEST_SPEED : Zlib::BEST_COMPRESSION
-
- [Zlib::Deflate.deflate(dump, compression), 'deflate']
- end
-
- def check_post_size(post_string)
- # TODO: define this as a config option on the server side
- return if post_string.size < 2000000
- log.warn "Tried to send too much data, retrying with less: #{post_string.size} bytes"
- raise PostTooBigException
- end
-
- def send_request(opts)
- request = Net::HTTP::Post.new(opts[:uri], 'CONTENT-ENCODING' => opts[:encoding], 'ACCEPT-ENCODING' => 'gzip', 'HOST' => opts[:collector].name)
- request.content_type = "application/octet-stream"
- request.body = opts[:data]
-
- log.debug "connect to #{opts[:collector]}#{opts[:uri]}"
-
- response = nil
- http = control.http_connection(collector)
- begin
- timeout(@request_timeout) do
- response = http.request(request)
- end
- rescue Timeout::Error
- log.warn "Timed out trying to post data to RPM (timeout = #{@request_timeout} seconds)" unless @request_timeout < 30
- raise IgnoreSilentlyException
- end
-
- if !(response.is_a? Net::HTTPSuccess)
- log.debug "Unexpected response from server: #{response.code}: #{response.message}"
- raise IgnoreSilentlyException
- end
- response
- end
-
- def decompress_response(response)
- if response['content-encoding'] != 'gzip'
- log.debug "Uncompressed content returned"
- return response.body
- end
- log.debug "Decompressing return value"
- i = Zlib::GzipReader.new(StringIO.new(response.body))
- i.read
- end
-
- def check_for_exception(response)
- dump = decompress_response(response)
- value = Marshal.load(dump)
- raise value if value.is_a? Exception
- value
- end
-
- def remote_method_uri(method)
- uri = "/agent_listener/#{PROTOCOL_VERSION}/#{control.license_key}/#{method}"
- uri << "?run_id=#{@agent_id}" if @agent_id
- uri
- end
-
- # send a message via post
- def invoke_remote(method, *args)
- #determines whether to zip the data or send plain
- post_data, encoding = compress_data(args)
-
- # this checks to make sure mongrel won't choke on big uploads
- check_post_size(post_data)
-
- response = send_request({:uri => remote_method_uri(method), :encoding => encoding, :collector => collector, :data => post_data})
-
- # raises the right exception if the remote server tells it to die
- return check_for_exception(response)
- rescue ForceDisconnectException => e
- log.error "RPM forced this agent to disconnect (#{e.message})\n" \
- "Restart this process to resume monitoring via rpm.newrelic.com."
- # when a disconnect is requested, stop the current thread, which
- # is the worker thread that gathers data and talks to the
- # server.
- @connected = false
- Thread.exit
- rescue SystemCallError, SocketError => e
- # These include Errno connection errors
- log.debug "Recoverable error connecting to the server: #{e}"
- raise IgnoreSilentlyException
- end
-
- def graceful_disconnect
- if @connected && !(control.server.name == "localhost" && control.dispatcher_instance_id == '3000')
- begin
- log.debug "Sending graceful shutdown message to #{control.server}"
-
- @request_timeout = 10
-
- log.debug "Sending RPM service agent run shutdown message"
- invoke_remote :shutdown, @agent_id, Time.now.to_f
-
- log.debug "Graceful shutdown complete"
-
- rescue Timeout::Error, StandardError
- end
- else
- log.debug "Bypassing graceful shutdown - agent not connected"
- end
- end
- end
-
-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
61 vendor/plugins/newrelic_rpm/lib/new_relic/agent/collection_helper.rb
@@ -1,61 +0,0 @@
-module NewRelic::Agent::CollectionHelper
- # Transform parameter hash into a hash whose values are strictly
- # strings
- def normalize_params(params)
- case params
- when Symbol, FalseClass, TrueClass, nil
- params
- when Numeric
- truncate(params.to_s)
- when String
- truncate(params)
- when Hash
- new_params = {}
- params.each do | key, value |
- new_params[truncate(normalize_params(key),32)] = normalize_params(value)
- end
- new_params
- when Array
- params.first(20).map{|item| normalize_params(item)}
- else
- truncate(flatten(params))
- end
- end
-
- # Return an array of strings (backtrace), cleaned up for readability
- # Return nil if there is no backtrace
-
- def strip_nr_from_backtrace(backtrace)
- if backtrace
- # this is for 1.9.1, where strings no longer have Enumerable
- backtrace = backtrace.split("\n") if String === backtrace
- # strip newrelic from the trace
- backtrace = backtrace.reject {|line| line =~ /new_relic\/agent\// }
- # rename methods back to their original state
- backtrace = backtrace.collect {|line| line.gsub(/_without_(newrelic|trace)/, "")}
- end
- backtrace
- end
-
- private
-
- # Convert any kind of object to a short string.
- def flatten(object)
- s = case object
- when nil then ''
- when object.instance_of?(String) then object
- when String then String.new(object) # convert string subclasses to strings
- else "#<#{object.class.to_s}>"
- end
- end
- def truncate(string, len=256)
- case string
- when Symbol then string
- when nil then ""
- when String
- string.to_s.gsub(/^(.{#{len}})(.*)/) {$2.blank? ? $1 : $1 + "..."}
- else
- truncate(flatten(string), len)
- end
- end
-end
View
119 vendor/plugins/newrelic_rpm/lib/new_relic/agent/error_collector.rb
@@ -1,119 +0,0 @@
-
-module NewRelic::Agent
- class ErrorCollector
- include CollectionHelper
-
- MAX_ERROR_QUEUE_LENGTH = 20 unless defined? MAX_ERROR_QUEUE_LENGTH
-
- attr_accessor :enabled
-
- def initialize(agent = nil)
- @agent = agent
- @errors = []
- # lookup of exception class names to ignore. Hash for fast access
- @ignore = {}
- @ignore_filter = nil
-
- config = NewRelic::Control.instance.fetch('error_collector', {})
-
- @enabled = config.fetch('enabled', true)
- @capture_source = config.fetch('capture_source', true)
-
- ignore_errors = config.fetch('ignore_errors', "")
- ignore_errors = ignore_errors.split(",")
- ignore_errors.each { |error| error.strip! }
- ignore(ignore_errors)
- @lock = Mutex.new
- end
-
- def ignore_error_filter(&block)
- @ignore_filter = block
- end
-
-
- # errors is an array of Exception Class Names
- #
- def ignore(errors)
- errors.each { |error| @ignore[error] = true; log.debug("Ignoring error: '#{error}'") }
- end
-
-
- def notice_error(exception, request=nil, action_path=nil, filtered_params={})
-
- return unless @enabled
- return if @ignore[exception.class.name]
-
- if @ignore_filter
- exception = @ignore_filter.call(exception)
-
- return if exception.nil?
- end
-
- error_stat.increment_count
-
- data = {}
-
- action_path ||= ''
-
- data[:request_params] = normalize_params(filtered_params) if NewRelic::Control.instance.capture_params
-
- data[:custom_params] = normalize_params(@agent.custom_params) if @agent
-
- data[:request_uri] = request.path if request
- data[:request_uri] ||= ""
-
- data[:request_referer] = request.referer if request
- data[:request_referer] ||= ""
-
- data[:rails_root] = NewRelic::Control.instance.root
-
- data[:file_name] = exception.file_name if exception.respond_to?('file_name')
- data[:line_number] = exception.line_number if exception.respond_to?('line_number')
-
- if @capture_source && exception.respond_to?('source_extract')
- data[:source] = exception.source_extract
- end
-
- if exception.respond_to? 'original_exception'
- inside_exception = exception.original_exception
- else
- inside_exception = exception
- end
-
- data[:stack_trace] = inside_exception.backtrace
-
- noticed_error = NewRelic::NoticedError.new(action_path, data, exception)
-
- @lock.synchronize do
- if @errors.length >= MAX_ERROR_QUEUE_LENGTH
- log.info("The error reporting queue has reached #{MAX_ERROR_QUEUE_LENGTH}. This error will not be reported to RPM: #{exception.message}")
- else
- @errors << noticed_error
- end
- end
- end
-
- # Get the errors currently queued up. Unsent errors are left
- # over from a previous unsuccessful attempt to send them to the server.
- # We first clear out all unsent errors before sending the newly queued errors.
- def harvest_errors(unsent_errors)
- if unsent_errors && !unsent_errors.empty?
- return unsent_errors
- else
- @lock.synchronize do
- errors = @errors
- @errors = []
- return errors
- end
- end
- end
-
- private
- def error_stat
- @error_stat ||= NewRelic::Agent.get_stats("Errors/all")
- end
- def log
- NewRelic::Control.instance.log
- end
- 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
81 ...plugins/newrelic_rpm/lib/new_relic/agent/instrumentation/active_record_instrumentation.rb
@@ -1,81 +0,0 @@
-
-# NewRelic instrumentation for ActiveRecord
-if defined?(ActiveRecord::Base) && !NewRelic::Control.instance['skip_ar_instrumentation']
-
- module NewRelic::Agent::Instrumentation::ActiveRecordInstrumentation
-
- def self.included(instrumented_class)
- instrumented_class.class_eval do
- alias_method :log_without_newrelic_instrumentation, :log
- alias_method :log, :log_with_newrelic_instrumentation
- protected :log
- end
- end
-
- def active_record_all_stats
- NewRelic::Agent.instance.stats_engine.get_stats_no_scope("ActiveRecord/all")
- end
-
- def log_with_newrelic_instrumentation(sql, name, &block)
- # Capture db config if we are going to try to get the explain plans
- if (defined?(ActiveRecord::ConnectionAdapters::MysqlAdapter) && self.is_a?(ActiveRecord::ConnectionAdapters::MysqlAdapter)) ||
- (defined?(ActiveRecord::ConnectionAdapters::PostgreSQLAdapter) && self.is_a?(ActiveRecord::ConnectionAdapters::PostgreSQLAdapter))
- supported_config = @config
- end
- if name && (parts = name.split " ") && parts.size == 2
- model = parts.first
- operation = parts.last.downcase
- metric_name = case operation
- when 'load' then 'find'
- when 'indexes', 'columns' then nil # fall back to DirectSQL
- when 'destroy', 'find', 'save', 'create' then operation
- when 'update' then 'save'
- else
- if model == 'Join'
- operation
- end
- end
- metric = "ActiveRecord/#{model}/#{metric_name}" if metric_name
- end
- if metric.nil? && sql =~ /^(select|update|insert|delete)/i
- # Could not determine the model/operation so let's find a better
- # metric. If it doesn't match the regex, it's probably a show
- # command or some DDL which we'll ignore.
- metric = "Database/SQL/#{$1.downcase}"
- end
-
- if !metric
- log_without_newrelic_instrumentation(sql, name, &block)
- else
- self.class.trace_method_execution_with_scope metric, true, true do
- t0 = Time.now.to_f
- result = log_without_newrelic_instrumentation(sql, name, &block)
- duration = Time.now.to_f - t0
-
- NewRelic::Agent.instance.transaction_sampler.notice_sql(sql, supported_config, duration)
- # Record in the overall summary metric
- active_record_all_stats.record_data_point(duration)
- # Record in the summary metric for this operation
- NewRelic::Agent.instance.stats_engine.get_stats_no_scope("ActiveRecord/#{metric_name}").record_data_point(duration) if metric_name
- result
- end
- end
- end
-
- end
-
- # instrumentation to catch logged SQL statements in sampled transactions
- ActiveRecord::ConnectionAdapters::AbstractAdapter.module_eval do
- include ::NewRelic::Agent::Instrumentation::ActiveRecordInstrumentation
- end
-
- # This instrumentation will add an extra scope to the transaction traces
- # which will show the code surrounding the query, inside the model find_by_sql
- # method.
- ActiveRecord::Base.class_eval do
- class << self
- add_method_tracer :find_by_sql, 'ActiveRecord/#{self.name}/find_by_sql', :metric => false
- end
- end
-
-end
View
193 ...or/plugins/newrelic_rpm/lib/new_relic/agent/instrumentation/controller_instrumentation.rb
@@ -1,193 +0,0 @@
-# NewRelic instrumentation for controllers
-#
-# This instrumentation is applied to the action controller by default if the agent
-# is actively collecting statistics. It will collect statistics for the
-# given action.
-#
-# In cases where you don't want to instrument the top level action, but instead
-# have other methods which are dispatched to by your action, and you want to treat
-# these as distinct actions, then what you need to do is call newrelic_ignore
-# on the top level action, and manually instrument the called 'actions'.
-#
-# Here's an example of a controller with a send_message action which dispatches
-# to more specific send_servicename methods. This results in the controller
-# action stats showing up for send_servicename.
-#
-# MyController < ActionController::Base
-# newrelic_ignore :only => 'send_message'
-# # dispatch this action to the method given by the service parameter.
-# def send_message
-# service = params['service']
-# dispatch_to_method = "send_messge_to_#{service}"
-# perform_action_with_newrelic_trace(dispatch_to_method) do
-# send dispatch_to_method, params['message']
-# end
-# end
-# end
-
-module NewRelic::Agent::Instrumentation
- module ControllerInstrumentation
-
- def self.included(clazz)
- clazz.extend(ClassMethods)
- end
-
- # This module is for importing stubs when the agent is disabled
- module ClassMethodsShim
- def newrelic_ignore(*args); end
- def newrelic_ignore_apdex(*args); end
- end
-
- module Shim
- def self.included(clazz)
- clazz.extend(ClassMethodsShim)
- end
- def newrelic_notice_error(*args); end
- def new_relic_trace_controller_action(*args); yield; end
- def newrelic_metric_path; end
- def perform_action_with_newrelic_trace(*args); yield; end
- end
-
- module ClassMethods
- # Have NewRelic ignore actions in this controller. Specify the actions as hash options
- # using :except and :only. If no actions are specified, all actions are ignored.
- def newrelic_ignore(specifiers={})
- newrelic_ignore_aspect('do_not_trace', specifiers)
- end
- # Have NewRelic omit apdex measurements on the given actions. Typically used for
- # actions that are not user facing or that skew your overall apdex measurement.
- # Accepts :except and :only options, as with #newrelic_ignore.
- def newrelic_ignore_apdex(specifiers={})
- newrelic_ignore_aspect('ignore_apdex', specifiers)
- end
-
- def newrelic_ignore_aspect(property, specifiers={}) # :nodoc:
- if specifiers.empty?
- self.newrelic_write_attr property, true
- elsif ! (Hash === specifiers)
- logger.error "newrelic_#{property} takes an optional hash with :only and :except lists of actions (illegal argument type '#{specifiers.class}')"
- else
- self.newrelic_write_attr property, specifiers
- end
- end
-
- # Should be monkey patched into the controller class implemented with the inheritable attribute mechanism.
- def newrelic_write_attr(attr_name, value) # :nodoc:
- instance_variable_set "@#{attr_name}", value
- end
- def newrelic_read_attr(attr_name) # :nodoc:
- instance_variable_get "@#{attr_name}", value
- end
- end
-
- # Must be implemented in the controller class:
- # Determine the path that is used in the metric name for
- # the called controller action. Of the form controller_path/action_name
- #
- def newrelic_metric_path(action_name_override = nil) # :nodoc:
- raise "Not implemented!"
- end
-
- # Perform the current action with NewRelic tracing. Used in a method
- # chain via aliasing. Call directly if you want to instrument a specifc
- # block as if it were an action. Pass the block along with the path.
- # The metric is named according to the action name, or the given path if called
- # directly.
- def perform_action_with_newrelic_trace(*args)
- agent = NewRelic::Agent.instance
- stats_engine = agent.stats_engine
-
- # Skip instrumentation based on the value of 'do_not_trace' and if
- # we aren't calling directly with a block.
- if !block_given? && is_filtered?(self.class.newrelic_read_attr('do_not_trace'))
- # Tell the dispatcher instrumentation that we ignored this action and it shouldn't
- # be counted for the overall HTTP operations measurement.
- Thread.current[:controller_ignored] = true
-
- return perform_action_without_newrelic_trace(*args)
- end
-
- # reset this in case we came through a code path where the top level controller is ignored
- Thread.current[:controller_ignored] = nil
-
- start = Time.now.to_f
- agent.ensure_worker_thread_started
-
- # generate metrics for all all controllers (no scope)
- self.class.trace_method_execution_no_scope "Controller" do
- # assuming the first argument, if present, is the action name
- path = newrelic_metric_path(args.size > 0 ? args[0] : nil)
- controller_metric = "Controller/#{path}"
-
- self.class.trace_method_execution_with_scope controller_metric, true, true do
- stats_engine.transaction_name = controller_metric
-
- local_params = (respond_to? :filter_parameters) ? filter_parameters(params) : params
-
- agent.transaction_sampler.notice_transaction(path, request, local_params)
-
- t = Process.times.utime + Process.times.stime
-
- failed = false
-
- begin
- # run the action
- if block_given?
- yield
- else
- perform_action_without_newrelic_trace(*args)
- end
- rescue Exception => e
- failed = true
- raise e
- ensure
- cpu_burn = (Process.times.utime + Process.times.stime) - t
- stats_engine.get_stats_no_scope("ControllerCPU/#{path}").record_data_point(cpu_burn)
- agent.transaction_sampler.notice_transaction_cpu_time(cpu_burn)
-
- # do the apdex bucketing
- #
- unless is_filtered?(self.class.newrelic_read_attr('ignore_apdex'))
- duration = Time.now.to_f - start
- controller_stat = stats_engine.get_custom_stats("Apdex/#{path}", NewRelic::ApdexStats)
- case
- when failed
- apdex_overall_stat.record_apdex_f # frustrated
- controller_stat.record_apdex_f
- when duration <= NewRelic::Control.instance['apdex_t']
- apdex_overall_stat.record_apdex_s # satisfied
- controller_stat.record_apdex_s
- when duration <= 4 * NewRelic::Control.instance['apdex_t']
- apdex_overall_stat.record_apdex_t # tolerating
- controller_stat.record_apdex_t
- else
- apdex_overall_stat.record_apdex_f # frustrated
- controller_stat.record_apdex_f
- end
- end
- end
- end
- end
- ensure
- # clear out the name of the traced transaction under all circumstances
- stats_engine.transaction_name = nil
- end
-
- private
- def apdex_overall_stat
- NewRelic::Agent.instance.stats_engine.get_custom_stats("Apdex", NewRelic::ApdexStats)
- end
-
- def is_filtered?(ignore_actions)
- case ignore_actions
- when nil; false
- when Hash
- only_actions = Array(ignore_actions[:only])
- except_actions = Array(ignore_actions[:except])
- only_actions.include?(action_name.to_sym) || (except_actions.any? && !except_actions.include?(action_name.to_sym))
- else
- true
- end
- 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
127 ...or/plugins/newrelic_rpm/lib/new_relic/agent/instrumentation/dispatcher_instrumentation.rb
@@ -1,127 +0,0 @@
-# We have to patch the mongrel dispatcher live since the classes
-# aren't defined when our instrumentation loads
-# To use this module, you need to monkey patch a method newrelic_response_code
-# which will return the response status code when the dispatcher finishes.
-module NewRelic::Agent::Instrumentation
- module DispatcherInstrumentation
-
- 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
- newrelic_dispatcher_start_time = Time.now.to_f
- Thread.current[:newrelic_dispatcher_start] = newrelic_dispatcher_start_time
- NewRelic::Agent::Instrumentation::DispatcherInstrumentation::BusyCalculator.dispatcher_start newrelic_dispatcher_start_time
- # 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]
- mongrel_queue_stat.trace_call(newrelic_dispatcher_start_time - mongrel_start.to_f) if mongrel_start
- NewRelic::Agent.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
- #puts @env.to_a.map{|k,v| "#{'%32s' % k}: #{v.inspect[0..64]}"}.join("\n")