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
data/lib/new_relic/agent.rb
CHANGED
@@ -334,6 +334,23 @@ module NewRelic
|
|
334
334
|
end
|
335
335
|
end
|
336
336
|
|
337
|
+
|
338
|
+
# Subscribe to events of +event_type+, calling the given +handler+
|
339
|
+
# when one is sent.
|
340
|
+
def subscribe(event_type, &handler)
|
341
|
+
agent.events.subscribe( event_type, &handler )
|
342
|
+
end
|
343
|
+
|
344
|
+
|
345
|
+
# Fire an event of the specified +event_type+, passing it an the given +args+
|
346
|
+
# to any registered handlers.
|
347
|
+
def notify(event_type, *args)
|
348
|
+
agent.events.notify( event_type, *args )
|
349
|
+
rescue => err
|
350
|
+
NewRelic::Agent.logger.debug "Ignoring exception during %p event notification" % [event_type]
|
351
|
+
end
|
352
|
+
|
353
|
+
|
337
354
|
# This method disables the recording of transaction traces in the given
|
338
355
|
# block. See also #disable_all_tracing
|
339
356
|
def disable_transaction_tracing
|
data/lib/new_relic/build.rb
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
# GITSHA:
|
2
|
-
module NewRelic; module VERSION; BUILD='
|
1
|
+
# GITSHA: 0b3609118317f2a210341a12bcf8759e9978fd28
|
2
|
+
module NewRelic; module VERSION; BUILD='103.beta'; end; end
|
data/lib/new_relic/coerce.rb
CHANGED
@@ -10,15 +10,29 @@ module NewRelic::Rack
|
|
10
10
|
@app = app
|
11
11
|
end
|
12
12
|
|
13
|
+
FIRED_FORMATS = {
|
14
|
+
:before_call => "newrelic.agent_hooks_before_fired",
|
15
|
+
:after_call => "newrelic.agent_hooks_after_fired"
|
16
|
+
}
|
17
|
+
|
13
18
|
# method required by Rack interface
|
14
19
|
# [status, headers, response]
|
15
20
|
def call(env)
|
16
|
-
|
17
|
-
events.notify(:before_call, env)
|
21
|
+
notify(:before_call, env)
|
18
22
|
result = @app.call(env)
|
19
|
-
|
23
|
+
notify(:after_call, env, result)
|
20
24
|
result
|
21
25
|
end
|
26
|
+
|
27
|
+
def notify(event, env, *args)
|
28
|
+
key = FIRED_FORMATS[event]
|
29
|
+
events.notify(event, *([env] + args)) unless env[key]
|
30
|
+
env[key] = true
|
31
|
+
end
|
32
|
+
|
33
|
+
def events
|
34
|
+
NewRelic::Agent.instance.events
|
35
|
+
end
|
22
36
|
end
|
23
37
|
end
|
24
38
|
|
@@ -15,9 +15,10 @@ module NewRelic::Rack
|
|
15
15
|
def call(env)
|
16
16
|
result = @app.call(env) # [status, headers, response]
|
17
17
|
|
18
|
-
if (NewRelic::Agent.browser_timing_header != "") && should_instrument?(result[0], result[1])
|
18
|
+
if (NewRelic::Agent.browser_timing_header != "") && should_instrument?(env, result[0], result[1])
|
19
19
|
response_string = autoinstrument_source(result[2], result[1])
|
20
20
|
|
21
|
+
env[ALREADY_INSTRUMENTED_KEY] = true
|
21
22
|
if response_string
|
22
23
|
response = Rack::Response.new(response_string, result[0], result[1])
|
23
24
|
response.finish
|
@@ -29,8 +30,12 @@ module NewRelic::Rack
|
|
29
30
|
end
|
30
31
|
end
|
31
32
|
|
32
|
-
|
33
|
-
|
33
|
+
ALREADY_INSTRUMENTED_KEY = "newrelic.browser_monitoring_already_instrumented"
|
34
|
+
|
35
|
+
def should_instrument?(env, status, headers)
|
36
|
+
status == 200 &&
|
37
|
+
!env[ALREADY_INSTRUMENTED_KEY] &&
|
38
|
+
headers["Content-Type"] && headers["Content-Type"].include?("text/html") &&
|
34
39
|
!headers['Content-Disposition'].to_s.include?('attachment')
|
35
40
|
end
|
36
41
|
|
@@ -37,6 +37,8 @@ module NewRelic::Rack
|
|
37
37
|
end
|
38
38
|
|
39
39
|
def ignored_in_controller?(exception, request)
|
40
|
+
return true if request.env['newrelic.ignored']
|
41
|
+
|
40
42
|
if request.env['action_dispatch.request.parameters']
|
41
43
|
ignore_actions = newrelic_ignore_for_controller(request.env['action_dispatch.request.parameters']['controller'])
|
42
44
|
action_name = request.env['action_dispatch.request.parameters']['action']
|
@@ -110,29 +110,6 @@ module NewRelic
|
|
110
110
|
count
|
111
111
|
end
|
112
112
|
|
113
|
-
# Walk through the tree and truncate the segments in a
|
114
|
-
# depth-first manner
|
115
|
-
def truncate(max)
|
116
|
-
return 1 unless @called_segments
|
117
|
-
total, self.called_segments = truncate_each_child(max - 1)
|
118
|
-
total+1
|
119
|
-
end
|
120
|
-
|
121
|
-
def truncate_each_child(max)
|
122
|
-
total = 0
|
123
|
-
accumulator = []
|
124
|
-
called_segments.each { | s |
|
125
|
-
if total == max
|
126
|
-
true
|
127
|
-
else
|
128
|
-
total += s.truncate(max - total)
|
129
|
-
accumulator << s
|
130
|
-
end
|
131
|
-
}
|
132
|
-
total
|
133
|
-
[total, accumulator]
|
134
|
-
end
|
135
|
-
|
136
113
|
def []=(key, value)
|
137
114
|
# only create a parameters field if a parameter is set; this will save
|
138
115
|
# bandwidth etc as most segments have no parameters
|
@@ -38,15 +38,6 @@ module NewRelic
|
|
38
38
|
@segment_count
|
39
39
|
end
|
40
40
|
|
41
|
-
# Truncates the transaction sample to a maximum length determined
|
42
|
-
# by the passed-in parameter. Operates recursively on the entire
|
43
|
-
# tree of transaction segments in a depth-first manner
|
44
|
-
def truncate(max)
|
45
|
-
return if @segment_count < max
|
46
|
-
@root_segment.truncate(max + 1)
|
47
|
-
@segment_count = max
|
48
|
-
end
|
49
|
-
|
50
41
|
# makes sure that the parameter cache for segment count is set to
|
51
42
|
# the correct value
|
52
43
|
def ensure_segment_count_set(count)
|
data/lib/new_relic/version.rb
CHANGED
@@ -0,0 +1,204 @@
|
|
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
|
+
# These helpers should not have any gem dependencies except on newrelic_rpm
|
6
|
+
# itself, and should be usable from within any multiverse suite.
|
7
|
+
|
8
|
+
def assert_between(floor, ceiling, value, message="expected #{floor} <= #{value} <= #{ceiling}")
|
9
|
+
assert((floor <= value && value <= ceiling), message)
|
10
|
+
end
|
11
|
+
|
12
|
+
def assert_in_delta(expected, actual, delta)
|
13
|
+
assert_between((expected - delta), (expected + delta), actual)
|
14
|
+
end
|
15
|
+
|
16
|
+
def check_metric_time(metric, value, delta)
|
17
|
+
time = NewRelic::Agent.get_stats(metric).total_call_time
|
18
|
+
assert_in_delta(value, time, delta)
|
19
|
+
end
|
20
|
+
|
21
|
+
def check_metric_count(metric, value)
|
22
|
+
count = NewRelic::Agent.get_stats(metric).call_count
|
23
|
+
assert_equal(value, count, "should have the correct number of calls")
|
24
|
+
end
|
25
|
+
|
26
|
+
def check_unscoped_metric_count(metric, value)
|
27
|
+
count = NewRelic::Agent.get_stats_unscoped(metric).call_count
|
28
|
+
assert_equal(value, count, "should have the correct number of calls")
|
29
|
+
end
|
30
|
+
|
31
|
+
def generate_unscoped_metric_counts(*metrics)
|
32
|
+
metrics.inject({}) do |sum, metric|
|
33
|
+
sum[metric] = NewRelic::Agent.get_stats_no_scope(metric).call_count
|
34
|
+
sum
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
def generate_metric_counts(*metrics)
|
39
|
+
metrics.inject({}) do |sum, metric|
|
40
|
+
sum[metric] = NewRelic::Agent.get_stats(metric).call_count
|
41
|
+
sum
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
def assert_does_not_call_metrics(*metrics)
|
46
|
+
first_metrics = generate_metric_counts(*metrics)
|
47
|
+
yield
|
48
|
+
last_metrics = generate_metric_counts(*metrics)
|
49
|
+
assert_equal first_metrics, last_metrics, "should not have changed these metrics"
|
50
|
+
end
|
51
|
+
|
52
|
+
def assert_calls_metrics(*metrics)
|
53
|
+
first_metrics = generate_metric_counts(*metrics)
|
54
|
+
yield
|
55
|
+
last_metrics = generate_metric_counts(*metrics)
|
56
|
+
assert_not_equal first_metrics, last_metrics, "should have changed these metrics"
|
57
|
+
end
|
58
|
+
|
59
|
+
def assert_calls_unscoped_metrics(*metrics)
|
60
|
+
first_metrics = generate_unscoped_metric_counts(*metrics)
|
61
|
+
yield
|
62
|
+
last_metrics = generate_unscoped_metric_counts(*metrics)
|
63
|
+
assert_not_equal first_metrics, last_metrics, "should have changed these metrics"
|
64
|
+
end
|
65
|
+
|
66
|
+
unless defined?( assert_includes )
|
67
|
+
def assert_includes( collection, member, msg=nil )
|
68
|
+
msg = build_message( msg, "Expected ? to include ?", collection, member )
|
69
|
+
assert_block( msg ) { collection.include?(member) }
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
unless defined?( assert_not_includes )
|
74
|
+
def assert_not_includes( collection, member, msg=nil )
|
75
|
+
msg = build_message( msg, "Expected ? not to include ?", collection, member )
|
76
|
+
assert_block( msg ) { !collection.include?(member) }
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
def compare_metrics(expected, actual)
|
81
|
+
actual.delete_if {|a| a.include?('GC/cumulative') } # in case we are in REE
|
82
|
+
assert_equal(expected.to_a.sort, actual.to_a.sort, "extra: #{(actual - expected).to_a.inspect}; missing: #{(expected - actual).to_a.inspect}")
|
83
|
+
end
|
84
|
+
|
85
|
+
def metric_spec_from_specish(specish)
|
86
|
+
spec = case specish
|
87
|
+
when String then NewRelic::MetricSpec.new(specish)
|
88
|
+
when Array then NewRelic::MetricSpec.new(*specish)
|
89
|
+
end
|
90
|
+
spec
|
91
|
+
end
|
92
|
+
|
93
|
+
def _normalize_metric_expectations(expectations)
|
94
|
+
case expectations
|
95
|
+
when Array
|
96
|
+
hash = {}
|
97
|
+
# Just assert that the metric is present, nothing about the attributes
|
98
|
+
expectations.each { |k| hash[k] = { } }
|
99
|
+
hash
|
100
|
+
else
|
101
|
+
expectations
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
def assert_metrics_recorded(expected)
|
106
|
+
expected = _normalize_metric_expectations(expected)
|
107
|
+
expected.each do |specish, expected_attrs|
|
108
|
+
expected_spec = metric_spec_from_specish(specish)
|
109
|
+
actual_stats = NewRelic::Agent.instance.stats_engine.lookup_stats(*Array(specish))
|
110
|
+
if !actual_stats
|
111
|
+
all_specs = NewRelic::Agent.instance.stats_engine.metric_specs
|
112
|
+
matches = all_specs.select { |spec| spec.name == expected_spec.name }
|
113
|
+
matches.map! { |m| " #{m.inspect}" }
|
114
|
+
msg = "Did not find stats for spec #{expected_spec.inspect}."
|
115
|
+
msg += "\nDid find specs: [\n#{matches.join(",\n")}\n]" unless matches.empty?
|
116
|
+
msg += "\nAll specs in there were: [\n#{all_specs.map {|s| s.name}.join(",\n")}\n]"
|
117
|
+
assert(actual_stats, msg)
|
118
|
+
end
|
119
|
+
expected_attrs.each do |attr, expected_value|
|
120
|
+
actual_value = actual_stats.send(attr)
|
121
|
+
if attr == :call_count
|
122
|
+
assert_equal(expected_value, actual_value,
|
123
|
+
"Expected #{attr} for #{expected_spec} to be #{expected_value}, got #{actual_value}")
|
124
|
+
else
|
125
|
+
assert_in_delta(expected_value, actual_value, 0.0001,
|
126
|
+
"Expected #{attr} for #{expected_spec} to be ~#{expected_value}, got #{actual_value}")
|
127
|
+
end
|
128
|
+
end
|
129
|
+
end
|
130
|
+
end
|
131
|
+
|
132
|
+
def assert_metrics_recorded_exclusive(expected, options={})
|
133
|
+
expected = _normalize_metric_expectations(expected)
|
134
|
+
assert_metrics_recorded(expected)
|
135
|
+
recorded_metrics = NewRelic::Agent.instance.stats_engine.metrics
|
136
|
+
if options[:filter]
|
137
|
+
recorded_metrics = recorded_metrics.select { |m| m.match(options[:filter]) }
|
138
|
+
end
|
139
|
+
expected_metrics = expected.keys.map { |s| metric_spec_from_specish(s).to_s }
|
140
|
+
unexpected_metrics = recorded_metrics.select{|m| m !~ /GC\/cumulative/}
|
141
|
+
unexpected_metrics -= expected_metrics
|
142
|
+
assert_equal(0, unexpected_metrics.size, "Found unexpected metrics: [#{unexpected_metrics.join(', ')}]")
|
143
|
+
end
|
144
|
+
|
145
|
+
def assert_metrics_not_recorded(not_expected)
|
146
|
+
not_expected = _normalize_metric_expectations(not_expected)
|
147
|
+
found_but_not_expected = []
|
148
|
+
not_expected.each do |specish, _|
|
149
|
+
spec = metric_spec_from_specish(specish)
|
150
|
+
if NewRelic::Agent.instance.stats_engine.lookup_stats(*Array(specish))
|
151
|
+
found_but_not_expected << spec
|
152
|
+
end
|
153
|
+
end
|
154
|
+
assert_equal([], found_but_not_expected, "Found unexpected metrics: [#{found_but_not_expected.join(', ')}]")
|
155
|
+
end
|
156
|
+
|
157
|
+
# Mock up a transaction for testing purposes, optionally specifying a name and
|
158
|
+
# transaction type. The given block will be executed within the context of the
|
159
|
+
# dummy transaction.
|
160
|
+
#
|
161
|
+
# Examples:
|
162
|
+
#
|
163
|
+
# With default name ('dummy') and type (:other):
|
164
|
+
# in_transaction { ... }
|
165
|
+
#
|
166
|
+
# With an explicit transaction name and default type:
|
167
|
+
# in_transaction('foobar') { ... }
|
168
|
+
#
|
169
|
+
# With default name and explicit type:
|
170
|
+
# in_transaction(:type => :controller) { ... }
|
171
|
+
#
|
172
|
+
# With a transaction name plus type:
|
173
|
+
# in_transaction('foobar', :type => :controller) { ... }
|
174
|
+
#
|
175
|
+
def in_transaction(*args)
|
176
|
+
opts = (args.last && args.last.is_a?(Hash)) ? args.pop : {}
|
177
|
+
name = args.first || 'dummy'
|
178
|
+
defaults = { :type => :other }
|
179
|
+
options = defaults.merge(opts)
|
180
|
+
NewRelic::Agent.instance.instance_variable_set(:@transaction_sampler,
|
181
|
+
NewRelic::Agent::TransactionSampler.new)
|
182
|
+
NewRelic::Agent.instance.stats_engine.transaction_sampler = \
|
183
|
+
NewRelic::Agent.instance.transaction_sampler
|
184
|
+
NewRelic::Agent::Transaction.start(options[:type])
|
185
|
+
val = yield
|
186
|
+
NewRelic::Agent::Transaction.stop(name)
|
187
|
+
val
|
188
|
+
end
|
189
|
+
|
190
|
+
# Convenience wrapper around in_transaction that sets the type so that it
|
191
|
+
# looks like we are in a web transaction
|
192
|
+
def in_web_transaction(name='dummy')
|
193
|
+
in_transaction(name, :type => :controller) do
|
194
|
+
yield
|
195
|
+
end
|
196
|
+
end
|
197
|
+
|
198
|
+
def freeze_time(now=Time.now)
|
199
|
+
Time.stubs(:now).returns(now)
|
200
|
+
end
|
201
|
+
|
202
|
+
def advance_time(seconds)
|
203
|
+
freeze_time(Time.now + seconds)
|
204
|
+
end
|
data/test/config/newrelic.yml
CHANGED
data/test/config/test_control.rb
CHANGED
@@ -22,7 +22,7 @@ class NewRelic::Control::Frameworks::Test < parent_class
|
|
22
22
|
end
|
23
23
|
|
24
24
|
def app
|
25
|
-
if defined?(::Rails::VERSION)
|
25
|
+
if defined?(::Rails) && defined?(::Rails::VERSION)
|
26
26
|
if ::Rails::VERSION::MAJOR.to_i == 4
|
27
27
|
:rails4
|
28
28
|
elsif ::Rails::VERSION::MAJOR.to_i == 3
|
@@ -30,6 +30,8 @@ class NewRelic::Control::Frameworks::Test < parent_class
|
|
30
30
|
else
|
31
31
|
:rails
|
32
32
|
end
|
33
|
+
else
|
34
|
+
:test
|
33
35
|
end
|
34
36
|
end
|
35
37
|
|
@@ -30,6 +30,10 @@ class KeyTransactionsTest < Test::Unit::TestCase
|
|
30
30
|
|
31
31
|
NewRelic::Agent.manual_start(:sync_startup => true,
|
32
32
|
:force_reconnect => true)
|
33
|
+
|
34
|
+
# Important that this be stubbed before any of our add_transaction_tracer's
|
35
|
+
# end up getting run in the test methods
|
36
|
+
@now = stub_time_now
|
33
37
|
end
|
34
38
|
|
35
39
|
def teardown
|
@@ -42,7 +46,7 @@ class KeyTransactionsTest < Test::Unit::TestCase
|
|
42
46
|
FAILING = 2
|
43
47
|
|
44
48
|
def test_applied_correct_apdex_t_to_key_txn
|
45
|
-
TestWidget.new.key_txn(
|
49
|
+
TestWidget.new.key_txn(@now)
|
46
50
|
NewRelic::Agent.instance.send(:harvest_and_send_timeslice_data)
|
47
51
|
|
48
52
|
stats = $collector.reported_stats_for_metric('Apdex')[0]
|
@@ -51,7 +55,7 @@ class KeyTransactionsTest < Test::Unit::TestCase
|
|
51
55
|
end
|
52
56
|
|
53
57
|
def test_applied_correct_apdex_t_to_regular_txn
|
54
|
-
TestWidget.new.other_txn(
|
58
|
+
TestWidget.new.other_txn(@now)
|
55
59
|
NewRelic::Agent.instance.send(:harvest_and_send_timeslice_data)
|
56
60
|
|
57
61
|
stats = $collector.reported_stats_for_metric('Apdex')[0]
|
@@ -60,9 +64,8 @@ class KeyTransactionsTest < Test::Unit::TestCase
|
|
60
64
|
end
|
61
65
|
|
62
66
|
def test_applied_correct_tt_theshold
|
63
|
-
now
|
64
|
-
TestWidget.new.
|
65
|
-
TestWidget.new.other_txn(now)
|
67
|
+
TestWidget.new.key_txn(@now)
|
68
|
+
TestWidget.new.other_txn(@now)
|
66
69
|
|
67
70
|
NewRelic::Agent.instance.send(:harvest_and_send_slowest_sample)
|
68
71
|
|