newrelic_rpm 3.6.7.159 → 3.6.8.164
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +14 -0
- data/lib/new_relic/agent/agent.rb +38 -35
- data/lib/new_relic/agent/agent_logger.rb +6 -47
- data/lib/new_relic/agent/beacon_configuration.rb +10 -4
- data/lib/new_relic/agent/browser_monitoring.rb +39 -33
- data/lib/new_relic/agent/commands/agent_command.rb +4 -4
- data/lib/new_relic/agent/commands/agent_command_router.rb +72 -10
- data/lib/new_relic/agent/commands/thread_profiler_session.rb +110 -0
- data/lib/new_relic/agent/commands/xray_session.rb +55 -0
- data/lib/new_relic/agent/commands/xray_session_collection.rb +158 -0
- data/lib/new_relic/agent/configuration/default_source.rb +61 -24
- data/lib/new_relic/agent/configuration/mask_defaults.rb +2 -2
- data/lib/new_relic/agent/configuration/server_source.rb +1 -1
- data/lib/new_relic/agent/instrumentation/action_controller_subscriber.rb +2 -0
- data/lib/new_relic/agent/instrumentation/controller_instrumentation.rb +4 -10
- data/lib/new_relic/agent/instrumentation/rails3/action_controller.rb +10 -11
- data/lib/new_relic/agent/memory_logger.rb +52 -0
- data/lib/new_relic/agent/new_relic_service.rb +4 -0
- data/lib/new_relic/agent/request_sampler.rb +32 -13
- data/lib/new_relic/agent/samplers/cpu_sampler.rb +6 -3
- data/lib/new_relic/agent/threading/agent_thread.rb +2 -1
- data/lib/new_relic/agent/threading/backtrace_node.rb +80 -27
- data/lib/new_relic/agent/threading/backtrace_service.rb +264 -0
- data/lib/new_relic/agent/threading/thread_profile.rb +79 -118
- data/lib/new_relic/agent/transaction/developer_mode_sample_buffer.rb +56 -0
- data/lib/new_relic/agent/transaction/force_persist_sample_buffer.rb +25 -0
- data/lib/new_relic/agent/transaction/slowest_sample_buffer.rb +25 -0
- data/lib/new_relic/agent/transaction/transaction_sample_buffer.rb +86 -0
- data/lib/new_relic/agent/transaction/xray_sample_buffer.rb +64 -0
- data/lib/new_relic/agent/transaction.rb +25 -4
- data/lib/new_relic/agent/transaction_sample_builder.rb +6 -10
- data/lib/new_relic/agent/transaction_sampler.rb +47 -202
- data/lib/new_relic/agent/worker_loop.rb +47 -39
- data/lib/new_relic/agent.rb +1 -1
- data/lib/new_relic/build.rb +2 -2
- data/lib/new_relic/coerce.rb +8 -0
- data/lib/new_relic/control/instance_methods.rb +1 -0
- data/lib/new_relic/rack/browser_monitoring.rb +15 -1
- data/lib/new_relic/rack/developer_mode.rb +1 -1
- data/lib/new_relic/transaction_sample.rb +20 -5
- data/lib/new_relic/version.rb +1 -1
- data/newrelic.yml +4 -6
- data/newrelic_rpm.gemspec +1 -1
- data/test/agent_helper.rb +11 -0
- data/test/environments/lib/environments/runner.rb +5 -1
- data/test/environments/rails21/Gemfile +2 -2
- data/test/environments/rails22/Gemfile +2 -2
- data/test/environments/rails23/Gemfile +2 -2
- data/test/environments/rails31/Gemfile +2 -2
- data/test/environments/rails32/Gemfile +2 -2
- data/test/multiverse/suites/agent_only/marshaling_test.rb +1 -1
- data/test/multiverse/suites/agent_only/testing_app.rb +6 -0
- data/test/multiverse/suites/agent_only/thread_profiling_test.rb +5 -5
- data/test/multiverse/suites/agent_only/xray_sessions_test.rb +163 -0
- data/test/multiverse/suites/rails/request_statistics_test.rb +2 -2
- data/test/multiverse/suites/rails/view_instrumentation_test.rb +20 -21
- data/test/new_relic/agent/agent/connect_test.rb +0 -10
- data/test/new_relic/agent/agent_test.rb +27 -44
- data/test/new_relic/agent/browser_monitoring_test.rb +0 -52
- data/test/new_relic/agent/commands/agent_command_router_test.rb +150 -12
- data/test/new_relic/agent/commands/{thread_profiler_test.rb → thread_profiler_session_test.rb} +58 -19
- data/test/new_relic/agent/commands/xray_session_collection_test.rb +332 -0
- data/test/new_relic/agent/commands/xray_session_test.rb +42 -0
- data/test/new_relic/agent/configuration/manager_test.rb +2 -1
- data/test/new_relic/agent/configuration/server_source_test.rb +10 -10
- data/test/new_relic/agent/cpu_sampler_test.rb +50 -0
- data/test/new_relic/agent/instrumentation/action_controller_subscriber_test.rb +31 -0
- data/test/new_relic/agent/instrumentation/queue_time_test.rb +0 -1
- data/test/new_relic/agent/instrumentation/sequel_test.rb +1 -1
- data/test/new_relic/agent/instrumentation/task_instrumentation_test.rb +0 -1
- data/test/new_relic/agent/memory_logger_test.rb +53 -0
- data/test/new_relic/agent/new_relic_service_test.rb +1 -1
- data/test/new_relic/agent/pipe_channel_manager_test.rb +4 -5
- data/test/new_relic/agent/request_sampler_test.rb +70 -20
- data/test/new_relic/agent/rules_engine_test.rb +6 -0
- data/test/new_relic/agent/threading/agent_thread_test.rb +2 -2
- data/test/new_relic/agent/threading/backtrace_node_test.rb +110 -17
- data/test/new_relic/agent/threading/backtrace_service_test.rb +567 -0
- data/test/new_relic/agent/threading/fake_thread.rb +4 -0
- data/test/new_relic/agent/threading/thread_profile_test.rb +141 -217
- data/test/new_relic/agent/threading/threaded_test_case.rb +3 -8
- data/test/new_relic/agent/transaction/developer_mode_sample_buffer_test.rb +69 -0
- data/test/new_relic/agent/transaction/force_persist_sample_buffer_test.rb +52 -0
- data/test/new_relic/agent/transaction/slowest_sample_buffer_test.rb +67 -0
- data/test/new_relic/agent/transaction/xray_sample_buffer_test.rb +71 -0
- data/test/new_relic/agent/transaction_sampler_test.rb +171 -307
- data/test/new_relic/agent/transaction_test.rb +33 -5
- data/test/new_relic/agent/worker_loop_test.rb +33 -11
- data/test/new_relic/coerce_test.rb +13 -0
- data/test/new_relic/fake_collector.rb +26 -3
- data/test/new_relic/multiverse_helpers.rb +2 -0
- data/test/new_relic/rack/browser_monitoring_test.rb +12 -0
- data/test/new_relic/rack/developer_mode_test.rb +2 -2
- data/test/new_relic/transaction_sample_test.rb +19 -2
- data/test/performance/lib/performance/console_reporter.rb +1 -1
- data/test/performance/lib/performance/test_case.rb +7 -3
- data/test/performance/script/runner +3 -0
- data/test/performance/suites/thread_profiling.rb +83 -0
- data/test/test_helper.rb +2 -2
- data.tar.gz.sig +0 -0
- metadata +32 -32
- metadata.gz.sig +1 -1
- data/lib/new_relic/agent/commands/thread_profiler.rb +0 -80
@@ -4,16 +4,18 @@
|
|
4
4
|
|
5
5
|
require File.expand_path(File.join(File.dirname(__FILE__),'..','..','..','test_helper'))
|
6
6
|
|
7
|
+
require 'new_relic/agent/threading/backtrace_service'
|
7
8
|
require 'new_relic/agent/threading/thread_profile'
|
8
9
|
require 'new_relic/agent/threading/threaded_test_case'
|
9
10
|
|
10
|
-
if NewRelic::Agent::
|
11
|
+
if NewRelic::Agent::Threading::BacktraceService.is_supported?
|
11
12
|
|
12
13
|
module NewRelic::Agent::Threading
|
13
|
-
class ThreadProfileTest <
|
14
|
+
class ThreadProfileTest < Test::Unit::TestCase
|
15
|
+
include ThreadedTestCase
|
14
16
|
|
15
17
|
def setup
|
16
|
-
|
18
|
+
setup_fake_threads
|
17
19
|
|
18
20
|
@single_trace = [
|
19
21
|
"irb.rb:69:in `catch'",
|
@@ -21,286 +23,208 @@ if NewRelic::Agent::Commands::ThreadProfiler.is_supported?
|
|
21
23
|
"irb:12:in `<main>'"
|
22
24
|
]
|
23
25
|
|
24
|
-
@profile = ThreadProfile.new
|
26
|
+
@profile = ThreadProfile.new
|
25
27
|
|
26
28
|
# Run the worker_loop for the thread profile based on two iterations
|
27
29
|
# This takes time fussiness out of the equation and keeps the tests stable
|
28
30
|
@profile.instance_variable_set(:@worker_loop, NewRelic::Agent::WorkerLoop.new(:limit => 2))
|
29
31
|
end
|
30
32
|
|
31
|
-
|
32
|
-
|
33
|
-
FakeThread.list << FakeThread.new
|
34
|
-
FakeThread.list << FakeThread.new
|
35
|
-
|
36
|
-
@profile.run
|
37
|
-
|
38
|
-
assert_equal 2, @profile.poll_count
|
39
|
-
assert_equal 4, @profile.sample_count
|
33
|
+
def teardown
|
34
|
+
teardown_fake_threads
|
40
35
|
end
|
41
36
|
|
42
|
-
def
|
43
|
-
|
44
|
-
:bucket => :request,
|
45
|
-
:backtrace => @single_trace)
|
46
|
-
|
47
|
-
@profile.run
|
48
|
-
|
49
|
-
assert_equal 1, @profile.traces[:request].size
|
37
|
+
def target_for_shared_client_tests
|
38
|
+
@profile
|
50
39
|
end
|
51
40
|
|
52
|
-
def
|
53
|
-
|
54
|
-
:bucket => :background,
|
55
|
-
:backtrace => @single_trace)
|
41
|
+
def test_prune_tree
|
42
|
+
@profile.aggregate(@single_trace, :request, Thread.current)
|
56
43
|
|
57
|
-
|
44
|
+
@profile.truncate_to_node_count!(1)
|
58
45
|
|
59
|
-
|
46
|
+
assert_equal 0, @profile.traces[:request].children.first.children.size
|
60
47
|
end
|
61
48
|
|
62
|
-
def
|
63
|
-
|
64
|
-
|
65
|
-
|
49
|
+
def test_prune_keeps_highest_counts
|
50
|
+
@profile.aggregate(@single_trace, :request, Thread.current)
|
51
|
+
@profile.aggregate(@single_trace, :other, Thread.current)
|
52
|
+
@profile.aggregate(@single_trace, :other, Thread.current)
|
66
53
|
|
67
|
-
|
54
|
+
@profile.truncate_to_node_count!(1)
|
68
55
|
|
69
|
-
|
56
|
+
assert_empty @profile.traces[:request]
|
57
|
+
assert_equal 1, @profile.traces[:other].children.size
|
58
|
+
assert_equal [], @profile.traces[:other].children.first.children
|
70
59
|
end
|
71
60
|
|
72
|
-
def
|
73
|
-
|
74
|
-
|
75
|
-
:backtrace => @single_trace)
|
61
|
+
def test_prune_keeps_highest_count_then_depths
|
62
|
+
@profile.aggregate(@single_trace, :request, Thread.current)
|
63
|
+
@profile.aggregate(@single_trace, :other, Thread.current)
|
76
64
|
|
77
|
-
|
65
|
+
@profile.truncate_to_node_count!(2)
|
78
66
|
|
79
|
-
|
67
|
+
assert_equal 1, @profile.traces[:request].children.size
|
68
|
+
assert_equal 1, @profile.traces[:other].children.size
|
69
|
+
assert_equal [], @profile.traces[:request].children.first.children
|
70
|
+
assert_equal [], @profile.traces[:other].children.first.children
|
80
71
|
end
|
81
72
|
|
82
|
-
def
|
83
|
-
|
84
|
-
:bucket => :ignore,
|
85
|
-
:backtrace => @single_trace)
|
86
|
-
|
87
|
-
@profile.run
|
88
|
-
|
89
|
-
@profile.traces.each do |key, trace|
|
90
|
-
assert trace.empty?, "Trace :#{key} should have been empty"
|
91
|
-
end
|
92
|
-
end
|
73
|
+
def build_well_known_trace(args={})
|
74
|
+
@profile = ThreadProfile.new(args)
|
93
75
|
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
:backtrace => @single_trace,
|
98
|
-
:scrubbed_backtrace => @single_trace[0..0])
|
76
|
+
thread = stub
|
77
|
+
trace = ["thread_profiler.py:1:in `<module>'"]
|
78
|
+
10.times { @profile.aggregate(trace, :other, thread) }
|
99
79
|
|
100
|
-
|
80
|
+
thread = stub
|
81
|
+
trace = [
|
82
|
+
"/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/threading.py:489:in `__bootstrap'",
|
83
|
+
"/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/threading.py:512:in `__bootstrap_inner'",
|
84
|
+
"/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/threading.py:480:in `run'",
|
85
|
+
"thread_profiler.py:76:in `_profiler_loop'",
|
86
|
+
"thread_profiler.py:103:in `_run_profiler'",
|
87
|
+
"thread_profiler.py:165:in `collect_thread_stacks'"
|
88
|
+
]
|
89
|
+
10.times { @profile.aggregate(trace, :agent, thread) }
|
101
90
|
|
102
|
-
|
91
|
+
@profile.increment_poll_count
|
103
92
|
end
|
104
93
|
|
105
|
-
|
106
|
-
# Can't easily stop in middle of processing since FakeThread's synchronous
|
107
|
-
# Mark to bail immediately, then see we didn't record anything
|
108
|
-
@profile.stop
|
109
|
-
|
110
|
-
@profile.run
|
111
|
-
|
112
|
-
assert_not_nil @profile.stop_time
|
113
|
-
assert_equal true, @profile.finished?
|
94
|
+
WELL_KNOWN_TRACE_ENCODED = "eJy9klFPwjAUhf/LfW7WDQTUGBPUiYkGdAxelqXZRpGGrm1uS8xi/O924JQX\n9Un7dm77ndN7c19hlt7FCZxnWQZug7xYMYN6LSTHwDRA4KLWq53kl0CinEQh\nCUmW5zmBJH5axPPUk16MJ/E0/cGk0lLyyrGPS+uKamu943DQeX5HMtypz5In\nwv6vRCeZ1NoAGQ2PCDpvrOM1fRAlFtjQWyxq/qJxa+lj4zZaBeuuQpccrdDK\n0l4wolKU1OxftOoQLNTzIdL/EcjJafjnQYyVWjvrsDBMKNVOZBD1/jO27fPs\naBG+DoGr8fX9JJktpjftVry9A9unzGo=\n"
|
114
95
|
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
end
|
96
|
+
def test_to_collector_array
|
97
|
+
build_well_known_trace('profile_id' => 333)
|
98
|
+
@profile.stubs(:created_at).returns(1350403938892.524)
|
99
|
+
@profile.finished_at = 1350403939904.375
|
120
100
|
|
121
|
-
|
122
|
-
|
101
|
+
expected = [
|
102
|
+
333,
|
103
|
+
1350403938892.524,
|
104
|
+
1350403939904.375,
|
105
|
+
1,
|
106
|
+
WELL_KNOWN_TRACE_ENCODED,
|
107
|
+
2,
|
108
|
+
0
|
109
|
+
]
|
123
110
|
|
124
|
-
|
125
|
-
assert_not_nil @profile.stop_time
|
111
|
+
assert_equal expected, @profile.to_collector_array(encoder)
|
126
112
|
end
|
127
113
|
|
128
|
-
def
|
129
|
-
|
130
|
-
|
131
|
-
@profile.
|
114
|
+
def test_to_collector_array_with_xray_session_id
|
115
|
+
build_well_known_trace('profile_id' => -1, 'x_ray_id' => 4242)
|
116
|
+
@profile.stubs(:created_at).returns(1350403938892.524)
|
117
|
+
@profile.finished_at = 1350403939904.375
|
132
118
|
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
119
|
+
expected = [
|
120
|
+
-1,
|
121
|
+
1350403938892.524,
|
122
|
+
1350403939904.375,
|
123
|
+
20,
|
124
|
+
WELL_KNOWN_TRACE_ENCODED,
|
125
|
+
2,
|
126
|
+
0,
|
127
|
+
4242
|
142
128
|
]
|
143
129
|
|
144
|
-
|
145
|
-
assert_equal({ :method => 'catch',
|
146
|
-
:file => '/Users/jclark/.rbenv/versions/1.9.3-p194/lib/ruby/1.9.1/irb.rb',
|
147
|
-
:line_no => 69 }, result[0])
|
148
|
-
assert_equal({ :method => 'start',
|
149
|
-
:file => '/Users/jclark/.rbenv/versions/1.9.3-p194/lib/ruby/1.9.1/irb.rb',
|
150
|
-
:line_no => 69 }, result[1])
|
151
|
-
assert_equal({ :method => '<main>',
|
152
|
-
:file => '/Users/jclark/.rbenv/versions/1.9.3/bin/irb',
|
153
|
-
:line_no => 12 }, result[2])
|
154
|
-
end
|
155
|
-
|
156
|
-
def test_aggregate_empty_trace
|
157
|
-
result = @profile.aggregate([])
|
158
|
-
assert_nil result
|
159
|
-
end
|
160
|
-
|
161
|
-
def test_aggregate_nil_trace
|
162
|
-
result = @profile.aggregate(nil)
|
163
|
-
assert_nil result
|
130
|
+
assert_equal expected, @profile.to_collector_array(encoder)
|
164
131
|
end
|
165
132
|
|
166
|
-
def
|
167
|
-
|
133
|
+
def test_to_collector_array_with_bad_values
|
134
|
+
build_well_known_trace(:profile_id => -1)
|
135
|
+
@profile.stubs(:created_at).returns('')
|
136
|
+
@profile.finished_at = nil
|
137
|
+
@profile.instance_variable_set(:@poll_count, Rational(10, 1))
|
138
|
+
@profile.instance_variable_set(:@backtrace_count, nil)
|
139
|
+
@profile.instance_variable_set(:@unique_threads, nil)
|
168
140
|
|
169
|
-
|
170
|
-
|
171
|
-
|
141
|
+
expected = [
|
142
|
+
-1,
|
143
|
+
0.0,
|
144
|
+
0.0,
|
145
|
+
10,
|
146
|
+
WELL_KNOWN_TRACE_ENCODED,
|
147
|
+
0,
|
148
|
+
0
|
149
|
+
]
|
172
150
|
|
173
|
-
assert_equal
|
151
|
+
assert_equal expected, @profile.to_collector_array(encoder)
|
174
152
|
end
|
175
153
|
|
176
|
-
def
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
tree = BacktraceNode.new(@single_trace[-1])
|
181
|
-
tree.runnable_count += 1
|
182
|
-
child = BacktraceNode.new(@single_trace[-2], tree)
|
183
|
-
child.runnable_count += 1
|
184
|
-
grand = BacktraceNode.new(@single_trace[-3], child)
|
185
|
-
grand.runnable_count += 1
|
154
|
+
def test_aggregate_should_increment_only_backtrace_count
|
155
|
+
backtrace_count = @profile.backtrace_count
|
156
|
+
failure_count = @profile.failure_count
|
157
|
+
@profile.aggregate(@single_trace, :request, Thread.current)
|
186
158
|
|
187
|
-
assert_equal
|
159
|
+
assert_equal backtrace_count + 1, @profile.backtrace_count
|
160
|
+
assert_equal failure_count, @profile.failure_count
|
188
161
|
end
|
189
162
|
|
190
|
-
def
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
"irb:12:in `<main>'"
|
195
|
-
]
|
163
|
+
def test_aggregate_increments_only_the_failure_count_with_nil_backtrace
|
164
|
+
backtrace_count = @profile.backtrace_count
|
165
|
+
failure_count = @profile.failure_count
|
166
|
+
@profile.aggregate(nil, :request, Thread.current)
|
196
167
|
|
197
|
-
|
198
|
-
|
168
|
+
assert_equal backtrace_count, @profile.backtrace_count
|
169
|
+
assert_equal failure_count + 1, @profile.failure_count
|
170
|
+
end
|
199
171
|
|
200
|
-
|
201
|
-
|
172
|
+
def test_aggregate_updates_created_at_timestamp
|
173
|
+
expected = freeze_time
|
174
|
+
@profile = ThreadProfile.new
|
202
175
|
|
203
|
-
|
204
|
-
|
176
|
+
@profile.aggregate(@single_trace, :request, Thread.current)
|
177
|
+
t0 = @profile.created_at
|
205
178
|
|
206
|
-
|
207
|
-
|
179
|
+
advance_time(5.0)
|
180
|
+
@profile.aggregate(@single_trace, :request, Thread.current)
|
208
181
|
|
209
|
-
assert_equal
|
182
|
+
assert_equal expected, t0
|
183
|
+
assert_equal expected, @profile.created_at
|
210
184
|
end
|
211
185
|
|
212
|
-
def
|
213
|
-
|
186
|
+
def test_aggregate_keeps_unique_thread_count
|
187
|
+
thread0 = stub
|
188
|
+
thread1 = stub
|
214
189
|
|
215
|
-
|
190
|
+
@profile.aggregate(@single_trace, :request, thread0)
|
191
|
+
@profile.aggregate(@single_trace, :request, thread0)
|
192
|
+
@profile.aggregate(@single_trace, :request, thread1)
|
216
193
|
|
217
|
-
assert_equal
|
194
|
+
assert_equal 2, @profile.unique_thread_count
|
218
195
|
end
|
219
196
|
|
220
|
-
|
221
|
-
@profile.aggregate(@single_trace, @profile.traces[:request])
|
222
|
-
@profile.aggregate(@single_trace, @profile.traces[:other])
|
223
|
-
@profile.aggregate(@single_trace, @profile.traces[:other])
|
197
|
+
SAMPLE_COUNT_POSITION = 3
|
224
198
|
|
225
|
-
|
199
|
+
def test_sample_count_for_thread_profiling
|
200
|
+
profile = ThreadProfile.new('x_ray_id' => nil)
|
201
|
+
profile.increment_poll_count
|
226
202
|
|
227
|
-
|
228
|
-
assert_equal 1,
|
229
|
-
assert_equal [], @profile.traces[:other][0].children
|
203
|
+
result = profile.to_collector_array(encoder)
|
204
|
+
assert_equal 1, result[SAMPLE_COUNT_POSITION]
|
230
205
|
end
|
231
206
|
|
232
|
-
def
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
@profile.prune!(2)
|
207
|
+
def test_sample_count_for_xrays
|
208
|
+
profile = ThreadProfile.new('x_ray_id' => 123)
|
209
|
+
profile.aggregate(@single_trace, :request, Thread.current)
|
237
210
|
|
238
|
-
|
239
|
-
assert_equal 1,
|
240
|
-
assert_equal [], @profile.traces[:request][0].children
|
241
|
-
assert_equal [], @profile.traces[:other][0].children
|
211
|
+
result = profile.to_collector_array(encoder)
|
212
|
+
assert_equal 1, result[SAMPLE_COUNT_POSITION]
|
242
213
|
end
|
243
214
|
|
244
|
-
def
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
trace = [
|
249
|
-
"/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/threading.py:489:in `__bootstrap'",
|
250
|
-
"/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/threading.py:512:in `__bootstrap_inner'",
|
251
|
-
"/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/threading.py:480:in `run'",
|
252
|
-
"thread_profiler.py:76:in `_profiler_loop'",
|
253
|
-
"thread_profiler.py:103:in `_run_profiler'",
|
254
|
-
"thread_profiler.py:165:in `collect_thread_stacks'"]
|
255
|
-
10.times { @profile.aggregate(trace, @profile.traces[:agent]) }
|
215
|
+
def test_empty
|
216
|
+
profile = ThreadProfile.new
|
217
|
+
assert profile.empty?
|
256
218
|
end
|
257
219
|
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
@profile.instance_variable_set(:@start_time, 1350403938892.524)
|
263
|
-
@profile.instance_variable_set(:@stop_time, 1350403939904.375)
|
264
|
-
@profile.instance_variable_set(:@poll_count, 10)
|
265
|
-
@profile.instance_variable_set(:@sample_count, 2)
|
266
|
-
|
267
|
-
build_well_known_trace
|
268
|
-
|
269
|
-
expected = [[
|
270
|
-
-1,
|
271
|
-
1350403938892.524,
|
272
|
-
1350403939904.375,
|
273
|
-
10,
|
274
|
-
WELL_KNOWN_TRACE_ENCODED,
|
275
|
-
2,
|
276
|
-
0
|
277
|
-
]]
|
278
|
-
|
279
|
-
marshaller = NewRelic::Agent::NewRelicService::JsonMarshaller.new
|
280
|
-
assert_equal expected, @profile.to_collector_array(marshaller.default_encoder)
|
220
|
+
def test_not_empty
|
221
|
+
profile = ThreadProfile.new
|
222
|
+
profile.aggregate([], :request, Thread.current)
|
223
|
+
assert_false profile.empty?
|
281
224
|
end
|
282
225
|
|
283
|
-
def
|
284
|
-
|
285
|
-
@profile.instance_variable_set(:@start_time, "")
|
286
|
-
@profile.instance_variable_set(:@stop_time, nil)
|
287
|
-
@profile.instance_variable_set(:@poll_count, Rational(10, 1))
|
288
|
-
@profile.instance_variable_set(:@sample_count, nil)
|
289
|
-
|
290
|
-
build_well_known_trace
|
291
|
-
|
292
|
-
expected = [[
|
293
|
-
-1,
|
294
|
-
0.0,
|
295
|
-
0.0,
|
296
|
-
10,
|
297
|
-
WELL_KNOWN_TRACE_ENCODED,
|
298
|
-
0,
|
299
|
-
0
|
300
|
-
]]
|
301
|
-
|
302
|
-
marshaller = NewRelic::Agent::NewRelicService::JsonMarshaller.new
|
303
|
-
assert_equal expected, @profile.to_collector_array(marshaller.default_encoder)
|
226
|
+
def encoder
|
227
|
+
NewRelic::Agent::NewRelicService::JsonMarshaller.new.default_encoder
|
304
228
|
end
|
305
229
|
end
|
306
230
|
|