newrelic_rpm 3.6.2.96 → 3.6.3.103.beta
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +3 -0
- data/CHANGELOG +33 -1
- data/README.md +7 -7
- data/lib/new_relic/agent/agent.rb +51 -22
- data/lib/new_relic/agent/agent_logger.rb +22 -11
- data/lib/new_relic/agent/configuration/defaults.rb +6 -1
- data/lib/new_relic/agent/instrumentation/action_controller_subscriber.rb +1 -6
- data/lib/new_relic/agent/instrumentation/action_view_subscriber.rb +1 -1
- data/lib/new_relic/agent/instrumentation/active_record.rb +8 -48
- data/lib/new_relic/agent/instrumentation/active_record_helper.rb +9 -1
- data/lib/new_relic/agent/instrumentation/controller_instrumentation.rb +4 -3
- data/lib/new_relic/agent/instrumentation/data_mapper.rb +4 -4
- data/lib/new_relic/agent/instrumentation/metric_frame.rb +10 -8
- data/lib/new_relic/agent/instrumentation/padrino.rb +32 -0
- data/lib/new_relic/agent/instrumentation/sinatra/ignorer.rb +52 -0
- data/lib/new_relic/agent/instrumentation/sinatra/transaction_namer.rb +56 -0
- data/lib/new_relic/agent/instrumentation/sinatra.rb +113 -48
- data/lib/new_relic/agent/new_relic_service.rb +6 -0
- data/lib/new_relic/agent/pipe_channel_manager.rb +13 -8
- data/lib/new_relic/agent/request_sampler.rb +205 -0
- data/lib/new_relic/agent/sampler.rb +0 -1
- data/lib/new_relic/agent/stats_engine/samplers.rb +0 -1
- data/lib/new_relic/agent/stats_engine/transactions.rb +12 -16
- data/lib/new_relic/agent/transaction.rb +27 -4
- data/lib/new_relic/agent/transaction_sample_builder.rb +47 -6
- data/lib/new_relic/agent/transaction_sampler.rb +0 -5
- data/lib/new_relic/agent.rb +17 -0
- data/lib/new_relic/build.rb +2 -2
- data/lib/new_relic/coerce.rb +3 -1
- data/lib/new_relic/rack/agent_hooks.rb +17 -3
- data/lib/new_relic/rack/browser_monitoring.rb +8 -3
- data/lib/new_relic/rack/error_collector.rb +2 -0
- data/lib/new_relic/transaction_sample/segment.rb +0 -23
- data/lib/new_relic/transaction_sample.rb +0 -9
- data/lib/new_relic/version.rb +1 -1
- data/test/agent_helper.rb +204 -0
- data/test/config/newrelic.yml +0 -1
- data/test/config/test_control.rb +3 -1
- data/test/multiverse/suites/agent_only/key_transactions_test.rb +8 -5
- data/test/multiverse/suites/agent_only/logging_test.rb +1 -1
- data/test/multiverse/suites/agent_only/thread_profiling_test.rb +7 -8
- data/test/multiverse/suites/datamapper/Envfile +7 -0
- data/test/multiverse/suites/datamapper/datamapper_test.rb +105 -0
- data/test/multiverse/suites/padrino/Envfile +16 -0
- data/test/multiverse/suites/padrino/config/newrelic.yml +24 -0
- data/test/multiverse/suites/padrino/padrino_test.rb +54 -0
- data/test/multiverse/suites/rails/Envfile +5 -5
- data/test/multiverse/suites/rails/app.rb +1 -0
- data/test/multiverse/suites/rails/request_statistics_test.rb +118 -0
- data/test/multiverse/suites/sinatra/Envfile +8 -2
- data/test/multiverse/suites/sinatra/ignoring_test.rb +185 -0
- data/test/multiverse/suites/sinatra/sinatra_classic_test.rb +92 -0
- data/test/multiverse/suites/sinatra/sinatra_metric_explosion_test.rb +0 -3
- data/test/multiverse/suites/sinatra/sinatra_modular_test.rb +89 -0
- data/test/multiverse/suites/sinatra/sinatra_test_cases.rb +120 -0
- data/test/new_relic/agent/agent_logger_test.rb +149 -56
- data/test/new_relic/agent/agent_test.rb +23 -0
- data/test/new_relic/agent/agent_test_controller_test.rb +8 -1
- data/test/new_relic/agent/autostart_test.rb +10 -6
- data/test/new_relic/agent/instrumentation/action_controller_subscriber_test.rb +36 -31
- data/test/new_relic/agent/instrumentation/action_view_subscriber_test.rb +7 -0
- data/test/new_relic/agent/instrumentation/active_record_helper_test.rb +20 -4
- data/test/new_relic/agent/instrumentation/active_record_instrumentation_test.rb +20 -9
- data/test/new_relic/agent/instrumentation/active_record_subscriber_test.rb +23 -19
- data/test/new_relic/agent/instrumentation/sequel_test.rb +118 -79
- data/test/new_relic/agent/instrumentation/sinatra/transaction_namer_test.rb +55 -0
- data/test/new_relic/agent/instrumentation/sinatra_test.rb +60 -11
- data/test/new_relic/agent/method_tracer_test.rb +7 -4
- data/test/new_relic/agent/new_relic_service_test.rb +6 -0
- data/test/new_relic/agent/pipe_channel_manager_test.rb +6 -2
- data/test/new_relic/agent/request_sampler_test.rb +159 -0
- data/test/new_relic/agent/stats_engine/samplers_test.rb +1 -5
- data/test/new_relic/agent/stats_engine_test.rb +14 -0
- data/test/new_relic/agent/transaction_sample_builder_test.rb +43 -6
- data/test/new_relic/agent/transaction_sampler_test.rb +31 -1
- data/test/new_relic/agent/transaction_test.rb +29 -0
- data/test/new_relic/agent_test.rb +7 -0
- data/test/new_relic/coerce_test.rb +13 -0
- data/test/new_relic/fake_collector.rb +31 -1
- data/test/new_relic/metric_spec_test.rb +14 -10
- data/test/new_relic/rack/agent_hooks_test.rb +9 -2
- data/test/new_relic/rack/browser_monitoring_test.rb +16 -7
- data/test/new_relic/rack/developer_mode_test.rb +7 -0
- data/test/new_relic/rack/error_collector_test.rb +10 -6
- data/test/new_relic/transaction_sample/segment_test.rb +0 -61
- data/test/new_relic/transaction_sample_subtest_test.rb +0 -19
- data/test/script/ci.sh +14 -0
- data/test/test_helper.rb +79 -203
- data.tar.gz.sig +0 -0
- metadata +50 -18
- metadata.gz.sig +0 -0
- data/test/multiverse/suites/datamapper/encoding_test.rb +0 -40
- data/test/multiverse/suites/sinatra/sinatra_test.rb +0 -143
metadata.gz.sig
CHANGED
Binary file
|
@@ -1,40 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
# This file is distributed under New Relic's license terms.
|
3
|
-
# See https://github.com/newrelic/rpm/blob/master/LICENSE for complete details.
|
4
|
-
|
5
|
-
# https://support.newrelic.com/tickets/2101
|
6
|
-
# https://github.com/newrelic/rpm/pull/42
|
7
|
-
# https://github.com/newrelic/rpm/pull/45
|
8
|
-
require 'test/unit'
|
9
|
-
require 'new_relic/agent/instrumentation/data_mapper'
|
10
|
-
|
11
|
-
class DatabaseAdapter
|
12
|
-
# we patch in here
|
13
|
-
def log(*args)
|
14
|
-
end
|
15
|
-
include ::NewRelic::Agent::Instrumentation::DataMapperInstrumentation
|
16
|
-
end
|
17
|
-
|
18
|
-
class EncodingTest < Test::Unit::TestCase
|
19
|
-
# datamapper wants a msg object
|
20
|
-
MSG = Object.new
|
21
|
-
def MSG.query
|
22
|
-
# Contains invalid UTF8 Byte
|
23
|
-
q = "select ICS95095010000000000083320000BS01030000004100+\xFF00000000000000000"
|
24
|
-
if RUBY_VERSION >= '1.9'
|
25
|
-
# Force the query to an invalid encoding
|
26
|
-
q.force_encoding 'UTF-8'
|
27
|
-
end
|
28
|
-
q
|
29
|
-
end
|
30
|
-
def MSG.duration; 1.0; end
|
31
|
-
|
32
|
-
def test_should_not_bomb_out_if_a_query_is_in_an_invalid_encoding
|
33
|
-
if RUBY_VERSION >= '1.9'
|
34
|
-
assert_equal false, MSG.query.valid_encoding?
|
35
|
-
end
|
36
|
-
db = DatabaseAdapter.new
|
37
|
-
db.send(:log, MSG)
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
@@ -1,143 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
# This file is distributed under New Relic's license terms.
|
3
|
-
# See https://github.com/newrelic/rpm/blob/master/LICENSE for complete details.
|
4
|
-
|
5
|
-
require 'mocha'
|
6
|
-
|
7
|
-
class SinatraRouteTestApp < Sinatra::Base
|
8
|
-
configure do
|
9
|
-
# display exceptions so we see what's going on
|
10
|
-
disable :show_exceptions
|
11
|
-
|
12
|
-
# create a condition (sintra's version of a before_filter) that returns the
|
13
|
-
# value that was passed into it.
|
14
|
-
set :my_condition do |boolean|
|
15
|
-
condition do
|
16
|
-
halt 404 unless boolean
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
get '/user/login' do
|
22
|
-
"please log in"
|
23
|
-
end
|
24
|
-
|
25
|
-
# this action will always return 404 because of the condition.
|
26
|
-
get '/user/:id', :my_condition => false do |id|
|
27
|
-
"Welcome #{id}"
|
28
|
-
end
|
29
|
-
|
30
|
-
get '/raise' do
|
31
|
-
raise "Uh-oh"
|
32
|
-
end
|
33
|
-
|
34
|
-
# check that pass works properly
|
35
|
-
condition { pass { halt 418, "I'm a teapot." } }
|
36
|
-
get('/pass') { }
|
37
|
-
|
38
|
-
get '/pass' do
|
39
|
-
"I'm not a teapot."
|
40
|
-
end
|
41
|
-
|
42
|
-
class Error < StandardError; end
|
43
|
-
error(Error) { halt 200, 'nothing happened' }
|
44
|
-
condition { raise Error }
|
45
|
-
get('/error') { }
|
46
|
-
|
47
|
-
def perform_action_with_newrelic_trace(options)
|
48
|
-
$last_sinatra_route = options[:name]
|
49
|
-
super
|
50
|
-
end
|
51
|
-
|
52
|
-
get '/route/:name' do |name|
|
53
|
-
# usually this would be a db test or something
|
54
|
-
pass if name != 'match'
|
55
|
-
'first route'
|
56
|
-
end
|
57
|
-
|
58
|
-
get '/route/no_match' do
|
59
|
-
'second route'
|
60
|
-
end
|
61
|
-
end
|
62
|
-
|
63
|
-
class SinatraTest < Test::Unit::TestCase
|
64
|
-
include Rack::Test::Methods
|
65
|
-
include ::NewRelic::Agent::Instrumentation::Sinatra
|
66
|
-
|
67
|
-
def app
|
68
|
-
SinatraRouteTestApp
|
69
|
-
end
|
70
|
-
|
71
|
-
def setup
|
72
|
-
::NewRelic::Agent.manual_start
|
73
|
-
end
|
74
|
-
|
75
|
-
def teardown
|
76
|
-
::NewRelic::Agent.agent.error_collector.harvest_errors([])
|
77
|
-
end
|
78
|
-
|
79
|
-
# https://support.newrelic.com/tickets/24779
|
80
|
-
def test_lower_priority_route_conditions_arent_applied_to_higher_priority_routes
|
81
|
-
get '/user/login'
|
82
|
-
assert_equal 200, last_response.status
|
83
|
-
assert_equal 'please log in', last_response.body
|
84
|
-
end
|
85
|
-
|
86
|
-
def test_conditions_are_applied_to_an_action_that_uses_them
|
87
|
-
get '/user/1'
|
88
|
-
assert_equal 404, last_response.status
|
89
|
-
end
|
90
|
-
|
91
|
-
def test_queue_time_headers_are_passed_to_agent
|
92
|
-
get '/user/login', {}, { 'HTTP_X_REQUEST_START' => 't=1360973845' }
|
93
|
-
assert ::NewRelic::Agent.agent.stats_engine.lookup_stats('WebFrontend/QueueTime')
|
94
|
-
end
|
95
|
-
|
96
|
-
def test_shown_errors_get_caught
|
97
|
-
get '/raise'
|
98
|
-
assert_equal 1, ::NewRelic::Agent.agent.error_collector.errors.size
|
99
|
-
end
|
100
|
-
|
101
|
-
def test_does_not_break_pass
|
102
|
-
get '/pass'
|
103
|
-
assert_equal 200, last_response.status
|
104
|
-
assert_equal "I'm not a teapot.", last_response.body
|
105
|
-
end
|
106
|
-
|
107
|
-
def test_does_not_break_error_handling
|
108
|
-
get '/error'
|
109
|
-
assert_equal 200, last_response.status
|
110
|
-
assert_equal "nothing happened", last_response.body
|
111
|
-
end
|
112
|
-
|
113
|
-
def test_sees_handled_error
|
114
|
-
get '/error'
|
115
|
-
assert_equal 1, ::NewRelic::Agent.agent.error_collector.errors.size
|
116
|
-
end
|
117
|
-
|
118
|
-
def test_correct_pattern
|
119
|
-
get '/route/match'
|
120
|
-
assert_equal 'first route', last_response.body
|
121
|
-
assert_equal 'GET route/([^/?#]+)', $last_sinatra_route
|
122
|
-
|
123
|
-
get '/route/no_match'
|
124
|
-
assert_equal 'second route', last_response.body
|
125
|
-
|
126
|
-
# Ideally we could handle this assert, but we can't rename transactions
|
127
|
-
# in flight at this point. Once we get that ability, consider patching
|
128
|
-
# process_route to notify of route name changes.
|
129
|
-
|
130
|
-
# assert_equal 'GET route/no_match', $last_sinatra_route
|
131
|
-
end
|
132
|
-
|
133
|
-
def test_set_unknown_transaction_name_if_error_in_routing
|
134
|
-
::NewRelic::Agent::Instrumentation::Sinatra::NewRelic \
|
135
|
-
.stubs(:http_verb).raises(StandardError.new('madness'))
|
136
|
-
|
137
|
-
get '/user/login'
|
138
|
-
|
139
|
-
metric_names = ::NewRelic::Agent.agent.stats_engine.metrics
|
140
|
-
assert(metric_names.include?('Controller/Sinatra/SinatraRouteTestApp/(unknown)'),
|
141
|
-
"#{metric_names} should include 'Controller/Sinatra/SinatraRouteTestApp/(unknown)'")
|
142
|
-
end
|
143
|
-
end
|