newrelic_rpm 3.3.2.1 → 3.3.3.beta1
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of newrelic_rpm might be problematic. Click here for more details.
- data/CHANGELOG +3 -2
- data/lib/new_relic/agent/instrumentation/queue_time.rb +1 -1
- data/lib/new_relic/agent/instrumentation/sinatra.rb +40 -20
- data/lib/new_relic/agent/transaction_info.rb +8 -15
- data/lib/new_relic/agent/transaction_sample_builder.rb +12 -3
- data/lib/new_relic/metric_spec.rb +7 -6
- data/lib/new_relic/version.rb +2 -2
- data/newrelic_rpm.gemspec +3 -4
- data/test/new_relic/agent/agent_test_controller_test.rb +19 -0
- data/test/new_relic/agent/instrumentation/queue_time_test.rb +2 -2
- data/test/new_relic/agent/transaction_sample_builder_test.rb +7 -1
- data/test/new_relic/agent/transaction_sampler_test.rb +29 -28
- metadata +7 -7
- data/test/new_relic/agent/transaction_info_test.rb +0 -13
data/CHANGELOG
CHANGED
@@ -1,5 +1,6 @@
|
|
1
|
-
v3.3.
|
2
|
-
*
|
1
|
+
v3.3.3
|
2
|
+
* Improved Sinatra instrumentation
|
3
|
+
* Limit the number of nodes collected in long running transactions to prevent leaking memory
|
3
4
|
|
4
5
|
v3.3.2
|
5
6
|
* deployments recipe change: truncate git SHAs to 7 characters
|
@@ -172,7 +172,7 @@ module NewRelic
|
|
172
172
|
def record_time_stat(name, start_time, end_time) # (String, Time, Time) -> nil
|
173
173
|
total_time = end_time - start_time
|
174
174
|
if total_time < 0
|
175
|
-
raise "should not provide an end time less than start time: #{end_time} is less than #{start_time}"
|
175
|
+
raise "should not provide an end time less than start time: #{end_time.strftime('%s.%N')} is less than #{start_time.strftime('%s.%N')}. total time is #{total_time}."
|
176
176
|
else
|
177
177
|
NewRelic::Agent.get_stats(name).trace_call(total_time)
|
178
178
|
end
|
@@ -2,7 +2,8 @@ require 'new_relic/agent/instrumentation/controller_instrumentation'
|
|
2
2
|
|
3
3
|
DependencyDetection.defer do
|
4
4
|
depends_on do
|
5
|
-
defined?(::Sinatra) && defined?(::Sinatra::Base)
|
5
|
+
defined?(::Sinatra) && defined?(::Sinatra::Base) &&
|
6
|
+
Sinatra::Base.private_method_defined?(:dispatch!)
|
6
7
|
end
|
7
8
|
|
8
9
|
executes do
|
@@ -12,8 +13,8 @@ DependencyDetection.defer do
|
|
12
13
|
executes do
|
13
14
|
::Sinatra::Base.class_eval do
|
14
15
|
include NewRelic::Agent::Instrumentation::Sinatra
|
15
|
-
alias
|
16
|
-
alias
|
16
|
+
alias dispatch_without_newrelic dispatch!
|
17
|
+
alias dispatch! dispatch_with_newrelic
|
17
18
|
end
|
18
19
|
end
|
19
20
|
end
|
@@ -30,26 +31,45 @@ module NewRelic
|
|
30
31
|
# to match them. HTTP operations are not distinguished. Multiple matches
|
31
32
|
# will all be tracked as separate actions.
|
32
33
|
module Sinatra
|
34
|
+
include ::NewRelic::Agent::Instrumentation::ControllerInstrumentation
|
35
|
+
|
36
|
+
def dispatch_with_newrelic
|
37
|
+
txn_name = NewRelic.transaction_name(self.class.routes, @request) do |pattern, keys, conditions|
|
38
|
+
process_route(pattern, keys, conditions) do
|
39
|
+
pattern.source
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
perform_action_with_newrelic_trace(:category => :sinatra,
|
44
|
+
:name => txn_name,
|
45
|
+
:params => @request.params) do
|
46
|
+
dispatch_without_newrelic
|
47
|
+
end
|
48
|
+
end
|
33
49
|
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
50
|
+
module NewRelic
|
51
|
+
extend self
|
52
|
+
|
53
|
+
def http_verb(request)
|
54
|
+
request.request_method if request.respond_to?(:request_method)
|
55
|
+
end
|
56
|
+
|
57
|
+
def transaction_name(routes, request)
|
58
|
+
name = '(unknown)'
|
59
|
+
verb = http_verb(request)
|
60
|
+
|
61
|
+
routes[verb].each do |pattern, keys, conditions, block|
|
62
|
+
if pattern = yield(pattern, keys, conditions)
|
63
|
+
name = pattern
|
44
64
|
end
|
45
65
|
end
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
66
|
+
|
67
|
+
name.gsub!(%r{^[/^]*(.*?)[/\$\?]*$}, '\1')
|
68
|
+
if verb
|
69
|
+
name = verb + ' ' + name
|
70
|
+
end
|
71
|
+
|
72
|
+
name
|
53
73
|
end
|
54
74
|
end
|
55
75
|
end
|
@@ -1,5 +1,3 @@
|
|
1
|
-
require 'erb'
|
2
|
-
|
3
1
|
module NewRelic
|
4
2
|
module Agent
|
5
3
|
class TransactionInfo
|
@@ -50,22 +48,17 @@ module NewRelic
|
|
50
48
|
def self.reset(request=nil)
|
51
49
|
clear
|
52
50
|
instance = get
|
53
|
-
instance.token = get_token(request)
|
54
|
-
end
|
55
51
|
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
ERB::Util.h(s[1])
|
52
|
+
if request
|
53
|
+
agent_flag = request.cookies['NRAGENT']
|
54
|
+
if agent_flag
|
55
|
+
s = agent_flag.split("=")
|
56
|
+
if s.length == 2
|
57
|
+
if s[0] == "tk" && s[1]
|
58
|
+
instance.token = s[1]
|
59
|
+
end
|
65
60
|
end
|
66
61
|
end
|
67
|
-
else
|
68
|
-
nil
|
69
62
|
end
|
70
63
|
end
|
71
64
|
end
|
@@ -9,6 +9,7 @@ module NewRelic
|
|
9
9
|
# accessed by any other thread so no need for synchronization.
|
10
10
|
class TransactionSampleBuilder
|
11
11
|
attr_reader :current_segment, :sample
|
12
|
+
attr_accessor :segment_limit
|
12
13
|
|
13
14
|
include NewRelic::CollectionHelper
|
14
15
|
|
@@ -16,24 +17,32 @@ module NewRelic
|
|
16
17
|
@sample = NewRelic::TransactionSample.new(time.to_f)
|
17
18
|
@sample_start = time.to_f
|
18
19
|
@current_segment = @sample.root_segment
|
20
|
+
@segment_limit = NewRelic::Control.instance.fetch('transaction_tracer', {}) \
|
21
|
+
.fetch('limit_segments', 4000)
|
19
22
|
end
|
20
23
|
|
21
24
|
def sample_id
|
22
25
|
@sample.sample_id
|
23
26
|
end
|
27
|
+
|
24
28
|
def ignored?
|
25
29
|
@ignore || @sample.params[:path].nil?
|
26
30
|
end
|
31
|
+
|
27
32
|
def ignore_transaction
|
28
33
|
@ignore = true
|
29
34
|
end
|
35
|
+
|
30
36
|
def trace_entry(metric_name, time)
|
31
|
-
|
32
|
-
|
33
|
-
|
37
|
+
if @sample.count_segments < @segment_limit
|
38
|
+
segment = @sample.create_segment(time.to_f - @sample_start, metric_name)
|
39
|
+
@current_segment.add_called_segment(segment)
|
40
|
+
@current_segment = segment
|
41
|
+
end
|
34
42
|
end
|
35
43
|
|
36
44
|
def trace_exit(metric_name, time)
|
45
|
+
return unless @sample.count_segments < @segment_limit
|
37
46
|
if metric_name != @current_segment.metric_name
|
38
47
|
fail "unbalanced entry/exit: #{metric_name} != #{@current_segment.metric_name}"
|
39
48
|
end
|
@@ -6,18 +6,19 @@ class NewRelic::MetricSpec
|
|
6
6
|
|
7
7
|
# the maximum length of a metric name or metric scope
|
8
8
|
MAX_LENGTH = 255
|
9
|
+
LENGTH_RANGE = (0...MAX_LENGTH)
|
9
10
|
# Need a "zero-arg" constructor so it can be instantiated from java (using
|
10
11
|
# jruby) for sending responses to ruby agents from the java collector.
|
11
12
|
#
|
12
13
|
def initialize(metric_name = '', metric_scope = '')
|
13
|
-
self.name = (metric_name || '') && metric_name[
|
14
|
-
self.scope = metric_scope && metric_scope[
|
14
|
+
self.name = (metric_name || '') && metric_name[LENGTH_RANGE]
|
15
|
+
self.scope = metric_scope && metric_scope[LENGTH_RANGE]
|
15
16
|
end
|
16
17
|
|
17
18
|
# truncates the name and scope to the MAX_LENGTH
|
18
19
|
def truncate!
|
19
|
-
self.name = name[
|
20
|
-
self.scope = scope[
|
20
|
+
self.name = name[LENGTH_RANGE] if name && name.size > MAX_LENGTH
|
21
|
+
self.scope = scope[LENGTH_RANGE] if scope && scope.size > MAX_LENGTH
|
21
22
|
end
|
22
23
|
|
23
24
|
def ==(o)
|
@@ -42,10 +43,10 @@ class NewRelic::MetricSpec
|
|
42
43
|
NewRelic::Control.instance.log.warn("The sub method on metric specs is deprecated") rescue nil
|
43
44
|
return nil if name !~ pattern &&
|
44
45
|
(!apply_to_scope || scope.nil? || scope !~ pattern)
|
45
|
-
new_name = name.sub(pattern, replacement)[
|
46
|
+
new_name = name.sub(pattern, replacement)[LENGTH_RANGE]
|
46
47
|
|
47
48
|
if apply_to_scope
|
48
|
-
new_scope = (scope && scope.sub(pattern, replacement)[
|
49
|
+
new_scope = (scope && scope.sub(pattern, replacement)[LENGTH_RANGE])
|
49
50
|
else
|
50
51
|
new_scope = scope
|
51
52
|
end
|
data/lib/new_relic/version.rb
CHANGED
@@ -3,8 +3,8 @@ module NewRelic
|
|
3
3
|
module VERSION #:nodoc:
|
4
4
|
MAJOR = 3
|
5
5
|
MINOR = 3
|
6
|
-
TINY =
|
7
|
-
BUILD =
|
6
|
+
TINY = 3
|
7
|
+
BUILD = 'beta1' # Set to nil for a release, 'beta1', 'alpha', etc for prerelease builds
|
8
8
|
STRING = [MAJOR, MINOR, TINY, BUILD].compact.join('.')
|
9
9
|
end
|
10
10
|
|
data/newrelic_rpm.gemspec
CHANGED
@@ -5,14 +5,14 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "newrelic_rpm"
|
8
|
-
s.version = "3.3.
|
8
|
+
s.version = "3.3.3.beta1"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Bill Kayser", "Jon Guymon", "Justin George", "Darin Swanson"]
|
12
|
-
s.date = "2012-03-
|
12
|
+
s.date = "2012-03-14"
|
13
13
|
s.description = "New Relic is a performance management system, developed by New Relic,\nInc (http://www.newrelic.com). New Relic provides you with deep\ninformation about the performance of your web application as it runs\nin production. The New Relic Ruby Agent is dual-purposed as a either a\nGem or plugin, hosted on\nhttp://github.com/newrelic/rpm/\n"
|
14
14
|
s.email = "support@newrelic.com"
|
15
|
-
s.executables = ["
|
15
|
+
s.executables = ["newrelic_cmd", "mongrel_rpm", "newrelic"]
|
16
16
|
s.extra_rdoc_files = [
|
17
17
|
"CHANGELOG",
|
18
18
|
"LICENSE",
|
@@ -170,7 +170,6 @@ Gem::Specification.new do |s|
|
|
170
170
|
"test/new_relic/agent/stats_engine/metric_stats_test.rb",
|
171
171
|
"test/new_relic/agent/stats_engine/samplers_test.rb",
|
172
172
|
"test/new_relic/agent/stats_engine_test.rb",
|
173
|
-
"test/new_relic/agent/transaction_info_test.rb",
|
174
173
|
"test/new_relic/agent/transaction_sample_builder_test.rb",
|
175
174
|
"test/new_relic/agent/transaction_sampler_test.rb",
|
176
175
|
"test/new_relic/agent/worker_loop_test.rb",
|
@@ -83,6 +83,9 @@ class NewRelic::Agent::AgentTestControllerTest < ActionController::TestCase
|
|
83
83
|
end
|
84
84
|
|
85
85
|
def test_new_queue_integration
|
86
|
+
# make this test deterministic
|
87
|
+
Time.stubs(:now => Time.at(2))
|
88
|
+
|
86
89
|
NewRelic::Agent::AgentTestController.clear_headers
|
87
90
|
engine.clear_stats
|
88
91
|
start = ((Time.now - 1).to_f * 1_000_000).to_i
|
@@ -94,6 +97,9 @@ class NewRelic::Agent::AgentTestControllerTest < ActionController::TestCase
|
|
94
97
|
|
95
98
|
|
96
99
|
def test_new_middleware_integration
|
100
|
+
# make this test deterministic
|
101
|
+
Time.stubs(:now => Time.at(2))
|
102
|
+
|
97
103
|
engine.clear_stats
|
98
104
|
start = ((Time.now - 1).to_f * 1_000_000).to_i
|
99
105
|
NewRelic::Agent::AgentTestController.set_some_headers 'HTTP_X_MIDDLEWARE_START'=> "t=#{start}"
|
@@ -103,6 +109,9 @@ class NewRelic::Agent::AgentTestControllerTest < ActionController::TestCase
|
|
103
109
|
end
|
104
110
|
|
105
111
|
def test_new_server_time_integration
|
112
|
+
# make this test deterministic
|
113
|
+
Time.stubs(:now => Time.at(2))
|
114
|
+
|
106
115
|
NewRelic::Agent::AgentTestController.clear_headers
|
107
116
|
engine.clear_stats
|
108
117
|
start = ((Time.now - 1).to_f * 1_000_000).to_i
|
@@ -113,6 +122,9 @@ class NewRelic::Agent::AgentTestControllerTest < ActionController::TestCase
|
|
113
122
|
end
|
114
123
|
|
115
124
|
def test_new_frontend_work_integration
|
125
|
+
# make this test deterministic
|
126
|
+
Time.stubs(:now => Time.at(10))
|
127
|
+
|
116
128
|
engine.clear_stats
|
117
129
|
times = [Time.now - 3, Time.now - 2, Time.now - 1]
|
118
130
|
times.map! {|t| (t.to_f * 1_000_000).to_i }
|
@@ -299,6 +311,9 @@ class NewRelic::Agent::AgentTestControllerTest < ActionController::TestCase
|
|
299
311
|
end
|
300
312
|
|
301
313
|
def test_queue_headers_apache
|
314
|
+
# make this test deterministic
|
315
|
+
Time.stubs(:now => Time.at(10))
|
316
|
+
|
302
317
|
NewRelic::Agent::AgentTestController.clear_headers
|
303
318
|
engine.clear_stats
|
304
319
|
queue_length_stat = stats('Mongrel/Queue Length')
|
@@ -315,6 +330,8 @@ class NewRelic::Agent::AgentTestControllerTest < ActionController::TestCase
|
|
315
330
|
|
316
331
|
end
|
317
332
|
def test_queue_headers_heroku
|
333
|
+
# make this test deterministic
|
334
|
+
Time.stubs(:now => Time.at(10))
|
318
335
|
|
319
336
|
engine.clear_stats
|
320
337
|
NewRelic::Agent::AgentTestController.clear_headers
|
@@ -333,6 +350,8 @@ class NewRelic::Agent::AgentTestControllerTest < ActionController::TestCase
|
|
333
350
|
end
|
334
351
|
|
335
352
|
def test_queue_headers_heroku_queue_length
|
353
|
+
# make this test deterministic
|
354
|
+
Time.stubs(:now => Time.at(10))
|
336
355
|
|
337
356
|
engine.clear_stats
|
338
357
|
NewRelic::Agent::AgentTestController.clear_headers
|
@@ -301,9 +301,9 @@ class NewRelic::Agent::Instrumentation::QueueTimeTest < Test::Unit::TestCase
|
|
301
301
|
end
|
302
302
|
|
303
303
|
def test_record_time_stat_with_end_after_start
|
304
|
-
record_time_stat('WebFrontend/WebServer/foo',
|
304
|
+
record_time_stat('WebFrontend/WebServer/foo', Time.at(1.0001), Time.at(1))
|
305
305
|
rescue RuntimeError => e
|
306
|
-
|
306
|
+
assert_match(/should not provide an end time less than start time/, e.message)
|
307
307
|
end
|
308
308
|
|
309
309
|
def test_convert_to_microseconds
|
@@ -159,7 +159,13 @@ class NewRelic::Agent::TransationSampleBuilderTest < Test::Unit::TestCase
|
|
159
159
|
@builder.finish_trace(Time.now.to_f)
|
160
160
|
validate_builder
|
161
161
|
end
|
162
|
-
|
162
|
+
|
163
|
+
def test_trace_should_not_record_more_than_segment_limit
|
164
|
+
@builder.segment_limit = 3
|
165
|
+
8.times {|i| build_segment i.to_s }
|
166
|
+
assert_equal 3, @builder.sample.count_segments
|
167
|
+
end
|
168
|
+
|
163
169
|
def validate_builder(check_names = true)
|
164
170
|
validate_segment @builder.sample.root_segment, check_names
|
165
171
|
end
|
@@ -264,7 +264,6 @@ class NewRelic::Agent::TransactionSamplerTest < Test::Unit::TestCase
|
|
264
264
|
assert_equal(new_sample, @sampler.instance_variable_get('@slowest_sample'))
|
265
265
|
end
|
266
266
|
|
267
|
-
|
268
267
|
def test_store_slowest_sample_not_slowest
|
269
268
|
old_sample = mock('old_sample')
|
270
269
|
new_sample = mock('new_sample')
|
@@ -297,7 +296,7 @@ class NewRelic::Agent::TransactionSamplerTest < Test::Unit::TestCase
|
|
297
296
|
new_sample.expects(:duration).returns(1.0)
|
298
297
|
assert_equal(true, @sampler.slowest_sample?(old_sample, new_sample))
|
299
298
|
end
|
300
|
-
|
299
|
+
|
301
300
|
def test_truncate_samples_no_samples
|
302
301
|
@sampler.instance_eval { @max_samples = 10 }
|
303
302
|
@sampler.instance_eval { @samples = [] }
|
@@ -527,7 +526,6 @@ class NewRelic::Agent::TransactionSamplerTest < Test::Unit::TestCase
|
|
527
526
|
assert_equal([], result, "should not add samples to the array when harvest count is not moduli sampling rate")
|
528
527
|
end
|
529
528
|
|
530
|
-
|
531
529
|
def test_add_random_sample_to_activated
|
532
530
|
@sampler.instance_eval { @random_sampling = true }
|
533
531
|
sample = mock('sample')
|
@@ -554,7 +552,6 @@ class NewRelic::Agent::TransactionSamplerTest < Test::Unit::TestCase
|
|
554
552
|
assert_equal([], result, "should not add the sample to the array")
|
555
553
|
end
|
556
554
|
|
557
|
-
|
558
555
|
def test_add_samples_to_no_data
|
559
556
|
result = []
|
560
557
|
slow_threshold = 2.0
|
@@ -620,8 +617,7 @@ class NewRelic::Agent::TransactionSamplerTest < Test::Unit::TestCase
|
|
620
617
|
@sampler.expects(:add_random_sample_to).with([slower_sample])
|
621
618
|
assert_equal([slower_sample], @sampler.add_samples_to(result, slow_threshold))
|
622
619
|
end
|
623
|
-
|
624
|
-
|
620
|
+
|
625
621
|
def test_keep_force_persist
|
626
622
|
sample1 = mock('regular')
|
627
623
|
sample1.stubs(:duration).returns(10)
|
@@ -636,8 +632,7 @@ class NewRelic::Agent::TransactionSamplerTest < Test::Unit::TestCase
|
|
636
632
|
assert_equal 2, result.length
|
637
633
|
assert_equal sample1, result[0]
|
638
634
|
assert_equal sample2, result[1]
|
639
|
-
end
|
640
|
-
|
635
|
+
end
|
641
636
|
|
642
637
|
def test_start_builder_default
|
643
638
|
Thread.current[:record_tt] = true
|
@@ -679,7 +674,6 @@ class NewRelic::Agent::TransactionSamplerTest < Test::Unit::TestCase
|
|
679
674
|
# generally usefully so
|
680
675
|
|
681
676
|
def test_multiple_samples
|
682
|
-
|
683
677
|
run_sample_trace
|
684
678
|
run_sample_trace
|
685
679
|
run_sample_trace
|
@@ -752,7 +746,6 @@ class NewRelic::Agent::TransactionSamplerTest < Test::Unit::TestCase
|
|
752
746
|
# sample traces, for example. It's unfortunate, but we can't
|
753
747
|
# reliably turn off GC on all versions of ruby under test
|
754
748
|
def test_harvest_slowest
|
755
|
-
|
756
749
|
run_sample_trace
|
757
750
|
run_sample_trace
|
758
751
|
run_sample_trace { sleep 0.1 }
|
@@ -775,9 +768,7 @@ class NewRelic::Agent::TransactionSamplerTest < Test::Unit::TestCase
|
|
775
768
|
assert((new_slowest.duration >= 0.15), "Slowest duration must be >= 0.15, but was: #{new_slowest.duration.inspect}")
|
776
769
|
end
|
777
770
|
|
778
|
-
|
779
771
|
def test_prepare_to_send
|
780
|
-
|
781
772
|
run_sample_trace { sleep 0.002 }
|
782
773
|
sample = @sampler.harvest(nil, 0)[0]
|
783
774
|
|
@@ -804,7 +795,6 @@ class NewRelic::Agent::TransactionSamplerTest < Test::Unit::TestCase
|
|
804
795
|
end
|
805
796
|
|
806
797
|
def test_sample_with_parallel_paths
|
807
|
-
|
808
798
|
assert_equal 0, @sampler.scope_depth
|
809
799
|
|
810
800
|
@sampler.notice_first_scope_push Time.now.to_f
|
@@ -830,7 +820,6 @@ class NewRelic::Agent::TransactionSamplerTest < Test::Unit::TestCase
|
|
830
820
|
end
|
831
821
|
|
832
822
|
def test_double_scope_stack_empty
|
833
|
-
|
834
823
|
@sampler.notice_first_scope_push Time.now.to_f
|
835
824
|
@sampler.notice_transaction "/path", nil, {}
|
836
825
|
@sampler.notice_push_scope "a"
|
@@ -845,7 +834,6 @@ class NewRelic::Agent::TransactionSamplerTest < Test::Unit::TestCase
|
|
845
834
|
|
846
835
|
|
847
836
|
def test_record_sql_off
|
848
|
-
|
849
837
|
@sampler.notice_first_scope_push Time.now.to_f
|
850
838
|
|
851
839
|
Thread::current[:record_sql] = false
|
@@ -869,8 +857,8 @@ class NewRelic::Agent::TransactionSamplerTest < Test::Unit::TestCase
|
|
869
857
|
assert segment[:sql]
|
870
858
|
assert segment[:backtrace]
|
871
859
|
end
|
860
|
+
|
872
861
|
def test_stack_trace__scope
|
873
|
-
|
874
862
|
@sampler.stack_trace_threshold = 0
|
875
863
|
t = Time.now
|
876
864
|
@sampler.notice_first_scope_push t.to_f
|
@@ -881,7 +869,6 @@ class NewRelic::Agent::TransactionSamplerTest < Test::Unit::TestCase
|
|
881
869
|
end
|
882
870
|
|
883
871
|
def test_nil_stacktrace
|
884
|
-
|
885
872
|
@sampler.stack_trace_threshold = 2
|
886
873
|
|
887
874
|
@sampler.notice_first_scope_push Time.now.to_f
|
@@ -895,7 +882,6 @@ class NewRelic::Agent::TransactionSamplerTest < Test::Unit::TestCase
|
|
895
882
|
end
|
896
883
|
|
897
884
|
def test_big_sql
|
898
|
-
|
899
885
|
@sampler.notice_first_scope_push Time.now.to_f
|
900
886
|
|
901
887
|
sql = "SADJKHASDHASD KAJSDH ASKDH ASKDHASDK JASHD KASJDH ASKDJHSAKDJHAS DKJHSADKJSAH DKJASHD SAKJDH SAKDJHS"
|
@@ -913,9 +899,7 @@ class NewRelic::Agent::TransactionSamplerTest < Test::Unit::TestCase
|
|
913
899
|
assert sql.length <= 16384
|
914
900
|
end
|
915
901
|
|
916
|
-
|
917
902
|
def test_segment_obfuscated
|
918
|
-
|
919
903
|
@sampler.notice_first_scope_push Time.now.to_f
|
920
904
|
@sampler.notice_push_scope "foo"
|
921
905
|
|
@@ -930,7 +914,6 @@ class NewRelic::Agent::TransactionSamplerTest < Test::Unit::TestCase
|
|
930
914
|
@sampler.notice_pop_scope "foo"
|
931
915
|
end
|
932
916
|
|
933
|
-
|
934
917
|
def test_param_capture
|
935
918
|
[true, false].each do |capture|
|
936
919
|
NewRelic::Control.instance.stubs(:capture_params).returns(capture)
|
@@ -943,23 +926,41 @@ class NewRelic::Agent::TransactionSamplerTest < Test::Unit::TestCase
|
|
943
926
|
assert_equal (capture) ? 1 : 0, tt.params[:request_params].length
|
944
927
|
end
|
945
928
|
end
|
946
|
-
|
947
|
-
|
929
|
+
|
930
|
+
def test_should_not_collect_segments_beyond_limit
|
931
|
+
NewRelic::Control.instance.merge_options('transaction_tracer' => {
|
932
|
+
'limit_segments' => 3,
|
933
|
+
})
|
934
|
+
@sampler.configure!
|
935
|
+
run_sample_trace do
|
936
|
+
@sampler.notice_push_scope 'a1'
|
937
|
+
@sampler.notice_sql("SELECT * FROM sandwiches WHERE bread = 'hallah'", nil, 0)
|
938
|
+
@sampler.notice_push_scope 'a11'
|
939
|
+
@sampler.notice_sql("SELECT * FROM sandwiches WHERE bread = 'semolina'", nil, 0)
|
940
|
+
@sampler.notice_pop_scope "a11"
|
941
|
+
@sampler.notice_pop_scope "a1"
|
942
|
+
end
|
943
|
+
assert_equal 3, @sampler.samples[0].count_segments
|
944
|
+
NewRelic::Control.instance.merge_options('transaction_tracer' => {
|
945
|
+
'limit_segments' => 4000,
|
946
|
+
})
|
947
|
+
end
|
948
|
+
|
948
949
|
private
|
949
|
-
|
950
|
+
|
951
|
+
def run_sample_trace
|
950
952
|
@sampler.notice_first_scope_push Time.now.to_f
|
951
953
|
@sampler.notice_transaction '/path', nil, {}
|
952
954
|
@sampler.notice_push_scope "a"
|
953
955
|
@sampler.notice_sql("SELECT * FROM sandwiches WHERE bread = 'wheat'", nil, 0)
|
954
956
|
@sampler.notice_push_scope "ab"
|
955
957
|
@sampler.notice_sql("SELECT * FROM sandwiches WHERE bread = 'white'", nil, 0)
|
956
|
-
|
958
|
+
yield if block_given?
|
957
959
|
@sampler.notice_pop_scope "ab"
|
958
|
-
@sampler.notice_push_scope "
|
960
|
+
@sampler.notice_push_scope "ac"
|
959
961
|
@sampler.notice_sql("SELECT * FROM sandwiches WHERE bread = 'french'", nil, 0)
|
960
|
-
@sampler.notice_pop_scope "
|
962
|
+
@sampler.notice_pop_scope "ac"
|
961
963
|
@sampler.notice_pop_scope "a"
|
962
964
|
@sampler.notice_scope_empty
|
963
965
|
end
|
964
|
-
|
965
966
|
end
|
metadata
CHANGED
@@ -1,14 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: newrelic_rpm
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
5
|
-
prerelease:
|
4
|
+
hash: 748706491
|
5
|
+
prerelease: 6
|
6
6
|
segments:
|
7
7
|
- 3
|
8
8
|
- 3
|
9
|
-
-
|
9
|
+
- 3
|
10
|
+
- beta
|
10
11
|
- 1
|
11
|
-
version: 3.3.
|
12
|
+
version: 3.3.3.beta1
|
12
13
|
platform: ruby
|
13
14
|
authors:
|
14
15
|
- Bill Kayser
|
@@ -19,7 +20,7 @@ autorequire:
|
|
19
20
|
bindir: bin
|
20
21
|
cert_chain: []
|
21
22
|
|
22
|
-
date: 2012-03-
|
23
|
+
date: 2012-03-14 00:00:00 Z
|
23
24
|
dependencies:
|
24
25
|
- !ruby/object:Gem::Dependency
|
25
26
|
name: jeweler
|
@@ -73,9 +74,9 @@ description: |
|
|
73
74
|
|
74
75
|
email: support@newrelic.com
|
75
76
|
executables:
|
76
|
-
- newrelic
|
77
77
|
- newrelic_cmd
|
78
78
|
- mongrel_rpm
|
79
|
+
- newrelic
|
79
80
|
extensions: []
|
80
81
|
|
81
82
|
extra_rdoc_files:
|
@@ -234,7 +235,6 @@ files:
|
|
234
235
|
- test/new_relic/agent/stats_engine/metric_stats_test.rb
|
235
236
|
- test/new_relic/agent/stats_engine/samplers_test.rb
|
236
237
|
- test/new_relic/agent/stats_engine_test.rb
|
237
|
-
- test/new_relic/agent/transaction_info_test.rb
|
238
238
|
- test/new_relic/agent/transaction_sample_builder_test.rb
|
239
239
|
- test/new_relic/agent/transaction_sampler_test.rb
|
240
240
|
- test/new_relic/agent/worker_loop_test.rb
|
@@ -1,13 +0,0 @@
|
|
1
|
-
require File.expand_path(File.join(File.dirname(__FILE__),'..','..','test_helper'))
|
2
|
-
require 'ostruct'
|
3
|
-
|
4
|
-
class NewRelic::Agent::TransactionInfoTest < Test::Unit::TestCase
|
5
|
-
def setup
|
6
|
-
@request = OpenStruct.new(:cookies => {'NRAGENT' => 'tk=1234<tag>evil</tag>5678'})
|
7
|
-
end
|
8
|
-
|
9
|
-
def test_get_token_gets_sanitized_token_from_cookie
|
10
|
-
assert_equal('1234<tag>evil</tag>5678',
|
11
|
-
NewRelic::Agent::TransactionInfo.get_token(@request))
|
12
|
-
end
|
13
|
-
end
|