wd_newrelic_rpm 3.3.4.1
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +591 -0
- data/LICENSE +64 -0
- data/README.rdoc +179 -0
- data/bin/mongrel_rpm +33 -0
- data/bin/newrelic +13 -0
- data/bin/newrelic_cmd +5 -0
- data/cert/cacert.pem +118 -0
- data/cert/oldsite.pem +28 -0
- data/cert/site.pem +27 -0
- data/install.rb +9 -0
- data/lib/conditional_vendored_dependency_detection.rb +3 -0
- data/lib/conditional_vendored_metric_parser.rb +5 -0
- data/lib/new_relic/agent.rb +467 -0
- data/lib/new_relic/agent/agent.rb +1325 -0
- data/lib/new_relic/agent/beacon_configuration.rb +121 -0
- data/lib/new_relic/agent/browser_monitoring.rb +142 -0
- data/lib/new_relic/agent/busy_calculator.rb +99 -0
- data/lib/new_relic/agent/chained_call.rb +13 -0
- data/lib/new_relic/agent/database.rb +223 -0
- data/lib/new_relic/agent/error_collector.rb +251 -0
- data/lib/new_relic/agent/instrumentation.rb +9 -0
- data/lib/new_relic/agent/instrumentation/active_merchant.rb +29 -0
- data/lib/new_relic/agent/instrumentation/active_record.rb +137 -0
- data/lib/new_relic/agent/instrumentation/acts_as_solr.rb +68 -0
- data/lib/new_relic/agent/instrumentation/authlogic.rb +19 -0
- data/lib/new_relic/agent/instrumentation/controller_instrumentation.rb +443 -0
- data/lib/new_relic/agent/instrumentation/data_mapper.rb +238 -0
- data/lib/new_relic/agent/instrumentation/delayed_job_instrumentation.rb +52 -0
- data/lib/new_relic/agent/instrumentation/memcache.rb +80 -0
- data/lib/new_relic/agent/instrumentation/merb/controller.rb +41 -0
- data/lib/new_relic/agent/instrumentation/merb/errors.rb +29 -0
- data/lib/new_relic/agent/instrumentation/metric_frame.rb +353 -0
- data/lib/new_relic/agent/instrumentation/metric_frame/pop.rb +80 -0
- data/lib/new_relic/agent/instrumentation/net.rb +29 -0
- data/lib/new_relic/agent/instrumentation/passenger_instrumentation.rb +37 -0
- data/lib/new_relic/agent/instrumentation/queue_time.rb +210 -0
- data/lib/new_relic/agent/instrumentation/rack.rb +98 -0
- data/lib/new_relic/agent/instrumentation/rails/action_controller.rb +114 -0
- data/lib/new_relic/agent/instrumentation/rails/action_web_service.rb +42 -0
- data/lib/new_relic/agent/instrumentation/rails/errors.rb +42 -0
- data/lib/new_relic/agent/instrumentation/rails3/action_controller.rb +180 -0
- data/lib/new_relic/agent/instrumentation/rails3/errors.rb +37 -0
- data/lib/new_relic/agent/instrumentation/sinatra.rb +78 -0
- data/lib/new_relic/agent/instrumentation/sunspot.rb +29 -0
- data/lib/new_relic/agent/instrumentation/unicorn_instrumentation.rb +21 -0
- data/lib/new_relic/agent/method_tracer.rb +528 -0
- data/lib/new_relic/agent/sampler.rb +50 -0
- data/lib/new_relic/agent/samplers/cpu_sampler.rb +58 -0
- data/lib/new_relic/agent/samplers/delayed_job_lock_sampler.rb +40 -0
- data/lib/new_relic/agent/samplers/memory_sampler.rb +143 -0
- data/lib/new_relic/agent/samplers/object_sampler.rb +26 -0
- data/lib/new_relic/agent/shim_agent.rb +29 -0
- data/lib/new_relic/agent/sql_sampler.rb +286 -0
- data/lib/new_relic/agent/stats_engine.rb +26 -0
- data/lib/new_relic/agent/stats_engine/gc_profiler.rb +123 -0
- data/lib/new_relic/agent/stats_engine/metric_stats.rb +187 -0
- data/lib/new_relic/agent/stats_engine/samplers.rb +95 -0
- data/lib/new_relic/agent/stats_engine/transactions.rb +125 -0
- data/lib/new_relic/agent/transaction_info.rb +74 -0
- data/lib/new_relic/agent/transaction_sample_builder.rb +116 -0
- data/lib/new_relic/agent/transaction_sampler.rb +468 -0
- data/lib/new_relic/agent/worker_loop.rb +89 -0
- data/lib/new_relic/collection_helper.rb +77 -0
- data/lib/new_relic/command.rb +85 -0
- data/lib/new_relic/commands/deployments.rb +105 -0
- data/lib/new_relic/commands/install.rb +80 -0
- data/lib/new_relic/control.rb +46 -0
- data/lib/new_relic/control/class_methods.rb +53 -0
- data/lib/new_relic/control/configuration.rb +206 -0
- data/lib/new_relic/control/frameworks.rb +10 -0
- data/lib/new_relic/control/frameworks/external.rb +16 -0
- data/lib/new_relic/control/frameworks/merb.rb +31 -0
- data/lib/new_relic/control/frameworks/rails.rb +164 -0
- data/lib/new_relic/control/frameworks/rails3.rb +75 -0
- data/lib/new_relic/control/frameworks/ruby.rb +42 -0
- data/lib/new_relic/control/frameworks/sinatra.rb +20 -0
- data/lib/new_relic/control/instance_methods.rb +179 -0
- data/lib/new_relic/control/instrumentation.rb +100 -0
- data/lib/new_relic/control/logging_methods.rb +143 -0
- data/lib/new_relic/control/profiling.rb +25 -0
- data/lib/new_relic/control/server_methods.rb +114 -0
- data/lib/new_relic/data_serialization.rb +151 -0
- data/lib/new_relic/delayed_job_injection.rb +51 -0
- data/lib/new_relic/language_support.rb +73 -0
- data/lib/new_relic/local_environment.rb +428 -0
- data/lib/new_relic/merbtasks.rb +6 -0
- data/lib/new_relic/metric_data.rb +51 -0
- data/lib/new_relic/metric_spec.rb +76 -0
- data/lib/new_relic/metrics.rb +9 -0
- data/lib/new_relic/noticed_error.rb +29 -0
- data/lib/new_relic/rack/browser_monitoring.rb +76 -0
- data/lib/new_relic/rack/developer_mode.rb +268 -0
- data/lib/new_relic/recipes.rb +77 -0
- data/lib/new_relic/stats.rb +335 -0
- data/lib/new_relic/timer_lib.rb +27 -0
- data/lib/new_relic/transaction_analysis.rb +77 -0
- data/lib/new_relic/transaction_analysis/segment_summary.rb +49 -0
- data/lib/new_relic/transaction_sample.rb +261 -0
- data/lib/new_relic/transaction_sample/composite_segment.rb +27 -0
- data/lib/new_relic/transaction_sample/fake_segment.rb +9 -0
- data/lib/new_relic/transaction_sample/segment.rb +203 -0
- data/lib/new_relic/transaction_sample/summary_segment.rb +21 -0
- data/lib/new_relic/url_rule.rb +14 -0
- data/lib/new_relic/version.rb +55 -0
- data/lib/newrelic_rpm.rb +49 -0
- data/lib/tasks/all.rb +4 -0
- data/lib/tasks/install.rake +7 -0
- data/lib/tasks/tests.rake +19 -0
- data/newrelic.yml +265 -0
- data/newrelic_rpm.gemspec +312 -0
- data/recipes/newrelic.rb +6 -0
- data/test/active_record_fixtures.rb +77 -0
- data/test/config/newrelic.yml +48 -0
- data/test/config/test_control.rb +48 -0
- data/test/fixtures/proc_cpuinfo.txt +575 -0
- data/test/new_relic/agent/agent/connect_test.rb +403 -0
- data/test/new_relic/agent/agent/start_test.rb +255 -0
- data/test/new_relic/agent/agent/start_worker_thread_test.rb +153 -0
- data/test/new_relic/agent/agent_test.rb +140 -0
- data/test/new_relic/agent/agent_test_controller.rb +77 -0
- data/test/new_relic/agent/agent_test_controller_test.rb +382 -0
- data/test/new_relic/agent/apdex_from_server_test.rb +9 -0
- data/test/new_relic/agent/beacon_configuration_test.rb +111 -0
- data/test/new_relic/agent/browser_monitoring_test.rb +323 -0
- data/test/new_relic/agent/busy_calculator_test.rb +81 -0
- data/test/new_relic/agent/database_test.rb +149 -0
- data/test/new_relic/agent/error_collector/notice_error_test.rb +257 -0
- data/test/new_relic/agent/error_collector_test.rb +192 -0
- data/test/new_relic/agent/instrumentation/active_record_instrumentation_test.rb +576 -0
- data/test/new_relic/agent/instrumentation/controller_instrumentation_test.rb +34 -0
- data/test/new_relic/agent/instrumentation/instrumentation_test.rb +11 -0
- data/test/new_relic/agent/instrumentation/metric_frame/pop_test.rb +171 -0
- data/test/new_relic/agent/instrumentation/metric_frame_test.rb +50 -0
- data/test/new_relic/agent/instrumentation/net_instrumentation_test.rb +84 -0
- data/test/new_relic/agent/instrumentation/queue_time_test.rb +382 -0
- data/test/new_relic/agent/instrumentation/rack_test.rb +35 -0
- data/test/new_relic/agent/instrumentation/task_instrumentation_test.rb +184 -0
- data/test/new_relic/agent/memcache_instrumentation_test.rb +143 -0
- data/test/new_relic/agent/method_tracer/class_methods/add_method_tracer_test.rb +164 -0
- data/test/new_relic/agent/method_tracer/instance_methods/trace_execution_scoped_test.rb +234 -0
- data/test/new_relic/agent/method_tracer_test.rb +386 -0
- data/test/new_relic/agent/mock_scope_listener.rb +23 -0
- data/test/new_relic/agent/rpm_agent_test.rb +149 -0
- data/test/new_relic/agent/sampler_test.rb +19 -0
- data/test/new_relic/agent/shim_agent_test.rb +20 -0
- data/test/new_relic/agent/sql_sampler_test.rb +192 -0
- data/test/new_relic/agent/stats_engine/metric_stats/harvest_test.rb +150 -0
- data/test/new_relic/agent/stats_engine/metric_stats_test.rb +82 -0
- data/test/new_relic/agent/stats_engine/samplers_test.rb +99 -0
- data/test/new_relic/agent/stats_engine_test.rb +220 -0
- data/test/new_relic/agent/transaction_info_test.rb +13 -0
- data/test/new_relic/agent/transaction_sample_builder_test.rb +219 -0
- data/test/new_relic/agent/transaction_sampler_test.rb +967 -0
- data/test/new_relic/agent/worker_loop_test.rb +66 -0
- data/test/new_relic/agent_test.rb +187 -0
- data/test/new_relic/collection_helper_test.rb +149 -0
- data/test/new_relic/command/deployments_test.rb +68 -0
- data/test/new_relic/control/class_methods_test.rb +62 -0
- data/test/new_relic/control/configuration_test.rb +84 -0
- data/test/new_relic/control/logging_methods_test.rb +185 -0
- data/test/new_relic/control_test.rb +256 -0
- data/test/new_relic/data_serialization_test.rb +208 -0
- data/test/new_relic/delayed_job_injection_test.rb +16 -0
- data/test/new_relic/local_environment_test.rb +85 -0
- data/test/new_relic/metric_data_test.rb +125 -0
- data/test/new_relic/metric_parser/metric_parser_test.rb +11 -0
- data/test/new_relic/metric_spec_test.rb +95 -0
- data/test/new_relic/rack/all_test.rb +11 -0
- data/test/new_relic/rack/browser_monitoring_test.rb +142 -0
- data/test/new_relic/rack/developer_mode_helper_test.rb +141 -0
- data/test/new_relic/rack/developer_mode_test.rb +74 -0
- data/test/new_relic/stats_test.rb +411 -0
- data/test/new_relic/transaction_analysis/segment_summary_test.rb +91 -0
- data/test/new_relic/transaction_analysis_test.rb +121 -0
- data/test/new_relic/transaction_sample/composite_segment_test.rb +35 -0
- data/test/new_relic/transaction_sample/fake_segment_test.rb +17 -0
- data/test/new_relic/transaction_sample/segment_test.rb +389 -0
- data/test/new_relic/transaction_sample/summary_segment_test.rb +31 -0
- data/test/new_relic/transaction_sample_subtest_test.rb +56 -0
- data/test/new_relic/transaction_sample_test.rb +177 -0
- data/test/new_relic/version_number_test.rb +89 -0
- data/test/script/build_test_gem.sh +51 -0
- data/test/script/ci.sh +94 -0
- data/test/script/ci_bench.sh +52 -0
- data/test/test_contexts.rb +29 -0
- data/test/test_helper.rb +155 -0
- data/ui/helpers/developer_mode_helper.rb +357 -0
- data/ui/helpers/google_pie_chart.rb +48 -0
- data/ui/views/layouts/newrelic_default.rhtml +47 -0
- data/ui/views/newrelic/_explain_plans.rhtml +27 -0
- data/ui/views/newrelic/_sample.rhtml +20 -0
- data/ui/views/newrelic/_segment.rhtml +28 -0
- data/ui/views/newrelic/_segment_limit_message.rhtml +1 -0
- data/ui/views/newrelic/_segment_row.rhtml +12 -0
- data/ui/views/newrelic/_show_sample_detail.rhtml +24 -0
- data/ui/views/newrelic/_show_sample_sql.rhtml +24 -0
- data/ui/views/newrelic/_show_sample_summary.rhtml +3 -0
- data/ui/views/newrelic/_sql_row.rhtml +16 -0
- data/ui/views/newrelic/_stack_trace.rhtml +15 -0
- data/ui/views/newrelic/_table.rhtml +12 -0
- data/ui/views/newrelic/explain_sql.rhtml +43 -0
- data/ui/views/newrelic/file/images/arrow-close.png +0 -0
- data/ui/views/newrelic/file/images/arrow-open.png +0 -0
- data/ui/views/newrelic/file/images/blue_bar.gif +0 -0
- data/ui/views/newrelic/file/images/file_icon.png +0 -0
- data/ui/views/newrelic/file/images/gray_bar.gif +0 -0
- data/ui/views/newrelic/file/images/new-relic-rpm-desktop.gif +0 -0
- data/ui/views/newrelic/file/images/new_relic_rpm_desktop.gif +0 -0
- data/ui/views/newrelic/file/images/textmate.png +0 -0
- data/ui/views/newrelic/file/javascript/jquery-1.4.2.js +6240 -0
- data/ui/views/newrelic/file/javascript/transaction_sample.js +120 -0
- data/ui/views/newrelic/file/stylesheets/style.css +490 -0
- data/ui/views/newrelic/index.rhtml +71 -0
- data/ui/views/newrelic/sample_not_found.rhtml +2 -0
- data/ui/views/newrelic/show_sample.rhtml +80 -0
- data/ui/views/newrelic/show_source.rhtml +3 -0
- data/ui/views/newrelic/threads.rhtml +53 -0
- data/vendor/gems/dependency_detection-0.0.1.build/LICENSE +5 -0
- data/vendor/gems/dependency_detection-0.0.1.build/lib/dependency_detection.rb +67 -0
- data/vendor/gems/dependency_detection-0.0.1.build/lib/dependency_detection/version.rb +3 -0
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/metric_parser.rb +1 -0
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser.rb +64 -0
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/action_mailer.rb +14 -0
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/active_merchant.rb +31 -0
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/active_record.rb +33 -0
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/apdex.rb +89 -0
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/background_transaction.rb +7 -0
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/client.rb +46 -0
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/controller.rb +67 -0
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/controller_cpu.rb +43 -0
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/controller_ext.rb +17 -0
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/database.rb +48 -0
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/database_pool.rb +24 -0
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/dot_net.rb +28 -0
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/dot_net_parser.rb +17 -0
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/errors.rb +11 -0
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/external.rb +55 -0
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/frontend.rb +40 -0
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/gc.rb +20 -0
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/hibernate_session.rb +7 -0
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/java.rb +31 -0
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/java_parser.rb +17 -0
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/jsp.rb +34 -0
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/jsp_tag.rb +7 -0
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/mem_cache.rb +55 -0
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/metric_parser.rb +135 -0
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/orm.rb +27 -0
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/other_transaction.rb +40 -0
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/servlet.rb +7 -0
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/servlet_context_listener.rb +7 -0
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/servlet_filter.rb +7 -0
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/solr.rb +27 -0
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/solr_request_handler.rb +15 -0
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/spring.rb +54 -0
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/spring_controller.rb +6 -0
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/spring_view.rb +6 -0
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/struts_action.rb +20 -0
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/struts_result.rb +20 -0
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/version.rb +5 -0
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/view.rb +70 -0
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/web_frontend.rb +18 -0
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/web_service.rb +14 -0
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/web_transaction.rb +133 -0
- metadata +376 -0
@@ -0,0 +1,77 @@
|
|
1
|
+
# When installed as a plugin this is loaded automatically.
|
2
|
+
#
|
3
|
+
# When installed as a gem, you need to add
|
4
|
+
# require 'new_relic/recipes'
|
5
|
+
# to your deploy.rb
|
6
|
+
#
|
7
|
+
# Defined deploy:notify_rpm which will send information about the deploy to New Relic.
|
8
|
+
# The task will run on app servers except where no_release is true.
|
9
|
+
# If it fails, it will not affect the task execution or do a rollback.
|
10
|
+
#
|
11
|
+
make_notify_task = Proc.new do
|
12
|
+
|
13
|
+
namespace :newrelic do
|
14
|
+
|
15
|
+
# on all deployments, notify New Relic
|
16
|
+
desc "Record a deployment in New Relic (newrelic.com)"
|
17
|
+
task :notice_deployment, :roles => :app, :except => {:no_release => true } do
|
18
|
+
rails_env = fetch(:newrelic_rails_env, fetch(:rails_env, "production"))
|
19
|
+
require File.join(File.dirname(__FILE__), 'command.rb')
|
20
|
+
begin
|
21
|
+
# allow overrides to be defined for revision, description, changelog and appname
|
22
|
+
rev = fetch(:newrelic_revision) if exists?(:newrelic_revision)
|
23
|
+
description = fetch(:newrelic_desc) if exists?(:newrelic_desc)
|
24
|
+
changelog = fetch(:newrelic_changelog) if exists?(:newrelic_changelog)
|
25
|
+
appname = fetch(:newrelic_appname) if exists?(:newrelic_appname)
|
26
|
+
if !changelog
|
27
|
+
logger.debug "Getting log of changes for New Relic Deployment details"
|
28
|
+
from_revision = source.next_revision(current_revision)
|
29
|
+
if scm == :git
|
30
|
+
log_command = "git log --no-color --pretty=format:' * %an: %s' --abbrev-commit --no-merges #{previous_revision}..#{real_revision}"
|
31
|
+
else
|
32
|
+
log_command = "#{source.log(from_revision)}"
|
33
|
+
end
|
34
|
+
changelog = `#{log_command}`
|
35
|
+
end
|
36
|
+
if rev.nil?
|
37
|
+
rev = source.query_revision(source.head()) do |cmd|
|
38
|
+
logger.debug "executing locally: '#{cmd}'"
|
39
|
+
`#{cmd}`
|
40
|
+
end
|
41
|
+
rev = rev[0..6] if scm == :git
|
42
|
+
end
|
43
|
+
new_revision = rev
|
44
|
+
deploy_options = { :environment => rails_env,
|
45
|
+
:revision => new_revision,
|
46
|
+
:changelog => changelog,
|
47
|
+
:description => description,
|
48
|
+
:appname => appname }
|
49
|
+
logger.debug "Uploading deployment to New Relic"
|
50
|
+
deployment = NewRelic::Command::Deployments.new deploy_options
|
51
|
+
deployment.run
|
52
|
+
logger.info "Uploaded deployment information to New Relic"
|
53
|
+
rescue NewRelic::Command::CommandFailure => e
|
54
|
+
logger.info e.message
|
55
|
+
rescue Capistrano::CommandError
|
56
|
+
logger.info "Unable to notify New Relic of the deployment... skipping"
|
57
|
+
rescue => e
|
58
|
+
logger.info "Error creating New Relic deployment (#{e})\n#{e.backtrace.join("\n")}"
|
59
|
+
end
|
60
|
+
# WIP: For rollbacks, let's update the deployment we created with an indication of the failure:
|
61
|
+
# on_rollback do
|
62
|
+
# run(...)
|
63
|
+
# end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
require 'capistrano/version'
|
68
|
+
if defined?(Capistrano::Version::MAJOR) && Capistrano::Version::MAJOR < 2
|
69
|
+
STDERR.puts "Unable to load #{__FILE__}\nNew Relic Capistrano hooks require at least version 2.0.0"
|
70
|
+
else
|
71
|
+
instance = Capistrano::Configuration.instance
|
72
|
+
if instance
|
73
|
+
instance.load &make_notify_task
|
74
|
+
else
|
75
|
+
make_notify_task.call
|
76
|
+
end
|
77
|
+
end
|
@@ -0,0 +1,335 @@
|
|
1
|
+
|
2
|
+
module NewRelic
|
3
|
+
module Stats
|
4
|
+
|
5
|
+
# a stat is absent if its call count equals zero
|
6
|
+
def absent?
|
7
|
+
call_count == 0
|
8
|
+
end
|
9
|
+
|
10
|
+
# outputs a useful human-readable time given a value in milliseconds
|
11
|
+
def time_str(value_ms)
|
12
|
+
case
|
13
|
+
when value_ms >= 10000
|
14
|
+
"%.1f s" % (value_ms / 1000.0)
|
15
|
+
when value_ms >= 5000
|
16
|
+
"%.2f s" % (value_ms / 1000.0)
|
17
|
+
else
|
18
|
+
"%.0f ms" % value_ms
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
# makes sure we aren't dividing by zero
|
23
|
+
def checked_calculation(numerator, denominator)
|
24
|
+
if denominator.nil? || denominator == 0
|
25
|
+
0.0
|
26
|
+
else
|
27
|
+
numerator.to_f / denominator
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def average_call_time
|
32
|
+
checked_calculation(total_call_time, call_count)
|
33
|
+
end
|
34
|
+
def average_exclusive_time
|
35
|
+
checked_calculation(total_exclusive_time, call_count)
|
36
|
+
end
|
37
|
+
|
38
|
+
# merge by adding to average response time
|
39
|
+
# - used to compose multiple metrics e.g. dispatcher time + mongrel queue time
|
40
|
+
def sum_merge! (other_stats)
|
41
|
+
Array(other_stats).each do |other|
|
42
|
+
self.sum_attributes(other)
|
43
|
+
end
|
44
|
+
self
|
45
|
+
end
|
46
|
+
|
47
|
+
def sum_attributes(other)
|
48
|
+
update_totals(other)
|
49
|
+
stack_min_max_from(other)
|
50
|
+
self.call_count = [self.call_count, other.call_count].max
|
51
|
+
update_boundaries(other)
|
52
|
+
end
|
53
|
+
|
54
|
+
def stack_min_max_from(other)
|
55
|
+
self.min_call_time += other.min_call_time
|
56
|
+
self.max_call_time += other.max_call_time
|
57
|
+
end
|
58
|
+
|
59
|
+
def update_boundaries(other)
|
60
|
+
self.begin_time = other.begin_time if should_replace_begin_time?(other)
|
61
|
+
self.end_time = other.end_time if should_replace_end_time?(other)
|
62
|
+
end
|
63
|
+
|
64
|
+
def should_replace_end_time?(other)
|
65
|
+
end_time.to_f < other.end_time.to_f
|
66
|
+
end
|
67
|
+
|
68
|
+
def should_replace_begin_time?(other)
|
69
|
+
other.begin_time.to_f < begin_time.to_f || begin_time.to_f == 0.0
|
70
|
+
end
|
71
|
+
|
72
|
+
def update_totals(other)
|
73
|
+
self.total_call_time += other.total_call_time
|
74
|
+
self.total_exclusive_time += other.total_exclusive_time
|
75
|
+
self.sum_of_squares += other.sum_of_squares
|
76
|
+
end
|
77
|
+
|
78
|
+
def min_time_less?(other)
|
79
|
+
(other.min_call_time < min_call_time && other.call_count > 0) || call_count == 0
|
80
|
+
end
|
81
|
+
|
82
|
+
def expand_min_max_to(other)
|
83
|
+
self.min_call_time = other.min_call_time if min_time_less?(other)
|
84
|
+
self.max_call_time = other.max_call_time if other.max_call_time > max_call_time
|
85
|
+
end
|
86
|
+
|
87
|
+
def merge_attributes(other)
|
88
|
+
update_totals(other)
|
89
|
+
expand_min_max_to(other)
|
90
|
+
self.call_count += other.call_count
|
91
|
+
update_boundaries(other)
|
92
|
+
end
|
93
|
+
|
94
|
+
def merge!(other_stats)
|
95
|
+
Array(other_stats).each do |other|
|
96
|
+
merge_attributes(other)
|
97
|
+
end
|
98
|
+
|
99
|
+
self
|
100
|
+
end
|
101
|
+
|
102
|
+
def merge(other_stats)
|
103
|
+
stats = self.clone
|
104
|
+
stats.merge!(other_stats)
|
105
|
+
end
|
106
|
+
|
107
|
+
|
108
|
+
def is_reset?
|
109
|
+
call_count == 0 && total_call_time == 0.0 && total_exclusive_time == 0.0
|
110
|
+
end
|
111
|
+
|
112
|
+
def reset
|
113
|
+
self.call_count = 0
|
114
|
+
self.total_call_time = 0.0
|
115
|
+
self.total_exclusive_time = 0.0
|
116
|
+
self.min_call_time = 0.0
|
117
|
+
self.max_call_time = 0.0
|
118
|
+
self.sum_of_squares = 0.0
|
119
|
+
self.begin_time = Time.at(0)
|
120
|
+
self.end_time = Time.at(0)
|
121
|
+
end
|
122
|
+
|
123
|
+
def as_percentage_of(other_stats)
|
124
|
+
checked_calculation(total_call_time, other_stats.total_call_time) * 100.0
|
125
|
+
end
|
126
|
+
|
127
|
+
# the stat total_call_time is a percent
|
128
|
+
def as_percentage
|
129
|
+
average_call_time * 100.0
|
130
|
+
end
|
131
|
+
|
132
|
+
def duration
|
133
|
+
end_time ? (end_time - begin_time) : 0.0
|
134
|
+
end
|
135
|
+
|
136
|
+
def midpoint
|
137
|
+
begin_time + (duration/2)
|
138
|
+
end
|
139
|
+
def calls_per_minute
|
140
|
+
checked_calculation(call_count, duration) * 60
|
141
|
+
end
|
142
|
+
|
143
|
+
def total_call_time_per_minute
|
144
|
+
60.0 * time_percentage
|
145
|
+
end
|
146
|
+
|
147
|
+
def standard_deviation
|
148
|
+
return 0 if call_count < 2 || self.sum_of_squares.nil?
|
149
|
+
|
150
|
+
# Convert sum of squares into standard deviation based on
|
151
|
+
# formula for the standard deviation for the entire population
|
152
|
+
x = self.sum_of_squares - (self.call_count * (self.average_value**2))
|
153
|
+
return 0 if x <= 0
|
154
|
+
|
155
|
+
Math.sqrt(x / self.call_count)
|
156
|
+
end
|
157
|
+
|
158
|
+
# returns the time spent in this component as a percentage of the total
|
159
|
+
# time window.
|
160
|
+
def time_percentage
|
161
|
+
checked_calculation(total_call_time, duration)
|
162
|
+
end
|
163
|
+
|
164
|
+
def exclusive_time_percentage
|
165
|
+
checked_calculation(total_exclusive_time, duration)
|
166
|
+
end
|
167
|
+
|
168
|
+
alias average_value average_call_time
|
169
|
+
alias average_response_time average_call_time
|
170
|
+
alias requests_per_minute calls_per_minute
|
171
|
+
|
172
|
+
def to_s
|
173
|
+
summary
|
174
|
+
end
|
175
|
+
|
176
|
+
# Summary string to facilitate testing
|
177
|
+
def summary
|
178
|
+
format = "%m/%d/%y %I:%M%p"
|
179
|
+
"[#{Time.at(begin_time.to_f).utc.strftime(format)} UTC, #{'%2.3fs' % duration.to_f}; #{'%2i' % call_count.to_i} calls #{'%4i' % average_call_time.to_f}s]"
|
180
|
+
end
|
181
|
+
|
182
|
+
# multiply the total time and rate by the given percentage
|
183
|
+
def multiply_by(percentage)
|
184
|
+
self.total_call_time = total_call_time * percentage
|
185
|
+
self.call_count = call_count * percentage
|
186
|
+
self.sum_of_squares = sum_of_squares * percentage
|
187
|
+
|
188
|
+
self
|
189
|
+
end
|
190
|
+
|
191
|
+
# returns s,t,f
|
192
|
+
def get_apdex
|
193
|
+
[@call_count, @total_call_time.to_i, @total_exclusive_time.to_i]
|
194
|
+
end
|
195
|
+
|
196
|
+
def apdex_score
|
197
|
+
s, t, f = get_apdex
|
198
|
+
(s.to_f + (t.to_f / 2)) / (s+t+f).to_f
|
199
|
+
end
|
200
|
+
end
|
201
|
+
|
202
|
+
|
203
|
+
class StatsBase
|
204
|
+
include Stats
|
205
|
+
|
206
|
+
attr_accessor :call_count
|
207
|
+
attr_accessor :min_call_time
|
208
|
+
attr_accessor :max_call_time
|
209
|
+
attr_accessor :total_call_time
|
210
|
+
attr_accessor :total_exclusive_time
|
211
|
+
attr_accessor :sum_of_squares
|
212
|
+
|
213
|
+
def initialize
|
214
|
+
reset
|
215
|
+
end
|
216
|
+
|
217
|
+
def freeze
|
218
|
+
@end_time = Time.now
|
219
|
+
super
|
220
|
+
end
|
221
|
+
|
222
|
+
def to_json(*a)
|
223
|
+
{'call_count' => call_count,
|
224
|
+
'min_call_time' => min_call_time,
|
225
|
+
'max_call_time' => max_call_time,
|
226
|
+
'total_call_time' => total_call_time,
|
227
|
+
'total_exclusive_time' => total_exclusive_time,
|
228
|
+
'sum_of_squares' => sum_of_squares}.to_json(*a)
|
229
|
+
end
|
230
|
+
|
231
|
+
|
232
|
+
# In this class, we explicitly don't track begin and end time here, to save space during
|
233
|
+
# cross process serialization via xml. Still the accessor methods must be provided for merge to work.
|
234
|
+
def begin_time=(t)
|
235
|
+
end
|
236
|
+
|
237
|
+
def end_time=(t)
|
238
|
+
end
|
239
|
+
|
240
|
+
def begin_time
|
241
|
+
0.0
|
242
|
+
end
|
243
|
+
|
244
|
+
def end_time
|
245
|
+
0.0
|
246
|
+
end
|
247
|
+
end
|
248
|
+
|
249
|
+
|
250
|
+
class BasicStats < StatsBase
|
251
|
+
end
|
252
|
+
|
253
|
+
class ApdexStats < StatsBase
|
254
|
+
|
255
|
+
def record_apdex_s
|
256
|
+
@call_count += 1
|
257
|
+
end
|
258
|
+
|
259
|
+
def record_apdex_t
|
260
|
+
@total_call_time += 1
|
261
|
+
end
|
262
|
+
|
263
|
+
def record_apdex_f
|
264
|
+
@total_exclusive_time += 1
|
265
|
+
end
|
266
|
+
end
|
267
|
+
|
268
|
+
# Statistics used to track the performance of traced methods
|
269
|
+
class MethodTraceStats < StatsBase
|
270
|
+
|
271
|
+
alias data_point_count call_count
|
272
|
+
|
273
|
+
# record a single data point into the statistical gatherer. The gatherer
|
274
|
+
# will aggregate all data points collected over a specified period and upload
|
275
|
+
# its data to the NewRelic server
|
276
|
+
def record_data_point(value, exclusive_time = value)
|
277
|
+
@call_count += 1
|
278
|
+
@total_call_time += value
|
279
|
+
@min_call_time = value if value < @min_call_time || @call_count == 1
|
280
|
+
@max_call_time = value if value > @max_call_time
|
281
|
+
@total_exclusive_time += exclusive_time
|
282
|
+
|
283
|
+
@sum_of_squares += (value * value)
|
284
|
+
self
|
285
|
+
end
|
286
|
+
|
287
|
+
alias trace_call record_data_point
|
288
|
+
|
289
|
+
# Records multiple data points as one method call - this handles
|
290
|
+
# all the aggregation that would be done with multiple
|
291
|
+
# record_data_point calls
|
292
|
+
def record_multiple_data_points(total_value, count=1)
|
293
|
+
return record_data_point(total_value) if count == 1
|
294
|
+
@call_count += count
|
295
|
+
@total_call_time += total_value
|
296
|
+
avg_val = total_value / count
|
297
|
+
@min_call_time = avg_val if avg_val < @min_call_time || @call_count == count
|
298
|
+
@max_call_time = avg_val if avg_val > @max_call_time
|
299
|
+
@total_exclusive_time += total_value
|
300
|
+
@sum_of_squares += (avg_val * avg_val) * count
|
301
|
+
self
|
302
|
+
end
|
303
|
+
|
304
|
+
# increments the call_count by one
|
305
|
+
def increment_count(value = 1)
|
306
|
+
@call_count += value
|
307
|
+
end
|
308
|
+
|
309
|
+
# outputs a human-readable version of the MethodTraceStats object
|
310
|
+
def inspect
|
311
|
+
"#<NewRelic::MethodTraceStats #{summary} >"
|
312
|
+
end
|
313
|
+
|
314
|
+
end
|
315
|
+
|
316
|
+
class ScopedMethodTraceStats < MethodTraceStats
|
317
|
+
attr_accessor :unscoped_stats
|
318
|
+
def initialize(unscoped_stats)
|
319
|
+
super()
|
320
|
+
self.unscoped_stats = unscoped_stats
|
321
|
+
end
|
322
|
+
def trace_call(call_time, exclusive_time = call_time)
|
323
|
+
unscoped_stats.trace_call call_time, exclusive_time
|
324
|
+
super call_time, exclusive_time
|
325
|
+
end
|
326
|
+
# Records multiple data points as one method call - this handles
|
327
|
+
# all the aggregation that would be done with multiple
|
328
|
+
# trace_call calls
|
329
|
+
def record_multiple_data_points(total_value, count=1)
|
330
|
+
unscoped_stats.record_multiple_data_points(total_value, count)
|
331
|
+
super total_value, count
|
332
|
+
end
|
333
|
+
end
|
334
|
+
end
|
335
|
+
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# Copyright: (C) 2008 David Vollbracht & Philippe Hanrigou
|
2
|
+
|
3
|
+
# This code was borrowed from the system_timer gem under the terms
|
4
|
+
# of the Ruby license. It has been slightly modified.
|
5
|
+
|
6
|
+
# Defines the constant TimerLib to the appropriate timeout library
|
7
|
+
module NewRelic #:nodoc:
|
8
|
+
|
9
|
+
begin
|
10
|
+
# Try to use the SystemTimer gem instead of Ruby's timeout library
|
11
|
+
# when running on Ruby 1.8.x. See:
|
12
|
+
# http://ph7spot.com/articles/system_timer
|
13
|
+
# We don't want to bother trying to load SystemTimer on jruby,
|
14
|
+
# ruby 1.9+ and rbx.
|
15
|
+
if !defined?(RUBY_ENGINE) || (RUBY_ENGINE == 'ruby' && RUBY_VERSION < '1.9.0')
|
16
|
+
require 'system_timer'
|
17
|
+
TimerLib = SystemTimer
|
18
|
+
else
|
19
|
+
require 'timeout'
|
20
|
+
TimerLib = Timeout
|
21
|
+
end
|
22
|
+
rescue LoadError => e
|
23
|
+
require 'timeout'
|
24
|
+
TimerLib = Timeout
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
@@ -0,0 +1,77 @@
|
|
1
|
+
require 'new_relic/transaction_analysis/segment_summary'
|
2
|
+
# Add these methods to TransactionSample that enable performance analysis in the user interface.
|
3
|
+
module NewRelic
|
4
|
+
module TransactionAnalysis
|
5
|
+
def database_time
|
6
|
+
time_percentage(/^Database\/.*/)
|
7
|
+
end
|
8
|
+
|
9
|
+
def render_time
|
10
|
+
time_percentage(/^View\/.*/)
|
11
|
+
end
|
12
|
+
|
13
|
+
# return the data that breaks down the performance of the transaction
|
14
|
+
# as an array of SegmentSummary objects. If a limit is specified, then
|
15
|
+
# limit the data set to the top n
|
16
|
+
def breakdown_data(limit = nil)
|
17
|
+
metric_hash = {}
|
18
|
+
each_segment_with_nest_tracking do |segment|
|
19
|
+
unless segment == root_segment
|
20
|
+
metric_name = segment.metric_name
|
21
|
+
metric_hash[metric_name] ||= SegmentSummary.new(metric_name, self)
|
22
|
+
metric_hash[metric_name] << segment
|
23
|
+
metric_hash[metric_name]
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
data = metric_hash.values
|
28
|
+
|
29
|
+
data.sort! do |x,y|
|
30
|
+
y.exclusive_time <=> x.exclusive_time
|
31
|
+
end
|
32
|
+
|
33
|
+
if limit && data.length > limit
|
34
|
+
data = data[0..limit - 1]
|
35
|
+
end
|
36
|
+
|
37
|
+
# add one last segment for the remaining time if any
|
38
|
+
remainder = duration
|
39
|
+
data.each do |segment|
|
40
|
+
remainder -= segment.exclusive_time
|
41
|
+
end
|
42
|
+
|
43
|
+
if (remainder*1000).round > 0
|
44
|
+
remainder_summary = SegmentSummary.new('Remainder', self)
|
45
|
+
remainder_summary.total_time = remainder_summary.exclusive_time = remainder
|
46
|
+
remainder_summary.call_count = 1
|
47
|
+
data << remainder_summary
|
48
|
+
end
|
49
|
+
|
50
|
+
data
|
51
|
+
end
|
52
|
+
|
53
|
+
# return an array of sql statements executed by this transaction
|
54
|
+
# each element in the array contains [sql, parent_segment_metric_name, duration]
|
55
|
+
def sql_segments(show_non_sql_segments = true)
|
56
|
+
segments = []
|
57
|
+
each_segment do |segment|
|
58
|
+
segments << segment if segment[:sql] || segment[:sql_obfuscated] || (show_non_sql_segments && segment[:key])
|
59
|
+
end
|
60
|
+
segments
|
61
|
+
end
|
62
|
+
|
63
|
+
private
|
64
|
+
def time_percentage(regex)
|
65
|
+
total = 0
|
66
|
+
each_segment do |segment|
|
67
|
+
if regex =~ segment.metric_name
|
68
|
+
total += segment.duration
|
69
|
+
end
|
70
|
+
end
|
71
|
+
fraction = 100.0 * total / duration
|
72
|
+
# percent value rounded to two digits:
|
73
|
+
return (100 * fraction).round / 100.0
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|