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,31 @@
|
|
1
|
+
require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'test_helper'))
|
2
|
+
require 'new_relic/transaction_sample/summary_segment'
|
3
|
+
class NewRelic::TransactionSample::SummarySegmentTest < Test::Unit::TestCase
|
4
|
+
def test_summary_segment_creation
|
5
|
+
fake_segment = mock_segment
|
6
|
+
NewRelic::TransactionSample::SummarySegment.new(fake_segment)
|
7
|
+
end
|
8
|
+
|
9
|
+
def test_add_segments
|
10
|
+
fake_segment = mock_segment
|
11
|
+
ss = NewRelic::TransactionSample::SummarySegment.new(fake_segment)
|
12
|
+
other_fake_segment = mock_segment
|
13
|
+
# with the new summary segment
|
14
|
+
ss.expects(:add_called_segment).with(instance_of(NewRelic::TransactionSample::SummarySegment))
|
15
|
+
ss.add_segments([other_fake_segment])
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
@@seg_count = 0
|
21
|
+
def mock_segment
|
22
|
+
@@seg_count += 1
|
23
|
+
segment = mock('segment ' + @@seg_count.to_s)
|
24
|
+
segment.expects(:entry_timestamp).returns(Time.now)
|
25
|
+
segment.expects(:exit_timestamp).returns(Time.now)
|
26
|
+
segment.expects(:metric_name).returns('Custom/test/metric')
|
27
|
+
segment.expects(:called_segments).returns([])
|
28
|
+
segment
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
@@ -0,0 +1,56 @@
|
|
1
|
+
class NewRelic::TransactionSample::SubTest < Test::Unit::TestCase
|
2
|
+
def setup
|
3
|
+
@t = NewRelic::TransactionSample.new
|
4
|
+
|
5
|
+
@t.params[:test] = "hi"
|
6
|
+
|
7
|
+
s1 = @t.create_segment(1.0, "controller")
|
8
|
+
|
9
|
+
@t.root_segment.add_called_segment(s1)
|
10
|
+
|
11
|
+
s2 = @t.create_segment(2.0, "AR1")
|
12
|
+
|
13
|
+
s2.params[:test] = "test"
|
14
|
+
|
15
|
+
s1.add_called_segment(s2)
|
16
|
+
s2.end_trace 3.0
|
17
|
+
s1.end_trace 4.0
|
18
|
+
|
19
|
+
s3 = @t.create_segment(4.0, "post_filter")
|
20
|
+
@t.root_segment.add_called_segment(s3)
|
21
|
+
s3.end_trace 6.0
|
22
|
+
|
23
|
+
s4 = @t.create_segment(6.0, "post_filter")
|
24
|
+
@t.root_segment.add_called_segment(s4)
|
25
|
+
s4.end_trace 7.0
|
26
|
+
end
|
27
|
+
|
28
|
+
def test_exclusive_duration
|
29
|
+
s1 = @t.root_segment.called_segments.first
|
30
|
+
assert_equal 3.0, s1.duration
|
31
|
+
assert_equal 2.0, s1.exclusive_duration
|
32
|
+
end
|
33
|
+
|
34
|
+
def test_count_the_segments
|
35
|
+
assert_equal 4, @t.count_segments
|
36
|
+
end
|
37
|
+
|
38
|
+
def test_truncate_long_samples
|
39
|
+
@t.truncate(2)
|
40
|
+
assert_equal 2, @t.count_segments
|
41
|
+
|
42
|
+
@t = NewRelic::TransactionSample.new
|
43
|
+
|
44
|
+
s1 = @t.create_segment(1.0, "controller")
|
45
|
+
@t.root_segment.add_called_segment(s1)
|
46
|
+
|
47
|
+
100.times do
|
48
|
+
s1.add_called_segment(@t.create_segment(1.0, "segment"))
|
49
|
+
end
|
50
|
+
assert_equal 101, @t.count_segments
|
51
|
+
@t.truncate(2)
|
52
|
+
assert_equal 2, @t.count_segments
|
53
|
+
assert_equal 101, @t.params[:segment_count]
|
54
|
+
end
|
55
|
+
|
56
|
+
end
|
@@ -0,0 +1,177 @@
|
|
1
|
+
require File.expand_path('../../test_helper.rb', __FILE__)
|
2
|
+
|
3
|
+
class NewRelic::TransactionSampleTest < Test::Unit::TestCase
|
4
|
+
include TransactionSampleTestHelper
|
5
|
+
::SQL_STATEMENT = "SELECT * from sandwiches"
|
6
|
+
|
7
|
+
def setup
|
8
|
+
@connection_stub = Mocha::Mockery.instance.named_mock('connection')
|
9
|
+
@connection_stub.stubs(:execute).returns([['QUERY RESULT']])
|
10
|
+
|
11
|
+
NewRelic::Agent::Database.stubs(:get_connection).returns @connection_stub
|
12
|
+
@t = make_sql_transaction(::SQL_STATEMENT, ::SQL_STATEMENT)
|
13
|
+
end
|
14
|
+
|
15
|
+
def test_be_recorded
|
16
|
+
assert_not_nil @t
|
17
|
+
end
|
18
|
+
|
19
|
+
def test_not_record_sql_when_record_sql_off
|
20
|
+
s = @t.prepare_to_send(:explain_sql => 0.00000001)
|
21
|
+
s.each_segment do |segment|
|
22
|
+
assert_nil segment.params[:explain_plan]
|
23
|
+
assert_nil segment.params[:sql]
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def test_record_raw_sql
|
28
|
+
s = @t.prepare_to_send(:explain_sql => 0.00000001, :record_sql => :raw)
|
29
|
+
got_one = false
|
30
|
+
s.each_segment do |segment|
|
31
|
+
fail if segment.params[:obfuscated_sql]
|
32
|
+
got_one = got_one || segment.params[:explain_plan] || segment.params[:sql]
|
33
|
+
end
|
34
|
+
assert got_one
|
35
|
+
end
|
36
|
+
|
37
|
+
def test_record_obfuscated_sql
|
38
|
+
|
39
|
+
s = @t.prepare_to_send(:explain_sql => 0.00000001, :record_sql => :obfuscated)
|
40
|
+
|
41
|
+
got_one = false
|
42
|
+
s.each_segment do |segment|
|
43
|
+
got_one = got_one || segment.params[:explain_plan] || segment.params[:sql]
|
44
|
+
end
|
45
|
+
|
46
|
+
assert got_one
|
47
|
+
end
|
48
|
+
|
49
|
+
def test_have_sql_rows_when_sql_is_recorded
|
50
|
+
s = @t.prepare_to_send(:explain_sql => 0.00000001)
|
51
|
+
|
52
|
+
assert s.sql_segments.empty?
|
53
|
+
s.root_segment[:sql] = 'hello'
|
54
|
+
assert !s.sql_segments.empty?
|
55
|
+
end
|
56
|
+
|
57
|
+
def test_have_sql_rows_when_sql_is_obfuscated
|
58
|
+
s = @t.prepare_to_send(:explain_sql => 0.00000001)
|
59
|
+
|
60
|
+
assert s.sql_segments.empty?
|
61
|
+
s.root_segment[:sql_obfuscated] = 'hello'
|
62
|
+
assert !s.sql_segments.empty?
|
63
|
+
end
|
64
|
+
|
65
|
+
def test_have_sql_rows_when_recording_non_sql_keys
|
66
|
+
s = @t.prepare_to_send(:explain_sql => 0.00000001)
|
67
|
+
|
68
|
+
assert s.sql_segments.empty?
|
69
|
+
s.root_segment[:key] = 'hello'
|
70
|
+
assert !s.sql_segments.empty?
|
71
|
+
end
|
72
|
+
|
73
|
+
def test_catch_exceptions
|
74
|
+
@connection_stub.expects(:execute).raises
|
75
|
+
# the sql connection will throw
|
76
|
+
@t.prepare_to_send(:record_sql => :obfuscated, :explain_sql => 0.00000001)
|
77
|
+
end
|
78
|
+
|
79
|
+
def test_have_explains
|
80
|
+
s = @t.prepare_to_send(:record_sql => :obfuscated, :explain_sql => 0.00000001)
|
81
|
+
|
82
|
+
s.each_segment do |segment|
|
83
|
+
if segment.params[:explain_plan]
|
84
|
+
explanation = segment.params[:explain_plan]
|
85
|
+
|
86
|
+
assert_kind_of Array, explanation
|
87
|
+
assert_equal([nil, [["QUERY RESULT"]]], explanation)
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
def test_not_record_sql_without_record_sql_option
|
93
|
+
t = nil
|
94
|
+
NewRelic::Agent.disable_sql_recording do
|
95
|
+
t = make_sql_transaction(::SQL_STATEMENT, ::SQL_STATEMENT)
|
96
|
+
end
|
97
|
+
|
98
|
+
s = t.prepare_to_send(:explain_sql => 0.00000001)
|
99
|
+
|
100
|
+
s.each_segment do |segment|
|
101
|
+
assert_nil segment.params[:explain_plan]
|
102
|
+
assert_nil segment.params[:sql]
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
def test_not_record_transactions
|
107
|
+
NewRelic::Agent.disable_transaction_tracing do
|
108
|
+
t = make_sql_transaction(::SQL_STATEMENT, ::SQL_STATEMENT)
|
109
|
+
assert t.nil?
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
def test_path_string
|
114
|
+
s = @t.prepare_to_send(:explain_sql => 0.1)
|
115
|
+
fake_segment = mock('segment')
|
116
|
+
fake_segment.expects(:path_string).returns('a path string')
|
117
|
+
s.instance_eval do
|
118
|
+
@root_segment = fake_segment
|
119
|
+
end
|
120
|
+
|
121
|
+
assert_equal('a path string', s.path_string)
|
122
|
+
end
|
123
|
+
|
124
|
+
def test_params_equals
|
125
|
+
s = @t.prepare_to_send(:explain_sql => 0.1)
|
126
|
+
s.params = {:params => 'hash' }
|
127
|
+
assert_equal({:params => 'hash'}, s.params, "should have the specified hash, but instead was #{s.params}")
|
128
|
+
end
|
129
|
+
|
130
|
+
class Hat
|
131
|
+
# just here to mess with the to_s logic in transaction samples
|
132
|
+
end
|
133
|
+
|
134
|
+
def test_to_s_with_bad_object
|
135
|
+
s = @t.prepare_to_send(:explain_sql => 0.1)
|
136
|
+
s.params[:fake] = Hat.new
|
137
|
+
assert_raise(RuntimeError) do
|
138
|
+
s.to_s
|
139
|
+
end
|
140
|
+
end
|
141
|
+
|
142
|
+
def test_to_s_includes_keys
|
143
|
+
s = @t.prepare_to_send(:explain_sql => 0.1)
|
144
|
+
s.params[:fake_key] = 'a fake param'
|
145
|
+
assert(s.to_s.include?('fake_key'), "should include 'fake_key' but instead was (#{s.to_s})")
|
146
|
+
assert(s.to_s.include?('a fake param'), "should include 'a fake param' but instead was (#{s.to_s})")
|
147
|
+
end
|
148
|
+
|
149
|
+
def test_find_segment
|
150
|
+
s = @t.prepare_to_send(:explain_sql => 0.1)
|
151
|
+
fake_segment = mock('segment')
|
152
|
+
fake_segment.expects(:find_segment).with(1).returns('a segment')
|
153
|
+
s.instance_eval do
|
154
|
+
@root_segment = fake_segment
|
155
|
+
end
|
156
|
+
|
157
|
+
assert_equal('a segment', s.find_segment(1))
|
158
|
+
end
|
159
|
+
|
160
|
+
def test_timestamp
|
161
|
+
s = @t.prepare_to_send(:explain_sql => 0.1)
|
162
|
+
assert(s.timestamp.instance_of?(Float), "s.timestamp should be a Float, but is #{s.timestamp.class.inspect}")
|
163
|
+
end
|
164
|
+
|
165
|
+
def test_count_segments
|
166
|
+
transaction = run_sample_trace_on(NewRelic::Agent::TransactionSampler.new) do |sampler|
|
167
|
+
sampler.notice_push_scope "level0"
|
168
|
+
sampler.notice_push_scope "level-1"
|
169
|
+
sampler.notice_push_scope "level-2"
|
170
|
+
sampler.notice_sql(::SQL_STATEMENT, nil, 0)
|
171
|
+
sampler.notice_pop_scope "level-2"
|
172
|
+
sampler.notice_pop_scope "level-1"
|
173
|
+
sampler.notice_pop_scope "level0"
|
174
|
+
end
|
175
|
+
assert_equal 6, transaction.count_segments
|
176
|
+
end
|
177
|
+
end
|
@@ -0,0 +1,89 @@
|
|
1
|
+
require File.expand_path(File.join(File.dirname(__FILE__),'..', 'test_helper'))
|
2
|
+
class NewRelic::VersionNumberTest < Test::Unit::TestCase
|
3
|
+
|
4
|
+
def test_comparison__first
|
5
|
+
versions = %w[1.0.0 0.1.0 0.0.1 10.0.1 1.10.0].map {|s| NewRelic::VersionNumber.new s }
|
6
|
+
assert_equal %w[0.0.1 0.1.0 1.0.0 1.10.0 10.0.1], versions.sort.map(&:to_s)
|
7
|
+
v0 = NewRelic::VersionNumber.new '1.2.3'
|
8
|
+
v1 = NewRelic::VersionNumber.new '1.2.2'
|
9
|
+
v3 = NewRelic::VersionNumber.new '1.2.2'
|
10
|
+
assert v0 > v1
|
11
|
+
assert v1 == v1
|
12
|
+
assert v1 == v3
|
13
|
+
end
|
14
|
+
def test_comparison__second
|
15
|
+
v0 = NewRelic::VersionNumber.new '1.2.0'
|
16
|
+
v1 = NewRelic::VersionNumber.new '2.2.2'
|
17
|
+
v3 = NewRelic::VersionNumber.new '1.1.2'
|
18
|
+
assert v0 < v1
|
19
|
+
assert v1 > v3
|
20
|
+
assert v3 < v0
|
21
|
+
end
|
22
|
+
def test_bug
|
23
|
+
v0 = NewRelic::VersionNumber.new '2.8.999'
|
24
|
+
v1 = NewRelic::VersionNumber.new '2.9.10'
|
25
|
+
assert v1 > v0
|
26
|
+
assert v0 <= v1
|
27
|
+
end
|
28
|
+
def test_long_version
|
29
|
+
v0 = NewRelic::VersionNumber.new '1.2.3.4'
|
30
|
+
v1 = NewRelic::VersionNumber.new '1.2.3.3'
|
31
|
+
v3 = NewRelic::VersionNumber.new '1.3'
|
32
|
+
assert v0 > v1
|
33
|
+
assert v0 < '1.2.3.5'
|
34
|
+
assert ! (v0 < '1.2.3.4')
|
35
|
+
assert v3 > v0
|
36
|
+
end
|
37
|
+
def test_sort
|
38
|
+
values = %w[1.1.1
|
39
|
+
1.1.99
|
40
|
+
1.1.999
|
41
|
+
2.0.6
|
42
|
+
2.6.5
|
43
|
+
2.7
|
44
|
+
2.7.1
|
45
|
+
2.7.2
|
46
|
+
2.7.2.0
|
47
|
+
3
|
48
|
+
999]
|
49
|
+
assert_equal values, values.map{|v| NewRelic::VersionNumber.new v}.sort.map(&:to_s)
|
50
|
+
end
|
51
|
+
def test_prerelease
|
52
|
+
v0 = NewRelic::VersionNumber.new '1.2.0.beta'
|
53
|
+
assert_equal [1,2,0,'beta'], v0.parts
|
54
|
+
assert v0 > '1.1.9.0'
|
55
|
+
assert v0 > '1.1.9.alpha'
|
56
|
+
assert v0 > '1.2.0.alpha'
|
57
|
+
assert v0 == '1.2.0.beta'
|
58
|
+
assert v0 < '1.2.1'
|
59
|
+
assert v0 < '1.2.0'
|
60
|
+
assert v0 < '1.2.0.c'
|
61
|
+
assert v0 < '1.2.0.0'
|
62
|
+
|
63
|
+
end
|
64
|
+
def test_compare_string
|
65
|
+
v0 = NewRelic::VersionNumber.new '1.2.0'
|
66
|
+
v1 = NewRelic::VersionNumber.new '2.2.2'
|
67
|
+
v3 = NewRelic::VersionNumber.new '1.1.2'
|
68
|
+
assert v0 < '2.2.2'
|
69
|
+
assert v1 > '1.1.2'
|
70
|
+
assert v3 < '1.2.0'
|
71
|
+
assert v0 == '1.2.0'
|
72
|
+
end
|
73
|
+
def test_4_numbers
|
74
|
+
v0 = NewRelic::VersionNumber.new '1.2.0'
|
75
|
+
v1 = NewRelic::VersionNumber.new '1.2.0.1'
|
76
|
+
v2 = NewRelic::VersionNumber.new '1.2.1.0'
|
77
|
+
v3 = NewRelic::VersionNumber.new '1.2.1.1'
|
78
|
+
assert v0 < v1
|
79
|
+
assert v1 < v2
|
80
|
+
assert v2 < v3
|
81
|
+
assert v0 < v3
|
82
|
+
assert v0 < '1.2.0.1'
|
83
|
+
assert v0 > '1.1.0.1'
|
84
|
+
end
|
85
|
+
def test_string
|
86
|
+
assert_equal '1.2.0', NewRelic::VersionNumber.new('1.2.0').to_s
|
87
|
+
assert_equal '1.2', NewRelic::VersionNumber.new('1.2').to_s
|
88
|
+
end
|
89
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
#!/bin/bash
|
2
|
+
|
3
|
+
# print commands in this script as they're invoked
|
4
|
+
set -x
|
5
|
+
# fail if any command fails
|
6
|
+
set -e
|
7
|
+
|
8
|
+
if [ "x$BUILD_NUMBER" == "x" ]; then
|
9
|
+
echo '$BUILD_NUMBER is undefined'
|
10
|
+
echo 'setting $BUILD_NUMBER to alpha'
|
11
|
+
BUILD_NUMBER=alpha
|
12
|
+
fi
|
13
|
+
|
14
|
+
SHA1=`git log --pretty=format:'%h' -n 1`
|
15
|
+
echo "building gem for commit $SHA"
|
16
|
+
|
17
|
+
if [[ `gem list jeweler | grep [j]eweler | wc -l` -eq 1 ]]; then
|
18
|
+
echo "detected jeweler. skipping install"
|
19
|
+
else
|
20
|
+
gem install jeweler --no-ri --no-rdoc
|
21
|
+
fi
|
22
|
+
|
23
|
+
# setup a gems directory as a work area for artifacts
|
24
|
+
rm -rf gems/
|
25
|
+
mkdir gems
|
26
|
+
|
27
|
+
# an identifier including the hudson build number and the git sha1
|
28
|
+
|
29
|
+
# FIXME: don't include the $SHA1 since some of our builds systems are confused
|
30
|
+
# by this.
|
31
|
+
BUILD_ID=$BUILD_NUMBER #.$SHA1
|
32
|
+
|
33
|
+
# rewrite the version file, setting the patch identifier to include the
|
34
|
+
# BUILD_ID
|
35
|
+
perl -p -i -e "s#BUILD *= *.*\$#BUILD = '$BUILD_ID'#" lib/new_relic/version.rb
|
36
|
+
|
37
|
+
# generate the gemspec
|
38
|
+
rake gemspec
|
39
|
+
|
40
|
+
# build the gem
|
41
|
+
gem build *.gemspec
|
42
|
+
|
43
|
+
# move artifacts to the gems directory
|
44
|
+
cp *.gemspec gems/
|
45
|
+
mv *.gem gems/
|
46
|
+
|
47
|
+
cd gems
|
48
|
+
|
49
|
+
# create a tarfile including the gem and the gemspec
|
50
|
+
gem_version=`ls *.gem | sed 's/\.gem$//' | sed 's/newrelic_rpm-//'`
|
51
|
+
tar czvf newrelic_rpm_agent-${gem_version}.tar.gz *
|
data/test/script/ci.sh
ADDED
@@ -0,0 +1,94 @@
|
|
1
|
+
#!/bin/bash
|
2
|
+
|
3
|
+
# Script to run test suites in CI or in development mode. This script handles
|
4
|
+
# checking out test dependencies (currently rpm_test_app and it's dependencies)
|
5
|
+
# and executing them.
|
6
|
+
#
|
7
|
+
# It relies on 3 environment variables:
|
8
|
+
#
|
9
|
+
# RUBY - The rvm ruby you want to use (e.g. 1.8.7, ree, jruby)
|
10
|
+
#
|
11
|
+
# BRANCH - The rpm_test_app branch you want to use (e.g. rails20, rails31)
|
12
|
+
#
|
13
|
+
# RPM_TEST_APP_CLONE_URL - where to clone the test app from (e.g.
|
14
|
+
# git://github.com/newrelic/rpm_test_app.git, /path/in/my/filesystem)
|
15
|
+
#
|
16
|
+
# Example usage:
|
17
|
+
# RPM_TEST_APP_CLONE_URL=git://github.com/newrelic/rpm_test_app.git \
|
18
|
+
# RUBY=ree BRANCH=rails20 test/script/ci.sh
|
19
|
+
#
|
20
|
+
# RPM_TEST_APP_CLONE_URL=git://github.com/newrelic/rpm_test_app.git \
|
21
|
+
# RUBY=ree BRANCH=rails20 test/script/ci.sh
|
22
|
+
#
|
23
|
+
# RPM_TEST_APP_CLONE_URL=~/dev/rpm_test_app/ \
|
24
|
+
# RUBY=jruby BRANCH=rails22 test/script/ci.sh
|
25
|
+
|
26
|
+
echo "Executing $0"
|
27
|
+
echo "Running in $(pwd)"
|
28
|
+
|
29
|
+
|
30
|
+
|
31
|
+
# print commands in this script as they're invoked
|
32
|
+
# set -x
|
33
|
+
# fail if any command fails
|
34
|
+
set -e
|
35
|
+
|
36
|
+
# check for require environment variables
|
37
|
+
if [ "x$RUBY" == "x" ]; then
|
38
|
+
echo '$RUBY is undefined'
|
39
|
+
exit 1
|
40
|
+
fi
|
41
|
+
if [ "x$BRANCH" == "x" ]; then
|
42
|
+
echo '$BRANCH is undefined'
|
43
|
+
exit 1
|
44
|
+
fi
|
45
|
+
if [ "x$RPM_TEST_APP_CLONE_URL" == "x" ]; then
|
46
|
+
echo '$RPM_TEST_APP_CLONE_URL is undefined'
|
47
|
+
exit 1
|
48
|
+
fi
|
49
|
+
|
50
|
+
. "$HOME/.rvm/scripts/rvm"
|
51
|
+
rvm use $RUBY || rvm install $RUBY
|
52
|
+
echo `which ruby`
|
53
|
+
|
54
|
+
# make sure that we're in the project root
|
55
|
+
script_dirname=`dirname $0`
|
56
|
+
cd "$script_dirname/../../"
|
57
|
+
pwd
|
58
|
+
|
59
|
+
rm -rf tmp
|
60
|
+
mkdir -p tmp
|
61
|
+
cd tmp
|
62
|
+
git clone --depth=1 $RPM_TEST_APP_CLONE_URL rpm_test_app
|
63
|
+
cd rpm_test_app
|
64
|
+
git checkout -t origin/$BRANCH || git checkout $BRANCH
|
65
|
+
mkdir -p log
|
66
|
+
mkdir -p tmp
|
67
|
+
if [ "x$BRANCH" == "xrails20" ]; then
|
68
|
+
printf "\e[0;31;49mWarning:\e[0m "
|
69
|
+
echo "Testing against the rails20 branch requires your changes to be committed. Uncommitted changes will not be used."
|
70
|
+
mkdir -p vendor/plugins
|
71
|
+
git clone ../.. vendor/plugins/newrelic_rpm
|
72
|
+
else
|
73
|
+
perl -p -i'.bak' -e 's#gem .newrelic_rpm.*$#gem "newrelic_rpm", :path => "\.\.\/\.\.\/"#' Gemfile
|
74
|
+
fi
|
75
|
+
|
76
|
+
rvm --force gemset delete ruby_agent_tests_$BRANCH
|
77
|
+
rvm gemset create ruby_agent_tests_$BRANCH
|
78
|
+
rvm gemset use ruby_agent_tests_$BRANCH
|
79
|
+
|
80
|
+
if [ "x$RUBY" == "x1.8.6" ]; then
|
81
|
+
# Bundler 1.1 dropped support for ruby 1.8.6
|
82
|
+
gem install bundler -v'~>1.0.0' --no-rdoc --no-ri
|
83
|
+
else
|
84
|
+
gem install bundler --no-rdoc --no-ri
|
85
|
+
fi
|
86
|
+
|
87
|
+
|
88
|
+
export RAILS_ENV=test
|
89
|
+
bundle
|
90
|
+
bundle exec rake --trace db:create:all ci:setup:testunit test:newrelic
|
91
|
+
|
92
|
+
|
93
|
+
|
94
|
+
|