sundawg_newrelic_rpm 3.5.8.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +22 -0
- data/.project +23 -0
- data/.travis.yml +9 -0
- data/CHANGELOG +969 -0
- data/GUIDELINES_FOR_CONTRIBUTING.md +76 -0
- data/Gemfile +20 -0
- data/LICENSE +87 -0
- data/README.md +195 -0
- data/Rakefile +58 -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/config.dot +290 -0
- data/config/database.yml +5 -0
- data/gem-public_cert.pem +20 -0
- data/init.rb +31 -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 +488 -0
- data/lib/new_relic/agent/agent.rb +1069 -0
- data/lib/new_relic/agent/agent_logger.rb +173 -0
- data/lib/new_relic/agent/audit_logger.rb +72 -0
- data/lib/new_relic/agent/beacon_configuration.rb +107 -0
- data/lib/new_relic/agent/browser_monitoring.rb +195 -0
- data/lib/new_relic/agent/busy_calculator.rb +112 -0
- data/lib/new_relic/agent/chained_call.rb +13 -0
- data/lib/new_relic/agent/configuration.rb +74 -0
- data/lib/new_relic/agent/configuration/defaults.rb +132 -0
- data/lib/new_relic/agent/configuration/environment_source.rb +49 -0
- data/lib/new_relic/agent/configuration/manager.rb +148 -0
- data/lib/new_relic/agent/configuration/mask_defaults.rb +11 -0
- data/lib/new_relic/agent/configuration/server_source.rb +31 -0
- data/lib/new_relic/agent/configuration/yaml_source.rb +67 -0
- data/lib/new_relic/agent/cross_app_monitor.rb +239 -0
- data/lib/new_relic/agent/cross_app_tracing.rb +281 -0
- data/lib/new_relic/agent/database.rb +254 -0
- data/lib/new_relic/agent/error_collector.rb +266 -0
- data/lib/new_relic/agent/event_listener.rb +43 -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 +134 -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/browser_monitoring_timings.rb +51 -0
- data/lib/new_relic/agent/instrumentation/controller_instrumentation.rb +485 -0
- data/lib/new_relic/agent/instrumentation/data_mapper.rb +230 -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 +356 -0
- data/lib/new_relic/agent/instrumentation/metric_frame/pop.rb +80 -0
- data/lib/new_relic/agent/instrumentation/net.rb +31 -0
- data/lib/new_relic/agent/instrumentation/passenger_instrumentation.rb +23 -0
- data/lib/new_relic/agent/instrumentation/queue_time.rb +68 -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 +41 -0
- data/lib/new_relic/agent/instrumentation/rails4/action_controller.rb +145 -0
- data/lib/new_relic/agent/instrumentation/rails4/errors.rb +45 -0
- data/lib/new_relic/agent/instrumentation/resque.rb +81 -0
- data/lib/new_relic/agent/instrumentation/sinatra.rb +107 -0
- data/lib/new_relic/agent/instrumentation/sunspot.rb +29 -0
- data/lib/new_relic/agent/instrumentation/unicorn_instrumentation.rb +22 -0
- data/lib/new_relic/agent/method_tracer.rb +530 -0
- data/lib/new_relic/agent/new_relic_service.rb +513 -0
- data/lib/new_relic/agent/pipe_channel_manager.rb +175 -0
- data/lib/new_relic/agent/pipe_service.rb +63 -0
- data/lib/new_relic/agent/rules_engine.rb +72 -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_sampler.rb +86 -0
- data/lib/new_relic/agent/samplers/memory_sampler.rb +141 -0
- data/lib/new_relic/agent/samplers/object_sampler.rb +26 -0
- data/lib/new_relic/agent/shim_agent.rb +28 -0
- data/lib/new_relic/agent/sql_sampler.rb +251 -0
- data/lib/new_relic/agent/stats.rb +149 -0
- data/lib/new_relic/agent/stats_engine.rb +30 -0
- data/lib/new_relic/agent/stats_engine/gc_profiler.rb +116 -0
- data/lib/new_relic/agent/stats_engine/metric_stats.rb +161 -0
- data/lib/new_relic/agent/stats_engine/samplers.rb +97 -0
- data/lib/new_relic/agent/stats_engine/stats_hash.rb +58 -0
- data/lib/new_relic/agent/stats_engine/transactions.rb +145 -0
- data/lib/new_relic/agent/thread.rb +32 -0
- data/lib/new_relic/agent/thread_profiler.rb +319 -0
- data/lib/new_relic/agent/transaction_info.rb +119 -0
- data/lib/new_relic/agent/transaction_sample_builder.rb +126 -0
- data/lib/new_relic/agent/transaction_sampler.rb +459 -0
- data/lib/new_relic/agent/worker_loop.rb +96 -0
- data/lib/new_relic/coerce.rb +37 -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 +114 -0
- data/lib/new_relic/commands/install.rb +80 -0
- data/lib/new_relic/control.rb +44 -0
- data/lib/new_relic/control/class_methods.rb +58 -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 +25 -0
- data/lib/new_relic/control/frameworks/rails.rb +173 -0
- data/lib/new_relic/control/frameworks/rails3.rb +71 -0
- data/lib/new_relic/control/frameworks/rails4.rb +23 -0
- data/lib/new_relic/control/frameworks/ruby.rb +21 -0
- data/lib/new_relic/control/frameworks/sinatra.rb +20 -0
- data/lib/new_relic/control/instance_methods.rb +145 -0
- data/lib/new_relic/control/instrumentation.rb +95 -0
- data/lib/new_relic/control/profiling.rb +25 -0
- data/lib/new_relic/control/server_methods.rb +80 -0
- data/lib/new_relic/delayed_job_injection.rb +51 -0
- data/lib/new_relic/helper.rb +66 -0
- data/lib/new_relic/language_support.rb +92 -0
- data/lib/new_relic/latest_changes.rb +31 -0
- data/lib/new_relic/local_environment.rb +385 -0
- data/lib/new_relic/merbtasks.rb +6 -0
- data/lib/new_relic/metric_data.rb +70 -0
- data/lib/new_relic/metric_spec.rb +80 -0
- data/lib/new_relic/metrics.rb +9 -0
- data/lib/new_relic/noticed_error.rb +59 -0
- data/lib/new_relic/okjson.rb +599 -0
- data/lib/new_relic/rack.rb +4 -0
- data/lib/new_relic/rack/agent_hooks.rb +20 -0
- data/lib/new_relic/rack/browser_monitoring.rb +85 -0
- data/lib/new_relic/rack/developer_mode.rb +271 -0
- data/lib/new_relic/rack/error_collector.rb +66 -0
- data/lib/new_relic/recipes.rb +99 -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 +272 -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 +205 -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 +66 -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 +17 -0
- data/newrelic.yml +227 -0
- data/newrelic_rpm.gemspec +50 -0
- data/recipes/newrelic.rb +6 -0
- data/test/active_record_fixtures.rb +77 -0
- data/test/config/newrelic.yml +49 -0
- data/test/config/test_control.rb +48 -0
- data/test/fixtures/proc_cpuinfo.txt +575 -0
- data/test/intentional_fail.rb +10 -0
- data/test/multiverse/.gitignore +11 -0
- data/test/multiverse/README.md +85 -0
- data/test/multiverse/lib/multiverse/color.rb +13 -0
- data/test/multiverse/lib/multiverse/envfile.rb +66 -0
- data/test/multiverse/lib/multiverse/environment.rb +16 -0
- data/test/multiverse/lib/multiverse/output_collector.rb +29 -0
- data/test/multiverse/lib/multiverse/runner.rb +44 -0
- data/test/multiverse/lib/multiverse/suite.rb +164 -0
- data/test/multiverse/script/run_one +3 -0
- data/test/multiverse/script/runner +9 -0
- data/test/multiverse/suites/active_record/Envfile +13 -0
- data/test/multiverse/suites/active_record/ar_method_aliasing.rb +94 -0
- data/test/multiverse/suites/active_record/config/newrelic.yml +22 -0
- data/test/multiverse/suites/active_record/encoding_test.rb +26 -0
- data/test/multiverse/suites/agent_only/Envfile +9 -0
- data/test/multiverse/suites/agent_only/audit_log_test.rb +97 -0
- data/test/multiverse/suites/agent_only/config/newrelic.yml +23 -0
- data/test/multiverse/suites/agent_only/cross_application_tracing_test.rb +56 -0
- data/test/multiverse/suites/agent_only/http_response_code_test.rb +53 -0
- data/test/multiverse/suites/agent_only/key_transactions_test.rb +66 -0
- data/test/multiverse/suites/agent_only/logging_test.rb +163 -0
- data/test/multiverse/suites/agent_only/marshaling_test.rb +96 -0
- data/test/multiverse/suites/agent_only/method_visibility_test.rb +98 -0
- data/test/multiverse/suites/agent_only/no_dns_resolv.rb +17 -0
- data/test/multiverse/suites/agent_only/pipe_manager_test.rb +33 -0
- data/test/multiverse/suites/agent_only/rename_rule_test.rb +57 -0
- data/test/multiverse/suites/agent_only/rum_instrumentation_test.rb +81 -0
- data/test/multiverse/suites/agent_only/service_timeout_test.rb +32 -0
- data/test/multiverse/suites/agent_only/ssl_test.rb +22 -0
- data/test/multiverse/suites/agent_only/start_up_test.rb +21 -0
- data/test/multiverse/suites/agent_only/test_trace_method_with_punctuation.rb +30 -0
- data/test/multiverse/suites/agent_only/test_trace_transaction_with_punctuation.rb +32 -0
- data/test/multiverse/suites/agent_only/testing_app.rb +17 -0
- data/test/multiverse/suites/agent_only/thread_profiling_test.rb +92 -0
- data/test/multiverse/suites/config_file_loading/Envfile +7 -0
- data/test/multiverse/suites/config_file_loading/config_file_loading_test.rb +106 -0
- data/test/multiverse/suites/datamapper/Envfile +8 -0
- data/test/multiverse/suites/datamapper/config/newrelic.yml +22 -0
- data/test/multiverse/suites/datamapper/encoding_test.rb +36 -0
- data/test/multiverse/suites/rails/Envfile +18 -0
- data/test/multiverse/suites/rails/app.rb +49 -0
- data/test/multiverse/suites/rails/app/views/foos/_foo.html.haml +1 -0
- data/test/multiverse/suites/rails/app/views/views/_a_partial.html.erb +1 -0
- data/test/multiverse/suites/rails/app/views/views/_mid_partial.html.erb +1 -0
- data/test/multiverse/suites/rails/app/views/views/_top_partial.html.erb +3 -0
- data/test/multiverse/suites/rails/app/views/views/deep_partial.html.erb +3 -0
- data/test/multiverse/suites/rails/app/views/views/haml_view.html.haml +6 -0
- data/test/multiverse/suites/rails/app/views/views/index.html.erb +4 -0
- data/test/multiverse/suites/rails/config/newrelic.yml +32 -0
- data/test/multiverse/suites/rails/error_tracing_test.rb +211 -0
- data/test/multiverse/suites/rails/gc_instrumentation_test.rb +79 -0
- data/test/multiverse/suites/rails/queue_time_test.rb +55 -0
- data/test/multiverse/suites/rails/view_instrumentation_test.rb +205 -0
- data/test/multiverse/suites/resque/Envfile +24 -0
- data/test/multiverse/suites/resque/Rakefile +8 -0
- data/test/multiverse/suites/resque/config/newrelic.yml +22 -0
- data/test/multiverse/suites/resque/instrumentation_test.rb +151 -0
- data/test/multiverse/suites/resque/resque_setup.rb +15 -0
- data/test/multiverse/suites/sinatra/Envfile +15 -0
- data/test/multiverse/suites/sinatra/config/newrelic.yml +24 -0
- data/test/multiverse/suites/sinatra/sinatra_error_tracing_test.rb +38 -0
- data/test/multiverse/suites/sinatra/sinatra_metric_explosion_test.rb +77 -0
- data/test/multiverse/suites/sinatra/sinatra_routes_test.rb +46 -0
- data/test/multiverse/suites/sinatra/sinatra_test.rb +139 -0
- data/test/multiverse/test/multiverse_test.rb +55 -0
- data/test/multiverse/test/suite_examples/one/a/Envfile +3 -0
- data/test/multiverse/test/suite_examples/one/a/a_test.rb +11 -0
- data/test/multiverse/test/suite_examples/one/a/config/newrelic.yml +24 -0
- data/test/multiverse/test/suite_examples/one/b/Envfile +3 -0
- data/test/multiverse/test/suite_examples/one/b/b_test.rb +11 -0
- data/test/multiverse/test/suite_examples/one/b/config/newrelic.yml +24 -0
- data/test/multiverse/test/suite_examples/three/a/Envfile +2 -0
- data/test/multiverse/test/suite_examples/three/a/fail_test.rb +6 -0
- data/test/multiverse/test/suite_examples/three/b/Envfile +2 -0
- data/test/multiverse/test/suite_examples/three/b/win_test.rb +6 -0
- data/test/multiverse/test/suite_examples/two/a/Envfile +1 -0
- data/test/multiverse/test/suite_examples/two/a/fail_test.rb +6 -0
- data/test/new_relic/agent/agent/connect_test.rb +295 -0
- data/test/new_relic/agent/agent/start_test.rb +205 -0
- data/test/new_relic/agent/agent/start_worker_thread_test.rb +88 -0
- data/test/new_relic/agent/agent_logger_test.rb +153 -0
- data/test/new_relic/agent/agent_test.rb +301 -0
- data/test/new_relic/agent/agent_test_controller.rb +77 -0
- data/test/new_relic/agent/agent_test_controller_test.rb +381 -0
- data/test/new_relic/agent/apdex_from_server_test.rb +9 -0
- data/test/new_relic/agent/audit_logger_test.rb +105 -0
- data/test/new_relic/agent/beacon_configuration_test.rb +107 -0
- data/test/new_relic/agent/browser_monitoring_test.rb +395 -0
- data/test/new_relic/agent/busy_calculator_test.rb +96 -0
- data/test/new_relic/agent/configuration/environment_source_test.rb +79 -0
- data/test/new_relic/agent/configuration/manager_test.rb +232 -0
- data/test/new_relic/agent/configuration/server_source_test.rb +50 -0
- data/test/new_relic/agent/configuration/yaml_source_test.rb +85 -0
- data/test/new_relic/agent/cross_app_monitor_test.rb +237 -0
- data/test/new_relic/agent/database_test.rb +194 -0
- data/test/new_relic/agent/error_collector/notice_error_test.rb +268 -0
- data/test/new_relic/agent/error_collector_test.rb +246 -0
- data/test/new_relic/agent/event_listener_test.rb +67 -0
- data/test/new_relic/agent/instrumentation/active_record_instrumentation_test.rb +606 -0
- data/test/new_relic/agent/instrumentation/browser_monitoring_timings_test.rb +66 -0
- data/test/new_relic/agent/instrumentation/controller_instrumentation_test.rb +107 -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 +151 -0
- data/test/new_relic/agent/instrumentation/net_instrumentation_test.rb +461 -0
- data/test/new_relic/agent/instrumentation/queue_time_test.rb +97 -0
- data/test/new_relic/agent/instrumentation/rack_test.rb +35 -0
- data/test/new_relic/agent/instrumentation/sinatra_test.rb +25 -0
- data/test/new_relic/agent/instrumentation/task_instrumentation_test.rb +182 -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 +158 -0
- data/test/new_relic/agent/method_tracer/instance_methods/trace_execution_scoped_test.rb +222 -0
- data/test/new_relic/agent/method_tracer_test.rb +389 -0
- data/test/new_relic/agent/mock_scope_listener.rb +26 -0
- data/test/new_relic/agent/new_relic_service_test.rb +571 -0
- data/test/new_relic/agent/pipe_channel_manager_test.rb +131 -0
- data/test/new_relic/agent/pipe_service_test.rb +133 -0
- data/test/new_relic/agent/rpm_agent_test.rb +115 -0
- data/test/new_relic/agent/rules_engine_test.rb +82 -0
- data/test/new_relic/agent/sampler_test.rb +19 -0
- data/test/new_relic/agent/shim_agent_test.rb +16 -0
- data/test/new_relic/agent/sql_sampler_test.rb +244 -0
- data/test/new_relic/agent/stats_engine/gc_profiler_test.rb +85 -0
- data/test/new_relic/agent/stats_engine/metric_stats_test.rb +180 -0
- data/test/new_relic/agent/stats_engine/samplers_test.rb +99 -0
- data/test/new_relic/agent/stats_engine_test.rb +184 -0
- data/test/new_relic/agent/stats_hash_test.rb +93 -0
- data/test/new_relic/agent/stats_test.rb +197 -0
- data/test/new_relic/agent/thread_profiler_test.rb +582 -0
- data/test/new_relic/agent/thread_test.rb +89 -0
- data/test/new_relic/agent/threaded_test.rb +65 -0
- data/test/new_relic/agent/transaction_info_test.rb +106 -0
- data/test/new_relic/agent/transaction_sample_builder_test.rb +227 -0
- data/test/new_relic/agent/transaction_sampler_test.rb +968 -0
- data/test/new_relic/agent/worker_loop_test.rb +84 -0
- data/test/new_relic/agent_test.rb +296 -0
- data/test/new_relic/coerce_test.rb +65 -0
- data/test/new_relic/collection_helper_test.rb +148 -0
- data/test/new_relic/command/deployments_test.rb +84 -0
- data/test/new_relic/control/class_methods_test.rb +44 -0
- data/test/new_relic/control/frameworks/rails_test.rb +26 -0
- data/test/new_relic/control_test.rb +194 -0
- data/test/new_relic/delayed_job_injection_test.rb +21 -0
- data/test/new_relic/dispatcher_test.rb +54 -0
- data/test/new_relic/fake_collector.rb +389 -0
- data/test/new_relic/framework_test.rb +53 -0
- data/test/new_relic/helper_test.rb +24 -0
- data/test/new_relic/load_test.rb +13 -0
- data/test/new_relic/local_environment_test.rb +85 -0
- data/test/new_relic/metric_data_test.rb +183 -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/noticed_error_test.rb +32 -0
- data/test/new_relic/rack/agent_hooks_test.rb +30 -0
- data/test/new_relic/rack/all_test.rb +11 -0
- data/test/new_relic/rack/browser_monitoring_test.rb +152 -0
- data/test/new_relic/rack/developer_mode_helper_test.rb +141 -0
- data/test/new_relic/rack/developer_mode_test.rb +80 -0
- data/test/new_relic/rack/error_collector_test.rb +90 -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 +415 -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 +250 -0
- data/test/new_relic/version_number_test.rb +97 -0
- data/test/script/build_test_gem.sh +57 -0
- data/test/script/ci.sh +168 -0
- data/test/script/ci_agent-tests_runner.sh +82 -0
- data/test/script/ci_bench.sh +52 -0
- data/test/script/ci_multiverse_runner.sh +63 -0
- data/test/test_contexts.rb +30 -0
- data/test/test_helper.rb +240 -0
- data/ui/helpers/developer_mode_helper.rb +367 -0
- data/ui/helpers/google_pie_chart.rb +49 -0
- data/ui/views/layouts/newrelic_default.rhtml +48 -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 +45 -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/.specification +116 -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/servlet_init.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 +494 -0
@@ -0,0 +1,96 @@
|
|
1
|
+
require 'thread'
|
2
|
+
module NewRelic
|
3
|
+
module Agent
|
4
|
+
|
5
|
+
# A worker loop executes a set of registered tasks on a single thread.
|
6
|
+
# A task is a proc or block with a specified call period in seconds.
|
7
|
+
class WorkerLoop
|
8
|
+
|
9
|
+
# Optional argument :duration (in seconds) for how long the worker loop runs
|
10
|
+
# or :limit (integer) for max number of iterations
|
11
|
+
def initialize(opts={})
|
12
|
+
@should_run = true
|
13
|
+
@next_invocation_time = Time.now
|
14
|
+
@period = 60.0
|
15
|
+
@duration = opts[:duration] if opts[:duration]
|
16
|
+
@limit = opts[:limit] if opts[:limit]
|
17
|
+
@iterations = 0
|
18
|
+
end
|
19
|
+
|
20
|
+
# returns a class-level memoized mutex to make sure we don't run overlapping
|
21
|
+
def lock
|
22
|
+
@@lock ||= Mutex.new
|
23
|
+
end
|
24
|
+
|
25
|
+
# Run infinitely, calling the registered tasks at their specified
|
26
|
+
# call periods. The caller is responsible for creating the thread
|
27
|
+
# that runs this worker loop. This will run the task immediately.
|
28
|
+
def run(period=nil, &block)
|
29
|
+
@deadline = Time.now + @duration if @duration
|
30
|
+
@period = period if period
|
31
|
+
@next_invocation_time = (Time.now + @period)
|
32
|
+
@task = block
|
33
|
+
while keep_running? do
|
34
|
+
while @now < @next_invocation_time
|
35
|
+
# sleep until this next task's scheduled invocation time
|
36
|
+
sleep_time = @next_invocation_time - @now
|
37
|
+
sleep sleep_time if sleep_time > 0
|
38
|
+
@now = Time.now
|
39
|
+
end
|
40
|
+
run_task if keep_running?
|
41
|
+
@iterations += 1 if !@limit.nil?
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
# a simple accessor for @should_run
|
46
|
+
def keep_running?
|
47
|
+
@now = Time.now
|
48
|
+
@should_run && under_duration? && under_limit?
|
49
|
+
end
|
50
|
+
|
51
|
+
def under_duration?
|
52
|
+
!@deadline || @now < @deadline
|
53
|
+
end
|
54
|
+
|
55
|
+
def under_limit?
|
56
|
+
!@limit || @iterations < @limit
|
57
|
+
end
|
58
|
+
|
59
|
+
# Sets @should_run to false. Returns false
|
60
|
+
def stop
|
61
|
+
@should_run = false
|
62
|
+
end
|
63
|
+
|
64
|
+
# Executes the block given to the worker loop, and handles many
|
65
|
+
# possible errors. Also updates the execution time so that the
|
66
|
+
# next run occurs on schedule, even if we execute at some odd time
|
67
|
+
def run_task
|
68
|
+
begin
|
69
|
+
lock.synchronize do
|
70
|
+
@task.call
|
71
|
+
end
|
72
|
+
rescue ServerError => e
|
73
|
+
::NewRelic::Agent.logger.debug "Server Error:", e
|
74
|
+
rescue NewRelic::Agent::ForceRestartException, NewRelic::Agent::ForceDisconnectException
|
75
|
+
# blow out the loop
|
76
|
+
raise
|
77
|
+
rescue RuntimeError => e
|
78
|
+
# This is probably a server error which has been logged in the server along
|
79
|
+
# with your account name.
|
80
|
+
::NewRelic::Agent.logger.error "Error running task in worker loop, likely a server error:", e
|
81
|
+
rescue Timeout::Error, NewRelic::Agent::ServerConnectionException
|
82
|
+
# Want to ignore these because they are handled already
|
83
|
+
rescue SystemExit, NoMemoryError, SignalException
|
84
|
+
raise
|
85
|
+
rescue => e
|
86
|
+
# Don't blow out the stack for anything that hasn't already propagated
|
87
|
+
::NewRelic::Agent.logger.error "Error running task in Agent Worker Loop:", e
|
88
|
+
end
|
89
|
+
now = Time.now
|
90
|
+
while @next_invocation_time <= now && @period > 0
|
91
|
+
@next_invocation_time += @period
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
module NewRelic
|
2
|
+
# We really don't want to send bad values to the collector, and it doesn't
|
3
|
+
# accept types like Rational that have occasionally slipped into our data.
|
4
|
+
#
|
5
|
+
# These methods are intended to safely coerce things into the form we want,
|
6
|
+
# to provide documentation of expected types on to_collector_array methods,
|
7
|
+
# and to log failures if totally invalid data gets into outgoing data
|
8
|
+
module Coerce
|
9
|
+
def int(value, context=nil)
|
10
|
+
Integer(value)
|
11
|
+
rescue => error
|
12
|
+
log_failure(value, Integer, context, error)
|
13
|
+
0
|
14
|
+
end
|
15
|
+
|
16
|
+
def float(value, context=nil)
|
17
|
+
Float(value)
|
18
|
+
rescue => error
|
19
|
+
log_failure(value, Float, context, error)
|
20
|
+
0.0
|
21
|
+
end
|
22
|
+
|
23
|
+
def string(value, context=nil)
|
24
|
+
return value if value.nil?
|
25
|
+
String(value)
|
26
|
+
rescue => error
|
27
|
+
log_failure(value.class, String, context, error)
|
28
|
+
""
|
29
|
+
end
|
30
|
+
|
31
|
+
def log_failure(value, type, context, error)
|
32
|
+
msg = "Unable to convert '#{value}' to #{type}"
|
33
|
+
msg += " in context '#{context}'" if context
|
34
|
+
NewRelic::Agent.logger.warn(msg, error)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,77 @@
|
|
1
|
+
require 'new_relic/control'
|
2
|
+
|
3
|
+
module NewRelic
|
4
|
+
module CollectionHelper
|
5
|
+
DEFAULT_TRUNCATION_SIZE=16 * 1024
|
6
|
+
DEFAULT_ARRAY_TRUNCATION_SIZE=128
|
7
|
+
# Transform parameter hash into a hash whose values are strictly
|
8
|
+
# strings
|
9
|
+
def normalize_params(params)
|
10
|
+
case params
|
11
|
+
when Hash
|
12
|
+
# optimize for empty hash since that is often what this is called with.
|
13
|
+
return params if params.empty?
|
14
|
+
new_params = {}
|
15
|
+
params.each do | key, value |
|
16
|
+
new_params[truncate(normalize_params(key),64)] = normalize_params(value)
|
17
|
+
end
|
18
|
+
new_params
|
19
|
+
when Symbol, FalseClass, TrueClass, nil
|
20
|
+
params
|
21
|
+
when Numeric
|
22
|
+
truncate(params.to_s)
|
23
|
+
when String
|
24
|
+
truncate(params)
|
25
|
+
when Array
|
26
|
+
params.first(DEFAULT_ARRAY_TRUNCATION_SIZE).map{|item| normalize_params(item)}
|
27
|
+
else
|
28
|
+
truncate(flatten(params))
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
# Return an array of strings (backtrace), cleaned up for readability
|
33
|
+
# Return nil if there is no backtrace
|
34
|
+
|
35
|
+
def strip_nr_from_backtrace(backtrace)
|
36
|
+
if backtrace && !Agent.config[:disable_backtrace_cleanup]
|
37
|
+
# this is for 1.9.1, where strings no longer have Enumerable
|
38
|
+
backtrace = backtrace.split("\n") if String === backtrace
|
39
|
+
backtrace = backtrace.map &:to_s
|
40
|
+
backtrace = backtrace.reject do |line|
|
41
|
+
line.include?(NewRelic::Control.newrelic_root) or
|
42
|
+
line =~ /^newrelic_rpm\s/
|
43
|
+
end
|
44
|
+
# rename methods back to their original state
|
45
|
+
backtrace = backtrace.collect {|line| line.gsub(/_without_(newrelic|trace)/, "")}
|
46
|
+
end
|
47
|
+
backtrace
|
48
|
+
end
|
49
|
+
|
50
|
+
private
|
51
|
+
|
52
|
+
# Convert any kind of object to a short string.
|
53
|
+
def flatten(object)
|
54
|
+
s = case object
|
55
|
+
when nil then ''
|
56
|
+
when object.instance_of?(String) then object
|
57
|
+
when String then String.new(object) # convert string subclasses to strings
|
58
|
+
else "#<#{object.class.to_s}>"
|
59
|
+
end
|
60
|
+
end
|
61
|
+
def truncate(string, len=DEFAULT_TRUNCATION_SIZE)
|
62
|
+
case string
|
63
|
+
when Symbol then string
|
64
|
+
when nil then ""
|
65
|
+
when String
|
66
|
+
real_string = flatten(string)
|
67
|
+
if real_string.size > len
|
68
|
+
real_string = real_string.slice(0...len)
|
69
|
+
real_string << "..."
|
70
|
+
end
|
71
|
+
real_string
|
72
|
+
else
|
73
|
+
truncate(flatten(string), len)
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
@@ -0,0 +1,85 @@
|
|
1
|
+
require 'optparse'
|
2
|
+
|
3
|
+
# Run the command given by the first argument. Right
|
4
|
+
# now all we have is deployments. We hope to have other
|
5
|
+
# kinds of events here later.
|
6
|
+
$LOAD_PATH << "#{File.dirname(__FILE__)}/.."
|
7
|
+
module NewRelic
|
8
|
+
class Command
|
9
|
+
attr_accessor :leftover
|
10
|
+
# Capture a failure to execute the command.
|
11
|
+
class CommandFailure < StandardError
|
12
|
+
attr_reader :options
|
13
|
+
def initialize message, opt_parser=nil
|
14
|
+
super message
|
15
|
+
@options = opt_parser
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def info(message)
|
20
|
+
STDOUT.puts message
|
21
|
+
end
|
22
|
+
|
23
|
+
def err(message)
|
24
|
+
STDERR.puts message
|
25
|
+
end
|
26
|
+
|
27
|
+
def initialize(command_line_args)
|
28
|
+
if Hash === command_line_args
|
29
|
+
# command line args is an options hash
|
30
|
+
command_line_args.each do | key, value |
|
31
|
+
instance_variable_set "@#{key}", value.to_s if value
|
32
|
+
end
|
33
|
+
else
|
34
|
+
# parse command line args. Throw an exception on a bad arg.
|
35
|
+
@options = options do | opts |
|
36
|
+
opts.on("-h", "Show this help") { raise CommandFailure, opts.to_s }
|
37
|
+
end
|
38
|
+
@leftover = @options.parse(command_line_args)
|
39
|
+
end
|
40
|
+
rescue OptionParser::ParseError => e
|
41
|
+
raise CommandFailure.new(e.message, @options)
|
42
|
+
end
|
43
|
+
|
44
|
+
@commands = []
|
45
|
+
def self.inherited(subclass)
|
46
|
+
@commands << subclass
|
47
|
+
end
|
48
|
+
|
49
|
+
cmds = File.expand_path(File.join(File.dirname(__FILE__), 'commands', '*.rb'))
|
50
|
+
Dir[cmds].each{|command| require command }
|
51
|
+
|
52
|
+
def self.run
|
53
|
+
|
54
|
+
@command_names = @commands.map{ |c| c.command }
|
55
|
+
|
56
|
+
extra = []
|
57
|
+
options = ARGV.options do |opts|
|
58
|
+
script_name = File.basename($0)
|
59
|
+
if script_name =~ /newrelic_cmd$/
|
60
|
+
$stdout.puts "warning: the 'newrelic_cmd' script has been renamed 'newrelic'"
|
61
|
+
script_name = 'newrelic'
|
62
|
+
end
|
63
|
+
opts.banner = "Usage: #{script_name} [ #{ @command_names.join(" | ")} ] [options]"
|
64
|
+
opts.separator "use '#{script_name} <command> -h' to see detailed command options"
|
65
|
+
opts
|
66
|
+
end
|
67
|
+
extra = options.order!
|
68
|
+
command = extra.shift
|
69
|
+
# just make it a little easier on them
|
70
|
+
command = 'deployments' if command =~ /deploy/
|
71
|
+
if command.nil?
|
72
|
+
STDERR.puts options
|
73
|
+
elsif !@command_names.include?(command)
|
74
|
+
STDERR.puts "Unrecognized command: #{command}"
|
75
|
+
STDERR.puts options
|
76
|
+
else
|
77
|
+
command_class = @commands.find{ |c| c.command == command}
|
78
|
+
command_class.new(extra).run
|
79
|
+
end
|
80
|
+
rescue OptionParser::InvalidOption => e
|
81
|
+
raise NewRelic::Command::CommandFailure, e.message
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
end
|
@@ -0,0 +1,114 @@
|
|
1
|
+
# This is a class for executing commands related to deployment
|
2
|
+
# events. It runs without loading the rails environment
|
3
|
+
|
4
|
+
require 'yaml'
|
5
|
+
require 'net/http'
|
6
|
+
require 'rexml/document'
|
7
|
+
|
8
|
+
# We need to use the Control object but we don't want to load
|
9
|
+
# the rails/merb environment. The defined? clause is so that
|
10
|
+
# it won't load it twice, something it does when run inside a test
|
11
|
+
require 'new_relic/control' unless defined? NewRelic::Control
|
12
|
+
|
13
|
+
class NewRelic::Command::Deployments < NewRelic::Command
|
14
|
+
attr_reader :control
|
15
|
+
def self.command; "deployments"; end
|
16
|
+
|
17
|
+
# Initialize the deployment uploader with command line args.
|
18
|
+
# Use -h to see options.
|
19
|
+
# When command_line_args is a hash, we are invoking directly and
|
20
|
+
# it's treated as an options with optional string values for
|
21
|
+
# :user, :description, :appname, :revision, :environment,
|
22
|
+
# and :changes.
|
23
|
+
#
|
24
|
+
# Will throw CommandFailed exception if there's any error.
|
25
|
+
#
|
26
|
+
def initialize command_line_args
|
27
|
+
@control = NewRelic::Control.instance
|
28
|
+
super(command_line_args)
|
29
|
+
@description ||= @leftover && @leftover.join(" ")
|
30
|
+
@user ||= ENV['USER']
|
31
|
+
control.env = @environment if @environment
|
32
|
+
load_yaml_from_env(control.env)
|
33
|
+
@appname ||= NewRelic::Agent.config.app_names[0] || control.env || 'development'
|
34
|
+
end
|
35
|
+
|
36
|
+
def load_yaml_from_env(env)
|
37
|
+
yaml = NewRelic::Agent::Configuration::YamlSource.new(NewRelic::Agent.config[:config_path], env)
|
38
|
+
NewRelic::Agent.config.replace_or_add_config(yaml, 1)
|
39
|
+
end
|
40
|
+
|
41
|
+
# Run the Deployment upload in New Relic via Active Resource.
|
42
|
+
# Will possibly print errors and exit the VM
|
43
|
+
def run
|
44
|
+
begin
|
45
|
+
@description = nil if @description && @description.strip.empty?
|
46
|
+
create_params = {}
|
47
|
+
{
|
48
|
+
:application_id => @appname,
|
49
|
+
:host => Socket.gethostname,
|
50
|
+
:description => @description,
|
51
|
+
:user => @user,
|
52
|
+
:revision => @revision,
|
53
|
+
:changelog => @changelog
|
54
|
+
}.each do |k, v|
|
55
|
+
create_params["deployment[#{k}]"] = v unless v.nil? || v == ''
|
56
|
+
end
|
57
|
+
http = ::NewRelic::Agent::NewRelicService.new(nil, control.api_server).http_connection
|
58
|
+
|
59
|
+
uri = "/deployments.xml"
|
60
|
+
|
61
|
+
if NewRelic::Agent.config[:license_key].nil? ||
|
62
|
+
NewRelic::Agent.config[:license_key].empty?
|
63
|
+
raise "license_key was not set in newrelic.yml for #{control.env}"
|
64
|
+
end
|
65
|
+
request = Net::HTTP::Post.new(uri, {'x-license-key' => NewRelic::Agent.config[:license_key]})
|
66
|
+
request.content_type = "application/octet-stream"
|
67
|
+
|
68
|
+
request.set_form_data(create_params)
|
69
|
+
|
70
|
+
response = http.request(request)
|
71
|
+
|
72
|
+
if response.is_a? Net::HTTPSuccess
|
73
|
+
info "Recorded deployment to '#{@appname}' (#{@description || Time.now })"
|
74
|
+
else
|
75
|
+
err_string = REXML::Document.new(response.body).elements['errors/error'].map(&:to_s).join("; ") rescue response.message
|
76
|
+
raise NewRelic::Command::CommandFailure, "Deployment not recorded: #{err_string}"
|
77
|
+
end
|
78
|
+
rescue SystemCallError, SocketError => e
|
79
|
+
# These include Errno connection errors
|
80
|
+
err_string = "Transient error attempting to connect to #{control.api_server} (#{e})"
|
81
|
+
raise NewRelic::Command::CommandFailure.new(err_string)
|
82
|
+
rescue NewRelic::Command::CommandFailure
|
83
|
+
raise
|
84
|
+
rescue => e
|
85
|
+
err "Unexpected error attempting to connect to #{control.api_server}"
|
86
|
+
info "#{e}: #{e.backtrace.join("\n ")}"
|
87
|
+
raise NewRelic::Command::CommandFailure.new(e.to_s)
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
private
|
92
|
+
|
93
|
+
def options
|
94
|
+
OptionParser.new %Q{Usage: #{$0} #{self.class.command} [OPTIONS] ["description"] }, 40 do |o|
|
95
|
+
o.separator "OPTIONS:"
|
96
|
+
o.on("-a", "--appname=NAME", String,
|
97
|
+
"Set the application name.",
|
98
|
+
"Default is app_name setting in newrelic.yml") { | e | @appname = e }
|
99
|
+
o.on("-e", "--environment=name", String,
|
100
|
+
"Override the (RAILS|MERB|RUBY|RACK)_ENV setting",
|
101
|
+
"currently: #{control.env}") { | e | @environment = e }
|
102
|
+
o.on("-u", "--user=USER", String,
|
103
|
+
"Specify the user deploying, for information only",
|
104
|
+
"Default: #{@user || '<none>'}") { | u | @user = u }
|
105
|
+
o.on("-r", "--revision=REV", String,
|
106
|
+
"Specify the revision being deployed") { | r | @revision = r }
|
107
|
+
o.on("-c", "--changes",
|
108
|
+
"Read in a change log from the standard input") { @changelog = STDIN.read }
|
109
|
+
yield o if block_given?
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
|
114
|
+
end
|
@@ -0,0 +1,80 @@
|
|
1
|
+
require 'fileutils'
|
2
|
+
require 'new_relic/version'
|
3
|
+
require 'erb'
|
4
|
+
|
5
|
+
class NewRelic::Command::Install < NewRelic::Command
|
6
|
+
|
7
|
+
NO_LICENSE_KEY = "<PASTE LICENSE KEY HERE>"
|
8
|
+
|
9
|
+
def self.command; "install"; end
|
10
|
+
|
11
|
+
# Use -h to see options.
|
12
|
+
# When command_line_args is a hash, we are invoking directly and
|
13
|
+
# it's treated as an options with optional string values for
|
14
|
+
# :user, :description, :appname, :revision, :environment,
|
15
|
+
# and :changes.
|
16
|
+
#
|
17
|
+
# Will throw CommandFailed exception if there's any error.
|
18
|
+
#
|
19
|
+
attr_reader :dest_dir, :license_key, :generated_for_user, :quiet, :src_file, :app_name
|
20
|
+
def initialize command_line_args={}
|
21
|
+
super command_line_args
|
22
|
+
if !@dest_dir
|
23
|
+
# Install a newrelic.yml file into the local config directory.
|
24
|
+
if File.directory? "config"
|
25
|
+
@dest_dir = "config"
|
26
|
+
else
|
27
|
+
@dest_dir = "."
|
28
|
+
end
|
29
|
+
end
|
30
|
+
@license_key ||= NO_LICENSE_KEY
|
31
|
+
@app_name ||= @leftover
|
32
|
+
raise CommandFailure.new("Application name required.", @options) unless @app_name && @app_name.size > 0
|
33
|
+
@generated_for_user ||= @user_string || ""
|
34
|
+
end
|
35
|
+
|
36
|
+
def run
|
37
|
+
dest_file = File.expand_path(@dest_dir + "/newrelic.yml")
|
38
|
+
if File.exist?(dest_file)
|
39
|
+
raise NewRelic::Command::CommandFailure, "newrelic.yml file already exists. Move it out of the way."
|
40
|
+
end
|
41
|
+
File.open(dest_file, 'w') { | out | out.puts(content) }
|
42
|
+
|
43
|
+
puts <<-EOF unless quiet
|
44
|
+
|
45
|
+
Installed a default configuration file at
|
46
|
+
#{dest_file}.
|
47
|
+
EOF
|
48
|
+
puts <<-EOF unless quiet || @license_key != NO_LICENSE_KEY
|
49
|
+
|
50
|
+
To monitor your application in production mode, sign up for an account
|
51
|
+
at www.newrelic.com, and replace the newrelic.yml file with the one
|
52
|
+
you receive upon registration.
|
53
|
+
EOF
|
54
|
+
puts <<-EOF unless quiet
|
55
|
+
|
56
|
+
E-mail support@newrelic.com with any problems or questions.
|
57
|
+
EOF
|
58
|
+
|
59
|
+
end
|
60
|
+
|
61
|
+
def content
|
62
|
+
@src_file ||= File.expand_path(File.join(File.dirname(__FILE__),"..","..","..","newrelic.yml"))
|
63
|
+
template = File.read(@src_file)
|
64
|
+
ERB.new(template).result(binding)
|
65
|
+
end
|
66
|
+
|
67
|
+
private
|
68
|
+
|
69
|
+
def options
|
70
|
+
OptionParser.new "Usage: #{$0} #{self.class.command} [ OPTIONS] 'application name'", 40 do |o|
|
71
|
+
o.on("-l", "--license_key=NAME", String,
|
72
|
+
"Use the given license key") { | e | @license_key = e }
|
73
|
+
o.on("-d", "--destdir=name", String,
|
74
|
+
"Write the newrelic.yml to the given directory, default is '.'") { | e | @dest_dir = e }
|
75
|
+
yield o if block_given?
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
|
80
|
+
end
|