newrelic_rpm 3.6.5.130 → 3.6.6.147
Sign up to get free protection for your applications and to get access to all the features.
- data.tar.gz.sig +0 -0
- data/CHANGELOG +27 -3
- data/Gemfile +1 -14
- data/Rakefile +15 -5
- data/config.dot +1 -1
- data/lib/new_relic/agent/agent.rb +15 -0
- data/lib/new_relic/agent/agent_logger.rb +19 -14
- data/lib/new_relic/agent/configuration/defaults.rb +4 -3
- data/lib/new_relic/agent/configuration/environment_source.rb +6 -4
- data/lib/new_relic/agent/configuration/manager.rb +7 -2
- data/lib/new_relic/agent/configuration/mask_defaults.rb +1 -2
- data/lib/new_relic/agent/cross_app_monitor.rb +5 -4
- data/lib/new_relic/agent/cross_app_tracing.rb +0 -1
- data/lib/new_relic/agent/error_collector.rb +30 -1
- data/lib/new_relic/agent/http_clients/curb_wrappers.rb +67 -0
- data/lib/new_relic/agent/http_clients/httpclient_wrappers.rb +59 -0
- data/lib/new_relic/agent/instrumentation/action_controller_subscriber.rb +12 -0
- data/lib/new_relic/agent/instrumentation/active_merchant.rb +3 -3
- data/lib/new_relic/agent/instrumentation/acts_as_solr.rb +3 -3
- data/lib/new_relic/agent/instrumentation/authlogic.rb +3 -3
- data/lib/new_relic/agent/instrumentation/curb.rb +179 -0
- data/lib/new_relic/agent/instrumentation/data_mapper.rb +3 -3
- data/lib/new_relic/agent/instrumentation/delayed_job_instrumentation.rb +35 -26
- data/lib/new_relic/agent/instrumentation/httpclient.rb +46 -0
- data/lib/new_relic/agent/instrumentation/merb/controller.rb +3 -3
- data/lib/new_relic/agent/instrumentation/puma.rb +23 -0
- data/lib/new_relic/agent/instrumentation/rack.rb +40 -0
- data/lib/new_relic/agent/instrumentation/rails/action_web_service.rb +4 -4
- data/lib/new_relic/agent/instrumentation/rails/errors.rb +0 -1
- data/lib/new_relic/agent/instrumentation/sequel.rb +0 -1
- data/lib/new_relic/agent/instrumentation/sunspot.rb +1 -1
- data/lib/new_relic/agent/internal_agent_error.rb +18 -0
- data/lib/new_relic/agent/new_relic_service.rb +2 -8
- data/lib/new_relic/agent/request_sampler.rb +4 -6
- data/lib/new_relic/agent/samplers/cpu_sampler.rb +0 -1
- data/lib/new_relic/agent/stats.rb +9 -0
- data/lib/new_relic/agent/stats_engine/stats_hash.rb +44 -6
- data/lib/new_relic/agent/system_info.rb +1 -1
- data/lib/new_relic/agent/thread_profiler.rb +6 -6
- data/lib/new_relic/agent/transaction.rb +1 -1
- data/lib/new_relic/agent/transaction_info.rb +0 -1
- data/lib/new_relic/agent/transaction_sample_builder.rb +6 -5
- data/lib/new_relic/agent/transaction_sampler.rb +1 -1
- data/lib/new_relic/commands/deployments.rb +6 -0
- data/lib/new_relic/commands/install.rb +2 -2
- data/lib/new_relic/control/frameworks/rails.rb +1 -2
- data/lib/new_relic/control/instrumentation.rb +2 -2
- data/lib/new_relic/control/server_methods.rb +1 -2
- data/lib/new_relic/delayed_job_injection.rb +0 -40
- data/lib/new_relic/helper.rb +0 -1
- data/lib/new_relic/latest_changes.rb +1 -1
- data/lib/new_relic/local_environment.rb +9 -4
- data/lib/new_relic/metric_spec.rb +19 -3
- data/lib/new_relic/noticed_error.rb +2 -1
- data/lib/new_relic/rack/agent_hooks.rb +0 -1
- data/lib/new_relic/rack/developer_mode.rb +1 -1
- data/lib/new_relic/rack/error_collector.rb +42 -21
- data/lib/new_relic/recipes.rb +0 -1
- data/lib/new_relic/transaction_analysis.rb +0 -1
- data/lib/new_relic/transaction_sample/segment.rb +4 -4
- data/lib/new_relic/version.rb +1 -1
- data/lib/sequel/extensions/newrelic_instrumentation.rb +6 -7
- data/lib/sequel/plugins/newrelic_instrumentation.rb +0 -1
- data/lib/tasks/install.rake +2 -2
- data/newrelic_rpm.gemspec +11 -1
- data/test/active_record_fixtures.rb +2 -2
- data/test/agent_helper.rb +46 -3
- data/test/config/newrelic.yml +2 -2
- data/test/multiverse/.gitignore +2 -0
- data/test/multiverse/lib/multiverse/envfile.rb +6 -9
- data/test/multiverse/lib/multiverse/environment.rb +0 -1
- data/test/multiverse/lib/multiverse/output_collector.rb +43 -11
- data/test/multiverse/lib/multiverse/runner.rb +37 -5
- data/test/multiverse/lib/multiverse/suite.rb +149 -67
- data/test/multiverse/script/run_one +4 -2
- data/test/multiverse/script/runner +1 -5
- data/test/multiverse/suites/active_record/Envfile +3 -2
- data/test/multiverse/suites/active_record/ar_method_aliasing.rb +13 -12
- data/test/multiverse/suites/active_record/config/newrelic.yml +0 -3
- data/test/multiverse/suites/agent_only/audit_log_test.rb +30 -34
- data/test/multiverse/suites/agent_only/before_suite.rb +7 -0
- data/test/multiverse/suites/agent_only/config/newrelic.yml +1 -7
- data/test/multiverse/suites/agent_only/cross_application_tracing_test.rb +12 -20
- data/test/multiverse/suites/agent_only/http_response_code_test.rb +16 -34
- data/test/multiverse/suites/agent_only/key_transactions_test.rb +18 -28
- data/test/multiverse/suites/agent_only/logging_test.rb +25 -49
- data/test/multiverse/suites/agent_only/marshaling_test.rb +30 -38
- data/test/multiverse/suites/agent_only/pipe_manager_test.rb +12 -6
- data/test/multiverse/suites/agent_only/rename_rule_test.rb +30 -38
- data/test/multiverse/suites/agent_only/rum_instrumentation_test.rb +16 -18
- data/test/multiverse/suites/agent_only/service_timeout_test.rb +6 -7
- data/test/multiverse/suites/agent_only/set_transaction_name_test.rb +26 -32
- data/test/multiverse/suites/agent_only/ssl_test.rb +10 -14
- data/test/multiverse/suites/agent_only/start_up_test.rb +1 -1
- data/test/multiverse/suites/agent_only/testing_app.rb +2 -0
- data/test/multiverse/suites/agent_only/thread_profiling_test.rb +23 -24
- data/test/multiverse/suites/config_file_loading/Envfile +6 -2
- data/test/multiverse/suites/config_file_loading/config_file_loading_test.rb +8 -4
- data/test/multiverse/suites/curb/Envfile +19 -0
- data/test/multiverse/suites/curb/config/newrelic.yml +19 -0
- data/test/multiverse/suites/curb/curb_test.rb +195 -0
- data/test/multiverse/suites/datamapper/Envfile +2 -0
- data/test/multiverse/suites/datamapper/config/newrelic.yml +0 -2
- data/test/multiverse/suites/datamapper/datamapper_test.rb +6 -10
- data/test/multiverse/suites/deferred_instrumentation/Envfile +19 -0
- data/test/multiverse/suites/deferred_instrumentation/config/newrelic.yml +22 -0
- data/test/multiverse/suites/deferred_instrumentation/sinatra_test.rb +103 -0
- data/test/multiverse/suites/excon/config/newrelic.yml +0 -2
- data/test/multiverse/suites/excon/excon_test.rb +3 -3
- data/test/multiverse/suites/httpclient/Envfile +15 -0
- data/test/multiverse/suites/httpclient/config/newrelic.yml +19 -0
- data/test/multiverse/suites/httpclient/httpclient_test.rb +70 -0
- data/test/multiverse/suites/net_http/config/newrelic.yml +0 -2
- data/test/multiverse/suites/net_http/net_http_test.rb +9 -4
- data/test/multiverse/suites/padrino/Envfile +2 -0
- data/test/multiverse/suites/padrino/config/newrelic.yml +0 -3
- data/test/multiverse/suites/padrino/padrino_test.rb +5 -4
- data/test/multiverse/suites/rails/Envfile +3 -0
- data/test/multiverse/suites/rails/app.rb +1 -0
- data/test/multiverse/suites/rails/bad_instrumentation_test.rb +31 -0
- data/test/multiverse/suites/rails/config/newrelic.yml +2 -3
- data/test/multiverse/suites/rails/error_tracing_test.rb +32 -41
- data/test/multiverse/suites/rails/gc_instrumentation_test.rb +6 -16
- data/test/multiverse/suites/rails/queue_time_test.rb +4 -20
- data/test/multiverse/suites/rails/request_statistics_test.rb +7 -32
- data/test/multiverse/suites/rails/view_instrumentation_test.rb +6 -10
- data/test/multiverse/suites/resque/config/newrelic.yml +1 -3
- data/test/multiverse/suites/resque/instrumentation_test.rb +10 -7
- data/test/multiverse/suites/sequel/Envfile +8 -0
- data/test/multiverse/suites/sequel/config/newrelic.yml +0 -3
- data/test/multiverse/suites/sequel/sequel_test.rb +1 -2
- data/test/multiverse/suites/sidekiq/Envfile +0 -12
- data/test/multiverse/suites/sidekiq/config/newrelic.yml +1 -3
- data/test/multiverse/suites/sidekiq/sidekiq_instrumentation_test.rb +44 -100
- data/test/multiverse/suites/sinatra/config/newrelic.yml +0 -3
- data/test/multiverse/suites/sinatra/ignoring_test.rb +8 -5
- data/test/multiverse/suites/sinatra/sinatra_classic_test.rb +8 -1
- data/test/multiverse/suites/sinatra/sinatra_error_tracing_test.rb +9 -12
- data/test/multiverse/suites/sinatra/sinatra_metric_explosion_test.rb +9 -8
- data/test/multiverse/suites/sinatra/sinatra_modular_test.rb +1 -1
- data/test/multiverse/suites/sinatra/sinatra_routes_test.rb +6 -5
- data/test/multiverse/suites/sinatra/sinatra_test_cases.rb +10 -13
- data/test/multiverse/suites/typhoeus/config/newrelic.yml +0 -2
- data/test/multiverse/suites/typhoeus/typhoeus_test.rb +7 -4
- data/test/multiverse/test/suite_examples/one/a/a_test.rb +0 -1
- data/test/multiverse/test/suite_examples/one/a/config/newrelic.yml +0 -1
- data/test/multiverse/test/suite_examples/one/b/b_test.rb +0 -1
- data/test/multiverse/test/suite_examples/one/b/config/newrelic.yml +0 -1
- data/test/new_relic/agent/agent/connect_test.rb +1 -1
- data/test/new_relic/agent/agent/start_test.rb +0 -1
- data/test/new_relic/agent/agent/start_worker_thread_test.rb +0 -1
- data/test/new_relic/agent/agent_logger_test.rb +37 -3
- data/test/new_relic/agent/agent_test.rb +23 -1
- data/test/new_relic/agent/browser_monitoring_test.rb +0 -1
- data/test/new_relic/agent/busy_calculator_test.rb +2 -2
- data/test/new_relic/agent/configuration/environment_source_test.rb +22 -0
- data/test/new_relic/agent/error_collector/notice_error_test.rb +1 -1
- data/test/new_relic/agent/error_collector_test.rb +95 -13
- data/test/new_relic/agent/event_listener_test.rb +0 -1
- data/test/new_relic/agent/instrumentation/active_record_instrumentation_test.rb +23 -0
- data/test/new_relic/agent/instrumentation/active_record_subscriber_test.rb +4 -2
- data/test/new_relic/agent/instrumentation/instrumentation_test.rb +0 -1
- data/test/new_relic/agent/instrumentation/queue_time_test.rb +16 -11
- data/test/new_relic/agent/instrumentation/rack_test.rb +0 -1
- data/test/new_relic/agent/memcache_instrumentation_test.rb +7 -7
- data/test/{multiverse/suites/agent_only/test_trace_method_with_punctuation.rb → new_relic/agent/method_interrobang_test.rb} +3 -5
- data/test/new_relic/agent/method_tracer/instance_methods/trace_execution_scoped_test.rb +1 -2
- data/test/{multiverse/suites/agent_only → new_relic/agent}/method_visibility_test.rb +17 -29
- data/test/new_relic/agent/new_relic_service_test.rb +1 -1
- data/test/new_relic/agent/pipe_service_test.rb +1 -1
- data/test/new_relic/agent/request_sampler_test.rb +10 -10
- data/test/new_relic/agent/rpm_agent_test.rb +1 -2
- data/test/new_relic/agent/stats_hash_test.rb +83 -5
- data/test/new_relic/agent/stats_test.rb +0 -1
- data/test/new_relic/agent/thread_profiler_test.rb +7 -7
- data/test/new_relic/agent/threaded_test.rb +1 -2
- data/test/new_relic/agent/transaction/pop_test.rb +0 -1
- data/test/{multiverse/suites/agent_only/test_trace_transaction_with_punctuation.rb → new_relic/agent/transaction_interrobang_test.rb} +2 -4
- data/test/new_relic/agent/transaction_sample_builder_test.rb +13 -0
- data/test/new_relic/agent/transaction_test.rb +7 -5
- data/test/new_relic/agent/worker_loop_test.rb +0 -1
- data/test/new_relic/agent_test.rb +0 -27
- data/test/new_relic/collection_helper_test.rb +17 -17
- data/test/new_relic/control/class_methods_test.rb +1 -1
- data/test/new_relic/control_test.rb +6 -6
- data/test/new_relic/dependency_detection_test.rb +28 -0
- data/test/new_relic/evil_server.rb +0 -1
- data/test/new_relic/fake_collector.rb +20 -2
- data/test/new_relic/fake_server.rb +0 -12
- data/test/new_relic/http_client_test_cases.rb +20 -24
- data/test/new_relic/metric_spec_test.rb +18 -0
- data/test/new_relic/multiverse_helpers.rb +164 -0
- data/test/new_relic/rack/agent_hooks_test.rb +0 -1
- data/test/new_relic/rack/all_test.rb +0 -1
- data/test/new_relic/rack/deferred_instrumentation_test.rb +35 -0
- data/test/new_relic/rack/developer_mode_helper_test.rb +8 -9
- data/test/new_relic/rack/developer_mode_test.rb +0 -2
- data/test/new_relic/rack/error_collector_test.rb +52 -8
- data/test/new_relic/transaction_sample/composite_segment_test.rb +0 -1
- data/test/new_relic/transaction_sample/fake_segment_test.rb +0 -1
- data/test/new_relic/transaction_sample/segment_test.rb +0 -1
- data/test/new_relic/transaction_sample/summary_segment_test.rb +0 -1
- data/test/performance/README.md +162 -0
- data/test/performance/lib/performance.rb +28 -0
- data/test/performance/lib/performance/console_reporter.rb +51 -0
- data/test/performance/lib/performance/hako_client.rb +31 -0
- data/test/performance/lib/performance/hako_reporter.rb +26 -0
- data/test/performance/lib/performance/instrumentation/cpu_usage.rb +26 -0
- data/test/performance/lib/performance/instrumentation/gc_stats.rb +53 -0
- data/test/performance/lib/performance/instrumentation/perf_tools.rb +30 -0
- data/test/performance/lib/performance/instrumentor.rb +110 -0
- data/test/performance/lib/performance/json_reporter.rb +15 -0
- data/test/performance/lib/performance/result.rb +80 -0
- data/test/performance/lib/performance/runner.rb +207 -0
- data/test/performance/lib/performance/test_case.rb +65 -0
- data/test/performance/lib/performance/timer.rb +38 -0
- data/test/performance/script/mega-runner +37 -0
- data/test/performance/script/runner +81 -0
- data/test/performance/suites/startup.rb +12 -0
- data/test/performance/suites/transaction_tracing.rb +66 -0
- data/test/script/ci_agent-tests_runner.sh +4 -4
- data/test/script/ci_multiverse_runner.sh +3 -3
- data/test/test_helper.rb +0 -11
- data/ui/helpers/developer_mode_helper.rb +1 -1
- data/ui/views/layouts/newrelic_default.rhtml +1 -1
- data/ui/views/newrelic/_segment.rhtml +2 -2
- data/ui/views/newrelic/_segment_limit_message.rhtml +1 -1
- data/ui/views/newrelic/_show_sample_detail.rhtml +1 -1
- data/ui/views/newrelic/_show_sample_sql.rhtml +4 -4
- data/ui/views/newrelic/_stack_trace.rhtml +2 -2
- data/ui/views/newrelic/file/javascript/transaction_sample.js +3 -3
- data/ui/views/newrelic/file/stylesheets/style.css +13 -13
- data/vendor/gems/dependency_detection-0.0.1.build/lib/dependency_detection.rb +18 -4
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/metric_parser.rb +0 -1
- metadata +186 -17
- metadata.gz.sig +0 -0
- data/test/multiverse/suites/active_record/encoding_test.rb +0 -30
- data/test/multiverse/suites/agent_only/no_dns_resolv.rb +0 -21
- data/test/multiverse/suites/sidekiq/app.rb +0 -25
- data/test/new_relic/delayed_job_injection_test.rb +0 -25
@@ -1,3 +1,5 @@
|
|
1
|
-
#!/bin/
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'fileutils'
|
3
|
+
require File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib', 'multiverse', 'environment'))
|
2
4
|
|
3
|
-
|
5
|
+
Multiverse::Runner.run_one ARGV[0]
|
@@ -1,9 +1,5 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
require 'fileutils'
|
3
|
-
require '
|
4
|
-
|
5
|
-
module Multiverse
|
6
|
-
require File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib', 'multiverse', 'environment'))
|
7
|
-
end
|
3
|
+
require File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib', 'multiverse', 'environment'))
|
8
4
|
|
9
5
|
Multiverse::Runner.run ARGV[0].to_s
|
@@ -1,12 +1,13 @@
|
|
1
1
|
gemfile <<-RB
|
2
|
+
gem 'rack'
|
2
3
|
if RUBY_VERSION == '1.8.6'
|
3
4
|
gem 'activerecord', '2.3.14'
|
4
5
|
elsif RUBY_PLATFORM == 'java'
|
5
6
|
gem 'activerecord-jdbcsqlite3-adapter', '1.2.2.1'
|
6
7
|
gem 'jdbc-sqlite3', '3.7.2'
|
7
|
-
gem 'activerecord'
|
8
|
+
gem 'activerecord', '~> 3.2.0'
|
8
9
|
else
|
9
|
-
gem 'activerecord'
|
10
|
+
gem 'activerecord', '~> 3.2.0'
|
10
11
|
gem 'sqlite3', '~> 1.3.5'
|
11
12
|
end
|
12
13
|
RB
|
@@ -2,18 +2,20 @@
|
|
2
2
|
# This file is distributed under New Relic's license terms.
|
3
3
|
# See https://github.com/newrelic/rpm/blob/master/LICENSE for complete details.
|
4
4
|
|
5
|
-
|
6
5
|
require 'rubygems'
|
7
6
|
|
8
7
|
require 'active_record'
|
9
|
-
require 'test/unit'
|
10
8
|
require 'newrelic_rpm'
|
11
9
|
require 'multiverse/color'
|
10
|
+
require 'multiverse_helpers'
|
11
|
+
require 'minitest/unit'
|
12
12
|
|
13
|
-
|
14
|
-
class InstrumentActiveRecordMethods < Test::Unit::TestCase
|
13
|
+
class InstrumentActiveRecordMethods < MiniTest::Unit::TestCase
|
15
14
|
extend Multiverse::Color
|
16
15
|
|
16
|
+
include MultiverseHelpers
|
17
|
+
setup_and_teardown_agent
|
18
|
+
|
17
19
|
if RUBY_VERSION >= '1.8.7'
|
18
20
|
if RUBY_PLATFORM == 'java'
|
19
21
|
require 'jdbc/sqlite3'
|
@@ -23,8 +25,8 @@ class InstrumentActiveRecordMethods < Test::Unit::TestCase
|
|
23
25
|
@@adapter = 'sqlite3'
|
24
26
|
end
|
25
27
|
|
26
|
-
class User < ActiveRecord::Base
|
27
|
-
include NewRelic::Agent::MethodTracer
|
28
|
+
class User < ActiveRecord::Base
|
29
|
+
include NewRelic::Agent::MethodTracer
|
28
30
|
has_many :aliases
|
29
31
|
|
30
32
|
add_method_tracer :save!
|
@@ -38,8 +40,8 @@ class InstrumentActiveRecordMethods < Test::Unit::TestCase
|
|
38
40
|
add_method_tracer :persisted?
|
39
41
|
add_method_tracer :destroyed?
|
40
42
|
end
|
41
|
-
|
42
|
-
def
|
43
|
+
|
44
|
+
def after_setup
|
43
45
|
puts "adapter : #{@@adapter}"
|
44
46
|
@db_connection = ActiveRecord::Base.establish_connection( :adapter => @@adapter, :database => "testdb.sqlite3")
|
45
47
|
ActiveRecord::Migration.class_eval do
|
@@ -55,7 +57,7 @@ class InstrumentActiveRecordMethods < Test::Unit::TestCase
|
|
55
57
|
end
|
56
58
|
end
|
57
59
|
|
58
|
-
def
|
60
|
+
def after_teardown
|
59
61
|
@db_connection = ActiveRecord::Base.establish_connection( :adapter => "sqlite3", :database => "testdb.sqlite3")
|
60
62
|
ActiveRecord::Migration.class_eval do
|
61
63
|
@connection = @db_connection
|
@@ -70,7 +72,7 @@ class InstrumentActiveRecordMethods < Test::Unit::TestCase
|
|
70
72
|
a_user.save!
|
71
73
|
assert User.connected?
|
72
74
|
assert a_user.persisted?
|
73
|
-
assert a_user.id == 1
|
75
|
+
assert a_user.id == 1
|
74
76
|
end
|
75
77
|
|
76
78
|
def test_alias_collection_query_method
|
@@ -78,7 +80,7 @@ class InstrumentActiveRecordMethods < Test::Unit::TestCase
|
|
78
80
|
a_user.save!
|
79
81
|
a_user = User.find(1)
|
80
82
|
assert User.connected?
|
81
|
-
assert a_user.id = 1
|
83
|
+
assert a_user.id = 1
|
82
84
|
|
83
85
|
an_alias = Alias.new :user_id => a_user.id, :aka => "the Blob"
|
84
86
|
assert an_alias.new_record?
|
@@ -95,4 +97,3 @@ class InstrumentActiveRecordMethods < Test::Unit::TestCase
|
|
95
97
|
puts yellow('SKIPPED! skipped until ruby 1.8.6 compatibilites ironed out')
|
96
98
|
end
|
97
99
|
end
|
98
|
-
|
@@ -11,12 +11,9 @@ development:
|
|
11
11
|
app_name: test
|
12
12
|
host: 127.0.0.1
|
13
13
|
api_host: 127.0.0.1
|
14
|
-
port: <%= 30_000 + ($$ % 10_000) %>
|
15
14
|
transaction_trace:
|
16
15
|
record_sql: obfuscated
|
17
16
|
enabled: true
|
18
17
|
stack_trace_threshold: 0.5
|
19
18
|
transaction_threshold: 1.0
|
20
19
|
capture_params: false
|
21
|
-
log_level: debug
|
22
|
-
log_file_path: agent.log
|
@@ -4,25 +4,17 @@
|
|
4
4
|
|
5
5
|
# RUBY-981 Audit Log
|
6
6
|
|
7
|
-
require 'test/unit'
|
8
7
|
require 'newrelic_rpm'
|
9
|
-
require '
|
8
|
+
require 'multiverse_helpers'
|
10
9
|
|
11
|
-
class AuditLogTest <
|
12
|
-
|
13
|
-
def setup
|
14
|
-
$collector ||= NewRelic::FakeCollector.new
|
15
|
-
$collector.reset
|
16
|
-
$collector.run
|
10
|
+
class AuditLogTest < MiniTest::Unit::TestCase
|
11
|
+
include MultiverseHelpers
|
17
12
|
|
13
|
+
def setup
|
18
14
|
@string_log = StringIO.new
|
19
15
|
NewRelic::Agent::AuditLogger.any_instance.stubs(:ensure_log_path).returns(@string_log)
|
20
16
|
end
|
21
17
|
|
22
|
-
def teardown
|
23
|
-
$collector.reset
|
24
|
-
end
|
25
|
-
|
26
18
|
def audit_log_contents
|
27
19
|
if @contents.nil?
|
28
20
|
@string_log.rewind
|
@@ -45,7 +37,7 @@ class AuditLogTest < Test::Unit::TestCase
|
|
45
37
|
# request bodies for the audit log, the transformation into strings is
|
46
38
|
# effectively one-way. This, combined with the fact that Hash traversal order
|
47
39
|
# is arbitrary in Ruby 1.8.x means that it's difficult to directly assert that
|
48
|
-
# some object graph made it into the audit log (due to different possible
|
40
|
+
# some object graph made it into the audit log (due to different possible
|
49
41
|
# orderings of the key/value pairs in Hashes that were embedded in the request
|
50
42
|
# body). So, this method traverses an object graph and only makes assertions
|
51
43
|
# about the terminal (non-Array-or-Hash) nodes therein.
|
@@ -68,34 +60,38 @@ class AuditLogTest < Test::Unit::TestCase
|
|
68
60
|
end
|
69
61
|
end
|
70
62
|
|
71
|
-
def run_agent_with_options(options)
|
72
|
-
NewRelic::Agent.manual_start(options)
|
73
|
-
yield NewRelic::Agent.agent if block_given?
|
74
|
-
NewRelic::Agent.shutdown
|
75
|
-
end
|
76
|
-
|
77
63
|
def test_logs_nothing_by_default
|
78
|
-
|
79
|
-
|
64
|
+
run_agent do
|
65
|
+
perform_actions
|
66
|
+
assert_equal('', audit_log_contents)
|
67
|
+
end
|
80
68
|
end
|
81
69
|
|
82
70
|
def test_logs_nothing_when_disabled
|
83
|
-
|
84
|
-
|
71
|
+
run_agent(:'audit_log.enabled' => false) do
|
72
|
+
perform_actions
|
73
|
+
assert_equal('', audit_log_contents)
|
74
|
+
end
|
85
75
|
end
|
86
76
|
|
87
77
|
def test_logs_request_bodies_human_readably_ish
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
agent.sql_sampler.notice_scope_empty('txn')
|
95
|
-
agent.send(:harvest_and_send_slowest_sql)
|
96
|
-
end
|
97
|
-
$collector.agent_data.each do |req|
|
98
|
-
assert_audit_log_contains_object(req.body, format)
|
78
|
+
run_agent(:'audit_log.enabled' => true) do
|
79
|
+
perform_actions
|
80
|
+
format = NewRelic::Agent::NewRelicService::JsonMarshaller.is_supported? ? :json : :pruby
|
81
|
+
$collector.agent_data.each do |req|
|
82
|
+
assert_audit_log_contains_object(req.body, format)
|
83
|
+
end
|
99
84
|
end
|
100
85
|
end
|
86
|
+
|
87
|
+
def perform_actions
|
88
|
+
reset_collector
|
89
|
+
|
90
|
+
NewRelic::Agent.instance.sql_sampler.notice_first_scope_push(nil)
|
91
|
+
NewRelic::Agent.instance.sql_sampler.notice_sql("select * from test",
|
92
|
+
"Database/test/select",
|
93
|
+
nil, 1.5)
|
94
|
+
NewRelic::Agent.instance.sql_sampler.notice_scope_empty('txn')
|
95
|
+
NewRelic::Agent.instance.send(:harvest_and_send_slowest_sql)
|
96
|
+
end
|
101
97
|
end
|
@@ -11,17 +11,11 @@ development:
|
|
11
11
|
app_name: test
|
12
12
|
host: 127.0.0.1
|
13
13
|
api_host: 127.0.0.1
|
14
|
-
|
15
|
-
port: <%= $collector.port %>
|
16
|
-
<% else %>
|
17
|
-
port: <%= 30_000 + ($$ % 10_000) %>
|
18
|
-
<% end %>
|
14
|
+
port: <%= $collector && $collector.port %>
|
19
15
|
transaction_tracer:
|
20
16
|
record_sql: obfuscated
|
21
17
|
enabled: true
|
22
18
|
stack_trace_threshold: 0.5
|
23
19
|
capture_params: false
|
24
|
-
log_level: debug
|
25
|
-
log_file_path: agent.log
|
26
20
|
browser_monitoring:
|
27
21
|
auto_instrument: true
|
@@ -5,34 +5,27 @@
|
|
5
5
|
require 'rack/test'
|
6
6
|
require 'fake_collector'
|
7
7
|
require './testing_app'
|
8
|
+
require 'multiverse_helpers'
|
8
9
|
|
9
|
-
class
|
10
|
+
class CrossApplicationTracingTest < MiniTest::Unit::TestCase
|
10
11
|
|
11
12
|
# Important because the hooks are global that we only wire one AgentHooks up
|
12
13
|
@@app = TestingApp.new
|
13
14
|
@@wrapper_app = NewRelic::Rack::AgentHooks.new(@@app)
|
14
15
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
:cross_process_id => "boo",
|
23
|
-
:encoding_key => "\0",
|
24
|
-
:trusted_account_ids => [1])
|
25
|
-
|
26
|
-
NewRelic::Agent.instance.events.notify(:finished_configuring)
|
16
|
+
include MultiverseHelpers
|
17
|
+
setup_and_teardown_agent(:cross_process_id => "boo",
|
18
|
+
:encoding_key => "\0",
|
19
|
+
:trusted_account_ids => [1]) \
|
20
|
+
do |collector|
|
21
|
+
collector.stub('connect', {"agent_run_id" => 666 })
|
22
|
+
end
|
27
23
|
|
24
|
+
def after_setup
|
28
25
|
@@app.reset_headers
|
29
26
|
@@app.response = "<html><head><title>W00t!</title></head><body><p>Hello World</p></body></html>"
|
30
27
|
end
|
31
28
|
|
32
|
-
def teardown
|
33
|
-
NewRelic::Agent.shutdown
|
34
|
-
end
|
35
|
-
|
36
29
|
include Rack::Test::Methods
|
37
30
|
|
38
31
|
def app
|
@@ -51,8 +44,7 @@ class CrossProcessTest < Test::Unit::TestCase
|
|
51
44
|
|
52
45
|
def test_cross_app_writes_out_information
|
53
46
|
get '/', nil, {'X-NewRelic-ID' => Base64.encode64('1#234')}
|
54
|
-
|
55
|
-
|
56
|
-
assert_equal 1, metric.call_count
|
47
|
+
refute_nil last_response.headers["X-NewRelic-App-Data"]
|
48
|
+
assert_metrics_recorded(['ClientApplication/1#234/all'])
|
57
49
|
end
|
58
50
|
end
|
@@ -4,54 +4,36 @@
|
|
4
4
|
|
5
5
|
# https://newrelic.atlassian.net/browse/RUBY-765
|
6
6
|
require 'fake_collector'
|
7
|
+
require 'multiverse_helpers'
|
7
8
|
|
8
|
-
class HttpResponseCodeTest <
|
9
|
-
|
10
|
-
$collector ||= NewRelic::FakeCollector.new
|
11
|
-
$collector.reset
|
12
|
-
$collector.run
|
13
|
-
NewRelic::Agent.manual_start(:send_data_on_exit => false, :port => $collector.port)
|
14
|
-
@agent = NewRelic::Agent.instance
|
15
|
-
end
|
9
|
+
class HttpResponseCodeTest < MiniTest::Unit::TestCase
|
10
|
+
include MultiverseHelpers
|
16
11
|
|
17
|
-
|
18
|
-
$collector.reset
|
19
|
-
NewRelic::Agent.shutdown
|
20
|
-
end
|
12
|
+
setup_and_teardown_agent
|
21
13
|
|
22
14
|
def test_request_entity_too_large
|
23
15
|
$collector.mock['metric_data'] = [413, {'exception' => {'error_type' => 'RuntimeError', 'message' => 'too much'}}]
|
24
16
|
|
25
|
-
|
26
|
-
|
27
|
-
assert_equal 1, @agent.stats_engine \
|
28
|
-
.get_stats_no_scope('Custom/too_big').call_count
|
17
|
+
NewRelic::Agent.increment_metric('Custom/too_big')
|
18
|
+
assert_metrics_recorded(['Custom/too_big'])
|
29
19
|
|
30
|
-
|
20
|
+
agent.send(:harvest_and_send_timeslice_data)
|
31
21
|
|
32
|
-
# make sure the data gets thrown away without crashing
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
# make sure we actually talked to the collector
|
37
|
-
assert_equal(1, $collector.agent_data.select{|x| x.action == 'metric_data'}.size)
|
22
|
+
# make sure the data gets thrown away after we called collector without crashing
|
23
|
+
assert_metrics_not_recorded(['Custom/too_big'])
|
24
|
+
assert_equal(1, $collector.calls_for('metric_data').size)
|
38
25
|
end
|
39
26
|
|
40
27
|
def test_unsupported_media_type
|
41
28
|
$collector.mock['metric_data'] = [415, {'exception' => {'error_type' => 'RuntimeError', 'message' => 'looks bad'}}]
|
42
29
|
|
43
|
-
|
44
|
-
|
45
|
-
assert_equal 1, @agent.stats_engine \
|
46
|
-
.get_stats_no_scope('Custom/too_big').call_count
|
47
|
-
|
48
|
-
@agent.send(:harvest_and_send_timeslice_data)
|
30
|
+
NewRelic::Agent.increment_metric('Custom/too_big')
|
31
|
+
assert_metrics_recorded(['Custom/too_big'])
|
49
32
|
|
50
|
-
|
51
|
-
assert_equal 0, @agent.stats_engine \
|
52
|
-
.get_stats_no_scope('Custom/too_big').call_count
|
33
|
+
agent.send(:harvest_and_send_timeslice_data)
|
53
34
|
|
54
|
-
# make sure
|
55
|
-
|
35
|
+
# make sure the data gets thrown away after we called collector without crashing
|
36
|
+
assert_metrics_not_recorded(['Custom/too_big'])
|
37
|
+
assert_equal(1, $collector.calls_for('metric_data').size)
|
56
38
|
end
|
57
39
|
end
|
@@ -3,8 +3,25 @@
|
|
3
3
|
# See https://github.com/newrelic/rpm/blob/master/LICENSE for complete details.
|
4
4
|
|
5
5
|
require File.join(File.dirname(__FILE__), '..', '..', '..', 'agent_helper')
|
6
|
+
require 'multiverse_helpers'
|
7
|
+
|
8
|
+
class KeyTransactionsTest < MiniTest::Unit::TestCase
|
9
|
+
|
10
|
+
include MultiverseHelpers
|
11
|
+
|
12
|
+
setup_and_teardown_agent do |collector|
|
13
|
+
key_txn_name = 'Controller/KeyTransactionsTest::TestWidget/key_txn'
|
14
|
+
collector.stub('connect',
|
15
|
+
{
|
16
|
+
'web_transactions_apdex' => { key_txn_name => 1 },
|
17
|
+
'apdex_t' => 10
|
18
|
+
})
|
19
|
+
end
|
20
|
+
|
21
|
+
def after_setup
|
22
|
+
freeze_time
|
23
|
+
end
|
6
24
|
|
7
|
-
class KeyTransactionsTest < Test::Unit::TestCase
|
8
25
|
class TestWidget
|
9
26
|
include ::NewRelic::Agent::Instrumentation::ControllerInstrumentation
|
10
27
|
|
@@ -19,28 +36,6 @@ class KeyTransactionsTest < Test::Unit::TestCase
|
|
19
36
|
add_transaction_tracer :other_txn
|
20
37
|
end
|
21
38
|
|
22
|
-
def setup
|
23
|
-
$collector ||= NewRelic::FakeCollector.new
|
24
|
-
$collector.reset
|
25
|
-
key_apdex_config = { 'Controller/KeyTransactionsTest::TestWidget/key_txn' => 1 }
|
26
|
-
$collector.mock['connect'] = [200, {'return_value' => {
|
27
|
-
"agent_run_id" => 666,
|
28
|
-
'web_transactions_apdex' => key_apdex_config,
|
29
|
-
'apdex_t' => 10
|
30
|
-
}}]
|
31
|
-
$collector.run
|
32
|
-
|
33
|
-
NewRelic::Agent.manual_start(:sync_startup => true,
|
34
|
-
:force_reconnect => true)
|
35
|
-
|
36
|
-
freeze_time
|
37
|
-
end
|
38
|
-
|
39
|
-
def teardown
|
40
|
-
NewRelic::Agent.shutdown
|
41
|
-
$collector.reset
|
42
|
-
end
|
43
|
-
|
44
39
|
SATISFYING = 0
|
45
40
|
TOLERATING = 1
|
46
41
|
FAILING = 2
|
@@ -75,9 +70,4 @@ class KeyTransactionsTest < Test::Unit::TestCase
|
|
75
70
|
traces[0].metric_name)
|
76
71
|
end
|
77
72
|
|
78
|
-
def stub_time_now
|
79
|
-
now = Time.now
|
80
|
-
Time.stubs(:now).returns(now)
|
81
|
-
return now
|
82
|
-
end
|
83
73
|
end
|