newrelic_rpm 3.6.8.168 → 3.6.9.171
Sign up to get free protection for your applications and to get access to all the features.
- data.tar.gz.sig +0 -0
- data/.gitignore +1 -0
- data/.yardopts +17 -0
- data/CHANGELOG +48 -0
- data/README.md +8 -6
- data/lib/new_relic/agent.rb +65 -17
- data/lib/new_relic/agent/agent.rb +42 -113
- data/lib/new_relic/agent/browser_monitoring.rb +9 -1
- data/lib/new_relic/agent/configuration/default_source.rb +12 -0
- data/lib/new_relic/agent/error_collector.rb +13 -6
- data/lib/new_relic/agent/instrumentation/active_record_subscriber.rb +5 -5
- data/lib/new_relic/agent/instrumentation/controller_instrumentation.rb +15 -0
- data/lib/new_relic/agent/instrumentation/curb.rb +2 -2
- data/lib/new_relic/agent/instrumentation/metric_frame.rb +2 -2
- data/lib/new_relic/agent/instrumentation/rack.rb +2 -0
- data/lib/new_relic/agent/instrumentation/resque.rb +9 -3
- data/lib/new_relic/agent/instrumentation/sidekiq.rb +5 -0
- data/lib/new_relic/agent/method_tracer.rb +45 -27
- data/lib/new_relic/agent/new_relic_service.rb +14 -6
- data/lib/new_relic/agent/pipe_service.rb +1 -1
- data/lib/new_relic/agent/request_sampler.rb +10 -7
- data/lib/new_relic/agent/rules_engine.rb +5 -0
- data/lib/new_relic/agent/samplers/object_sampler.rb +1 -1
- data/lib/new_relic/agent/sql_sampler.rb +4 -2
- data/lib/new_relic/agent/stats_engine.rb +3 -0
- data/lib/new_relic/agent/stats_engine/gc_profiler.rb +17 -7
- data/lib/new_relic/agent/stats_engine/metric_stats.rb +5 -7
- data/lib/new_relic/agent/stats_engine/stats_hash.rb +2 -0
- data/lib/new_relic/agent/supported_versions.rb +247 -0
- data/lib/new_relic/agent/threading/backtrace_service.rb +1 -1
- data/lib/new_relic/agent/threading/thread_profile.rb +2 -1
- data/lib/new_relic/agent/transaction.rb +7 -6
- data/lib/new_relic/agent/transaction/developer_mode_sample_buffer.rb +11 -5
- data/lib/new_relic/agent/transaction/force_persist_sample_buffer.rb +3 -3
- data/lib/new_relic/agent/transaction/slowest_sample_buffer.rb +3 -3
- data/lib/new_relic/agent/transaction/transaction_sample_buffer.rb +23 -4
- data/lib/new_relic/agent/transaction/xray_sample_buffer.rb +4 -4
- data/lib/new_relic/agent/transaction_sampler.rb +14 -18
- data/lib/new_relic/agent/worker_loop.rb +1 -0
- data/lib/new_relic/control.rb +1 -0
- data/lib/new_relic/control/instance_methods.rb +0 -1
- data/lib/new_relic/helper.rb +1 -2
- data/lib/new_relic/language_support.rb +12 -2
- data/lib/new_relic/local_environment.rb +12 -11
- data/lib/new_relic/rack.rb +9 -0
- data/lib/new_relic/rack/agent_hooks.rb +6 -0
- data/lib/new_relic/rack/browser_monitoring.rb +9 -2
- data/lib/new_relic/rack/developer_mode.rb +15 -1
- data/lib/new_relic/rack/error_collector.rb +7 -0
- data/lib/new_relic/recipes.rb +2 -0
- data/lib/new_relic/transaction_sample.rb +39 -48
- data/lib/new_relic/version.rb +1 -1
- data/lib/tasks/install.rake +44 -2
- data/lib/tasks/versions.html.erb +31 -0
- data/lib/tasks/versions.rake +52 -0
- data/lib/tasks/versions.txt.erb +14 -0
- data/newrelic_rpm.gemspec +4 -2
- data/test/agent_helper.rb +21 -1
- data/test/environments/lib/environments/runner.rb +19 -5
- data/test/environments/norails/Gemfile +4 -1
- data/test/environments/rails21/Gemfile +4 -6
- data/test/environments/rails21/Rakefile +4 -0
- data/test/environments/rails21/config/database.yml +2 -7
- data/test/environments/rails22/Gemfile +6 -13
- data/test/environments/rails22/Rakefile +4 -0
- data/test/environments/rails22/config/database.yml +2 -7
- data/test/environments/rails22/config/environment.rb +1 -1
- data/test/environments/rails23/Gemfile +3 -4
- data/test/environments/rails23/Rakefile +4 -0
- data/test/environments/rails23/config/database.yml +2 -7
- data/test/environments/rails30/Gemfile +2 -4
- data/test/environments/rails30/Rakefile +2 -0
- data/test/environments/rails30/config/database.yml +2 -7
- data/test/environments/rails31/Gemfile +2 -4
- data/test/environments/rails31/Rakefile +2 -0
- data/test/environments/rails31/config/database.yml +2 -7
- data/test/environments/rails32/Gemfile +2 -5
- data/test/environments/rails32/Rakefile +2 -0
- data/test/environments/rails32/config/database.yml +1 -1
- data/test/environments/rails40/Gemfile +7 -4
- data/test/environments/rails40/Rakefile +2 -0
- data/test/environments/rails40/config/database.yml +2 -7
- data/test/helpers/runtime_detection.rb +17 -0
- data/test/multiverse/lib/multiverse/suite.rb +20 -4
- data/test/multiverse/suites/agent_only/key_transactions_test.rb +1 -1
- data/test/multiverse/suites/agent_only/marshaling_test.rb +1 -1
- data/test/multiverse/suites/agent_only/thread_profiling_test.rb +32 -7
- data/test/multiverse/suites/agent_only/xray_sessions_test.rb +1 -0
- data/test/multiverse/suites/config_file_loading/config_file_loading_test.rb +4 -3
- data/test/multiverse/suites/curb/curb_test.rb +8 -0
- data/test/multiverse/suites/excon/excon_test.rb +8 -0
- data/test/multiverse/suites/httpclient/httpclient_test.rb +8 -0
- data/test/multiverse/suites/net_http/net_http_test.rb +8 -0
- data/test/multiverse/suites/padrino/Envfile +3 -2
- data/test/multiverse/suites/rails/gc_instrumentation_test.rb +17 -8
- data/test/multiverse/suites/resque/Envfile +3 -3
- data/test/multiverse/suites/resque/instrumentation_test.rb +47 -5
- data/test/multiverse/suites/sequel/Envfile +0 -3
- data/test/multiverse/suites/sequel/database.rb +53 -0
- data/test/{new_relic/agent/instrumentation/sequel_test.rb → multiverse/suites/sequel/sequel_instrumentation_test.rb} +12 -53
- data/test/multiverse/suites/sequel/{sequel_test.rb → sequel_safety_test.rb} +2 -17
- data/test/multiverse/suites/sidekiq/sidekiq_instrumentation_test.rb +50 -5
- data/test/multiverse/suites/sinatra/sinatra_metric_explosion_test.rb +15 -2
- data/test/multiverse/suites/typhoeus/typhoeus_test.rb +8 -0
- data/test/new_relic/agent/agent/connect_test.rb +3 -2
- data/test/new_relic/agent/agent_test.rb +89 -82
- data/test/new_relic/agent/browser_monitoring_test.rb +44 -1
- data/test/new_relic/agent/error_collector_test.rb +17 -20
- data/test/new_relic/agent/instrumentation/active_record_instrumentation_test.rb +13 -10
- data/test/new_relic/agent/instrumentation/active_record_subscriber_test.rb +16 -1
- data/test/new_relic/agent/instrumentation/task_instrumentation_test.rb +2 -2
- data/test/new_relic/agent/method_tracer/instance_methods/trace_execution_scoped_test.rb +1 -1
- data/test/new_relic/agent/new_relic_service_test.rb +78 -9
- data/test/new_relic/agent/pipe_channel_manager_test.rb +7 -9
- data/test/new_relic/agent/pipe_service_test.rb +4 -4
- data/test/new_relic/agent/request_sampler_test.rb +2 -2
- data/test/new_relic/agent/stats_engine/gc_profiler_test.rb +15 -35
- data/test/new_relic/agent/stats_engine/metric_stats_test.rb +15 -7
- data/test/new_relic/agent/stats_engine_test.rb +4 -3
- data/test/new_relic/agent/threading/backtrace_service_test.rb +2 -0
- data/test/new_relic/agent/threading/thread_profile_test.rb +19 -0
- data/test/new_relic/agent/transaction/developer_mode_sample_buffer_test.rb +4 -4
- data/test/new_relic/agent/transaction/force_persist_sample_buffer_test.rb +1 -1
- data/test/new_relic/agent/transaction_sampler_test.rb +60 -45
- data/test/new_relic/fake_collector.rb +37 -2
- data/test/new_relic/http_client_test_cases.rb +26 -1
- data/test/new_relic/language_support_test.rb +12 -31
- data/test/new_relic/local_environment_test.rb +6 -2
- data/test/new_relic/multiverse_helpers.rb +2 -5
- data/test/new_relic/transaction_sample_test.rb +57 -36
- data/test/performance/suites/config.rb +76 -0
- data/test/rum/no_html_and_no_header.result.html +3 -0
- data/test/rum/no_html_and_no_header.source.html +3 -0
- data/test/script/ci.sh +0 -2
- data/test/test_helper.rb +5 -0
- metadata +43 -26
- metadata.gz.sig +0 -0
@@ -64,8 +64,21 @@ class SinatraMetricExplosionTest < MiniTest::Unit::TestCase
|
|
64
64
|
get '/another_controller'
|
65
65
|
|
66
66
|
metric_names = ::NewRelic::Agent.agent.stats_engine.metrics
|
67
|
-
metric_names -= [
|
68
|
-
|
67
|
+
metric_names -= [
|
68
|
+
'CPU/User Time',
|
69
|
+
"Middleware/all",
|
70
|
+
"WebFrontend/QueueTime",
|
71
|
+
"WebFrontend/WebServer/all",
|
72
|
+
]
|
73
|
+
|
74
|
+
name_beginnings_to_ignore = [
|
75
|
+
"Supportability",
|
76
|
+
"GC/cumulative"
|
77
|
+
]
|
78
|
+
metric_names.delete_if do|metric|
|
79
|
+
name_beginnings_to_ignore.any? {|name| metric.start_with?(name)}
|
80
|
+
end
|
81
|
+
|
69
82
|
assert_equal 6, metric_names.size, "Explosion detected in: #{metric_names.inspect}"
|
70
83
|
end
|
71
84
|
|
@@ -43,6 +43,14 @@ if NewRelic::Agent::Instrumentation::TyphoeusTracing.is_supported_version?
|
|
43
43
|
Typhoeus::Request.post(default_url, ssl_option.merge(:body => ""))
|
44
44
|
end
|
45
45
|
|
46
|
+
def put_response
|
47
|
+
Typhoeus::Request.put(default_url, ssl_option.merge(:body => ""))
|
48
|
+
end
|
49
|
+
|
50
|
+
def delete_response
|
51
|
+
Typhoeus::Request.delete(default_url, ssl_option)
|
52
|
+
end
|
53
|
+
|
46
54
|
def request_instance
|
47
55
|
NewRelic::Agent::HTTPClients::TyphoeusHTTPRequest.new(Typhoeus::Request.new("http://newrelic.com"))
|
48
56
|
end
|
@@ -18,6 +18,7 @@ class NewRelic::Agent::Agent::ConnectTest < Test::Unit::TestCase
|
|
18
18
|
@transaction_sampler = NewRelic::Agent::TransactionSampler.new
|
19
19
|
@sql_sampler = NewRelic::Agent::SqlSampler.new
|
20
20
|
@error_collector = NewRelic::Agent::ErrorCollector.new
|
21
|
+
@stats_engine = NewRelic::Agent::StatsEngine.new
|
21
22
|
server = NewRelic::Control::Server.new('localhost', 30303)
|
22
23
|
@service = NewRelic::Agent::NewRelicService.new('abcdef', server)
|
23
24
|
@test_config = { :developer_mode => true }
|
@@ -195,7 +196,7 @@ class NewRelic::Agent::Agent::ConnectTest < Test::Unit::TestCase
|
|
195
196
|
{ 'match_expression' => 'xx',
|
196
197
|
'replacement' => 'XX' } ]
|
197
198
|
}
|
198
|
-
finish_setup(config)
|
199
|
+
NewRelic::Agent.instance.finish_setup(config)
|
199
200
|
|
200
201
|
rules = NewRelic::Agent.instance.transaction_rules
|
201
202
|
assert_equal 2, rules.size
|
@@ -219,7 +220,7 @@ class NewRelic::Agent::Agent::ConnectTest < Test::Unit::TestCase
|
|
219
220
|
}
|
220
221
|
finish_setup(config)
|
221
222
|
|
222
|
-
rules =
|
223
|
+
rules = @stats_engine.metric_rules
|
223
224
|
assert_equal 2, rules.size
|
224
225
|
assert(rules.find{|r| r.match_expression == /77/ && r.replacement == '&&' },
|
225
226
|
"rule not found among #{rules}")
|
@@ -25,6 +25,12 @@ module NewRelic
|
|
25
25
|
assert_equal 123, @agent.service.channel_id
|
26
26
|
end
|
27
27
|
|
28
|
+
def test_after_fork_reporting_to_channel_should_not_collect_environment_report
|
29
|
+
@agent.stubs(:connected?).returns(true)
|
30
|
+
@agent.expects(:generate_environment_report).never
|
31
|
+
@agent.after_fork(:report_to_channel => 123)
|
32
|
+
end
|
33
|
+
|
28
34
|
def test_after_fork_should_close_pipe_if_parent_not_connected
|
29
35
|
pipe = mock
|
30
36
|
pipe.expects(:after_fork_in_child)
|
@@ -49,6 +55,20 @@ module NewRelic
|
|
49
55
|
end
|
50
56
|
end
|
51
57
|
|
58
|
+
def test_after_fork_should_reset_errors_collected
|
59
|
+
with_config(:monitor_mode => true) do
|
60
|
+
@agent.stubs(:connected?).returns(true)
|
61
|
+
|
62
|
+
errors = []
|
63
|
+
errors << NewRelic::NoticedError.new("", {}, Exception.new("boo"))
|
64
|
+
@agent.merge_data_from([{}, [], errors])
|
65
|
+
|
66
|
+
@agent.after_fork(:report_to_channel => 123)
|
67
|
+
|
68
|
+
assert_equal 0, @agent.error_collector.errors.length, "Still got errors collected in parent"
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
52
72
|
def test_transmit_data_should_emit_before_harvest_event
|
53
73
|
got_it = false
|
54
74
|
@agent.events.subscribe(:before_harvest) { got_it = true }
|
@@ -71,19 +91,7 @@ module NewRelic
|
|
71
91
|
@agent.instance_eval { transmit_data }
|
72
92
|
end
|
73
93
|
|
74
|
-
def
|
75
|
-
@agent.service.stubs(:metric_data).raises(EOFError)
|
76
|
-
expects_no_logging(:error)
|
77
|
-
expects_logging(:warn, regexp_matches(/EOFError/))
|
78
|
-
expects_logging(:debug, is_a(EOFError))
|
79
|
-
@agent.instance_eval { transmit_data }
|
80
|
-
end
|
81
|
-
|
82
|
-
def test_harvest_transaction_traces
|
83
|
-
assert_equal([], @agent.send(:harvest_transaction_traces), 'should return transaction traces')
|
84
|
-
end
|
85
|
-
|
86
|
-
def test_harvest_and_send_slowest_sample
|
94
|
+
def test_harvest_and_send_transaction_traces
|
87
95
|
with_config(:'transaction_tracer.explain_threshold' => 2,
|
88
96
|
:'transaction_tracer.explain_enabled' => true,
|
89
97
|
:'transaction_tracer.record_sql' => 'raw') do
|
@@ -92,11 +100,38 @@ module NewRelic
|
|
92
100
|
:transaction_name => nil,
|
93
101
|
:force_persist => true,
|
94
102
|
:truncate => 4000)
|
95
|
-
trace.expects(:prepare_to_send).with(:record_sql => :raw,
|
96
|
-
:explain_sql => 2
|
97
|
-
|
98
|
-
@agent.
|
99
|
-
@agent.send :
|
103
|
+
trace.expects(:prepare_to_send!).with(:record_sql => :raw,
|
104
|
+
:explain_sql => 2)
|
105
|
+
|
106
|
+
@agent.transaction_sampler.stubs(:harvest).returns([trace])
|
107
|
+
@agent.send :harvest_and_send_transaction_traces
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
def test_harvest_and_send_transaction_traces_merges_back_on_failure
|
112
|
+
traces = [mock('tt1'), mock('tt2')]
|
113
|
+
|
114
|
+
# make prepare_to_send just return self
|
115
|
+
traces.each { |tt| tt.expects(:prepare_to_send!).returns(tt) }
|
116
|
+
|
117
|
+
@agent.transaction_sampler.expects(:harvest).returns(traces)
|
118
|
+
@agent.service.stubs(:transaction_sample_data).raises("wat")
|
119
|
+
@agent.transaction_sampler.expects(:merge!).with(traces)
|
120
|
+
|
121
|
+
assert_nothing_raised do
|
122
|
+
@agent.send :harvest_and_send_transaction_traces
|
123
|
+
end
|
124
|
+
end
|
125
|
+
|
126
|
+
def test_harvest_and_send_errors_merges_back_on_failure
|
127
|
+
errors = [mock('e0'), mock('e1')]
|
128
|
+
|
129
|
+
@agent.error_collector.expects(:harvest_errors).returns(errors)
|
130
|
+
@agent.service.stubs(:error_data).raises('wat')
|
131
|
+
@agent.error_collector.expects(:merge!).with(errors)
|
132
|
+
|
133
|
+
assert_nothing_raised do
|
134
|
+
@agent.send :harvest_and_send_errors
|
100
135
|
end
|
101
136
|
end
|
102
137
|
|
@@ -131,10 +166,6 @@ module NewRelic
|
|
131
166
|
end
|
132
167
|
end
|
133
168
|
|
134
|
-
def test_harvest_errors
|
135
|
-
assert_equal([], @agent.send(:harvest_errors), 'should return errors')
|
136
|
-
end
|
137
|
-
|
138
169
|
def test_handle_for_agent_commands
|
139
170
|
@agent.service.expects(:get_agent_commands).returns([]).once
|
140
171
|
@agent.send :check_for_and_handle_agent_commands
|
@@ -147,67 +178,18 @@ module NewRelic
|
|
147
178
|
end
|
148
179
|
|
149
180
|
def test_merge_data_from_empty
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
@agent.
|
154
|
-
@unsent_errors = unsent_errors
|
155
|
-
@unsent_timeslice_data = unsent_timeslice_data
|
156
|
-
@traces = unsent_traces
|
157
|
-
}
|
158
|
-
# nb none of the others should receive merge requests
|
159
|
-
@agent.merge_data_from([{}])
|
160
|
-
end
|
161
|
-
|
162
|
-
def test_unsent_errors_size_empty
|
163
|
-
@agent.instance_eval {
|
164
|
-
@unsent_errors = nil
|
165
|
-
}
|
166
|
-
assert_equal(nil, @agent.unsent_errors_size)
|
167
|
-
end
|
168
|
-
|
169
|
-
def test_unsent_errors_size_with_errors
|
170
|
-
@agent.instance_eval {
|
171
|
-
@unsent_errors = ['an error']
|
172
|
-
}
|
173
|
-
assert_equal(1, @agent.unsent_errors_size)
|
174
|
-
end
|
175
|
-
|
176
|
-
def test_unsent_traces_size_empty
|
177
|
-
@agent.instance_eval {
|
178
|
-
@traces = nil
|
179
|
-
}
|
180
|
-
assert_equal(nil, @agent.unsent_traces_size)
|
181
|
-
end
|
182
|
-
|
183
|
-
def test_unsent_traces_size_with_traces
|
184
|
-
@agent.instance_eval {
|
185
|
-
@traces = ['a trace']
|
186
|
-
}
|
187
|
-
assert_equal(1, @agent.unsent_traces_size)
|
188
|
-
end
|
189
|
-
|
190
|
-
def test_unsent_timeslice_data_empty
|
191
|
-
@agent.instance_eval {
|
192
|
-
@unsent_timeslice_data = nil
|
193
|
-
}
|
194
|
-
assert_equal(0, @agent.unsent_timeslice_data, "should have zero timeslice data to start")
|
195
|
-
assert_equal({}, @agent.instance_variable_get('@unsent_timeslice_data'), "should initialize the timeslice data to an empty hash if it is empty")
|
196
|
-
end
|
197
|
-
|
198
|
-
def test_unsent_timeslice_data_with_errors
|
199
|
-
@agent.instance_eval {
|
200
|
-
@unsent_timeslice_data = {:key => 'value'}
|
201
|
-
}
|
202
|
-
assert_equal(1, @agent.unsent_timeslice_data, "should have the key from above")
|
181
|
+
@agent.stats_engine.expects(:merge!).never
|
182
|
+
@agent.error_collector.expects(:merge!).never
|
183
|
+
@agent.transaction_sampler.expects(:merge!).never
|
184
|
+
@agent.merge_data_from([])
|
203
185
|
end
|
204
186
|
|
205
187
|
def test_merge_data_traces
|
206
|
-
|
188
|
+
transaction_sampler = mock('transaction sampler')
|
207
189
|
@agent.instance_eval {
|
208
|
-
@
|
190
|
+
@transaction_sampler = transaction_sampler
|
209
191
|
}
|
210
|
-
|
192
|
+
transaction_sampler.expects(:merge!).with([1,2,3])
|
211
193
|
@agent.merge_data_from([{}, [1,2,3], []])
|
212
194
|
end
|
213
195
|
|
@@ -230,7 +212,7 @@ module NewRelic
|
|
230
212
|
samples = [mock('some analytics event')]
|
231
213
|
|
232
214
|
request_sampler.expects(:harvest).returns(samples)
|
233
|
-
request_sampler.expects(:merge).with(samples)
|
215
|
+
request_sampler.expects(:merge!).with(samples)
|
234
216
|
|
235
217
|
# simulate a failure in transmitting analytics events
|
236
218
|
service.stubs(:analytic_event_data).raises(StandardError.new)
|
@@ -240,6 +222,18 @@ module NewRelic
|
|
240
222
|
end
|
241
223
|
end
|
242
224
|
|
225
|
+
def test_harvest_and_send_timeslice_data_merges_back_on_failure
|
226
|
+
timeslices = mock('timeslices')
|
227
|
+
|
228
|
+
@agent.stats_engine.expects(:harvest).returns(timeslices)
|
229
|
+
@agent.service.stubs(:metric_data).raises('wat')
|
230
|
+
@agent.stats_engine.expects(:merge!).with(timeslices)
|
231
|
+
|
232
|
+
assert_nothing_raised do
|
233
|
+
@agent.send(:harvest_and_send_timeslice_data)
|
234
|
+
end
|
235
|
+
end
|
236
|
+
|
243
237
|
def test_connect_retries_on_timeout
|
244
238
|
service = @agent.service
|
245
239
|
service.stubs(:connect).raises(Timeout::Error).then.returns(nil)
|
@@ -286,8 +280,9 @@ module NewRelic
|
|
286
280
|
@agent.send(:connect, :force_reconnect => true)
|
287
281
|
end
|
288
282
|
|
289
|
-
def
|
290
|
-
NewRelic::
|
283
|
+
def test_defer_start_if_resque_dispatcher_and_channel_manager_isnt_started_and_forkable
|
284
|
+
NewRelic::LanguageSupport.stubs(:can_fork?).returns(true)
|
285
|
+
NewRelic::Agent::PipeChannelManager.listener.stubs(:started?).returns(false)
|
291
286
|
|
292
287
|
# :send_data_on_exit setting to avoid setting an at_exit
|
293
288
|
with_config( :send_data_on_exit => false, :dispatcher => :resque ) do
|
@@ -298,7 +293,19 @@ module NewRelic
|
|
298
293
|
end
|
299
294
|
|
300
295
|
def test_doesnt_defer_start_if_resque_dispatcher_and_channel_manager_started
|
301
|
-
NewRelic::Agent::PipeChannelManager.listener.
|
296
|
+
NewRelic::Agent::PipeChannelManager.listener.stubs(:started?).returns(true)
|
297
|
+
|
298
|
+
# :send_data_on_exit setting to avoid setting an at_exit
|
299
|
+
with_config( :send_data_on_exit => false, :dispatcher => :resque ) do
|
300
|
+
@agent.start
|
301
|
+
end
|
302
|
+
|
303
|
+
assert @agent.started?
|
304
|
+
end
|
305
|
+
|
306
|
+
def test_doesnt_defer_start_for_resque_if_non_forking_platform
|
307
|
+
NewRelic::LanguageSupport.stubs(:can_fork?).returns(false)
|
308
|
+
NewRelic::Agent::PipeChannelManager.listener.stubs(:started?).returns(false)
|
302
309
|
|
303
310
|
# :send_data_on_exit setting to avoid setting an at_exit
|
304
311
|
with_config( :send_data_on_exit => false, :dispatcher => :resque ) do
|
@@ -107,6 +107,30 @@ class NewRelic::Agent::BrowserMonitoringTest < Test::Unit::TestCase
|
|
107
107
|
assert_equal "", header
|
108
108
|
end
|
109
109
|
|
110
|
+
def test_browser_timing_header_with_loader_without_js_errors_beta
|
111
|
+
with_config(:js_agent_loader => 'loader') do
|
112
|
+
header = browser_timing_header
|
113
|
+
assert_equal("<script type=\"text/javascript\">var NREUMQ=NREUMQ||[];NREUMQ.push([\"mark\",\"firstbyte\",new Date().getTime()]);</script>", header,
|
114
|
+
"expected old RUM header but saw '#{header}'")
|
115
|
+
end
|
116
|
+
end
|
117
|
+
|
118
|
+
def test_browser_timing_header_with_js_errors_beta_without_loader
|
119
|
+
with_config(:js_errors_beta => true) do
|
120
|
+
header = browser_timing_header
|
121
|
+
assert_equal("<script type=\"text/javascript\">var NREUMQ=NREUMQ||[];NREUMQ.push([\"mark\",\"firstbyte\",new Date().getTime()]);</script>", header,
|
122
|
+
"expected old RUM header but saw '#{header}'")
|
123
|
+
end
|
124
|
+
end
|
125
|
+
|
126
|
+
def test_browser_timing_header_with_js_errors_beta_and_loader
|
127
|
+
with_config(:js_errors_beta => true, :js_agent_loader => 'loader') do
|
128
|
+
header = browser_timing_header
|
129
|
+
assert_equal("\n<script type=\"text/javascript\">loader</script>", header,
|
130
|
+
"expected new JS agent loader 'loader' but saw '#{header}'")
|
131
|
+
end
|
132
|
+
end
|
133
|
+
|
110
134
|
def test_browser_timing_footer
|
111
135
|
with_config(:license_key => 'a' * 13) do
|
112
136
|
NewRelic::Agent::TransactionState.reset
|
@@ -139,7 +163,7 @@ var e=document.createElement("script");'
|
|
139
163
|
end
|
140
164
|
end
|
141
165
|
|
142
|
-
def
|
166
|
+
def setup_beacon_config
|
143
167
|
NewRelic::Agent::TransactionState.reset
|
144
168
|
browser_timing_header
|
145
169
|
|
@@ -148,6 +172,11 @@ var e=document.createElement("script");'
|
|
148
172
|
config = NewRelic::Agent::BeaconConfiguration.new
|
149
173
|
config.expects(:license_bytes).returns(license_bytes).at_least_once
|
150
174
|
NewRelic::Agent.instance.stubs(:beacon_configuration).returns(config).at_least_once
|
175
|
+
end
|
176
|
+
|
177
|
+
def test_browser_timing_footer_with_rum_enabled_not_specified
|
178
|
+
setup_beacon_config
|
179
|
+
|
151
180
|
footer = browser_timing_footer
|
152
181
|
beginning_snippet = '<script type="text/javascript">if (typeof NREUMQ !== "undefined") { if (!NREUMQ.f) { NREUMQ.f=function() {
|
153
182
|
NREUMQ.push(["load",new Date().getTime()]);
|
@@ -210,6 +239,20 @@ var e=document.createElement("script");'
|
|
210
239
|
end
|
211
240
|
end
|
212
241
|
|
242
|
+
def test_browser_timing_footer_with_js_errors_beta_and_loader
|
243
|
+
with_config(:js_errors_beta => true, :js_agent_loader => 'loader') do
|
244
|
+
setup_beacon_config
|
245
|
+
|
246
|
+
footer = browser_timing_footer
|
247
|
+
beginning_snippet = "\n<script type=\"text/javascript\">window.NREUM||(NREUM={});NREUM.info={\""
|
248
|
+
ending_snippet = '}</script>'
|
249
|
+
assert(footer.include?(beginning_snippet),
|
250
|
+
"expected footer to include beginning snippet: '#{beginning_snippet}', but was '#{footer}'")
|
251
|
+
assert(footer.include?(ending_snippet),
|
252
|
+
"expected footer to include ending snippet: '#{ending_snippet}', but was '#{footer}'")
|
253
|
+
end
|
254
|
+
end
|
255
|
+
|
213
256
|
def test_browser_monitoring_transaction_name_basic
|
214
257
|
txn = NewRelic::Agent::Transaction.new
|
215
258
|
txn.name = 'a transaction name'
|
@@ -22,14 +22,14 @@ class NewRelic::Agent::ErrorCollectorTest < Test::Unit::TestCase
|
|
22
22
|
end
|
23
23
|
|
24
24
|
def test_empty
|
25
|
-
@error_collector.harvest_errors
|
25
|
+
@error_collector.harvest_errors
|
26
26
|
@error_collector.notice_error(nil, :metric=> 'path', :request_params => {:x => 'y'})
|
27
|
-
errors = @error_collector.harvest_errors
|
27
|
+
errors = @error_collector.harvest_errors
|
28
28
|
|
29
29
|
assert_equal 0, errors.length
|
30
30
|
|
31
31
|
@error_collector.notice_error('Some error message', :metric=> 'path', :request_params => {:x => 'y'})
|
32
|
-
errors = @error_collector.harvest_errors
|
32
|
+
errors = @error_collector.harvest_errors
|
33
33
|
|
34
34
|
err = errors.first
|
35
35
|
assert_equal 'Some error message', err.message
|
@@ -44,8 +44,7 @@ class NewRelic::Agent::ErrorCollectorTest < Test::Unit::TestCase
|
|
44
44
|
def test_simple
|
45
45
|
@error_collector.notice_error(StandardError.new("message"), :uri => '/myurl/', :metric => 'path', :referer => 'test_referer', :request_params => {:x => 'y'})
|
46
46
|
|
47
|
-
|
48
|
-
errors = @error_collector.harvest_errors(old_errors)
|
47
|
+
errors = @error_collector.harvest_errors
|
49
48
|
|
50
49
|
assert_equal errors.length, 1
|
51
50
|
|
@@ -60,7 +59,7 @@ class NewRelic::Agent::ErrorCollectorTest < Test::Unit::TestCase
|
|
60
59
|
|
61
60
|
# the collector should now return an empty array since nothing
|
62
61
|
# has been added since its last harvest
|
63
|
-
errors = @error_collector.harvest_errors
|
62
|
+
errors = @error_collector.harvest_errors
|
64
63
|
assert errors.length == 0
|
65
64
|
end
|
66
65
|
|
@@ -69,8 +68,7 @@ class NewRelic::Agent::ErrorCollectorTest < Test::Unit::TestCase
|
|
69
68
|
#still 1 byte / char.
|
70
69
|
@error_collector.notice_error(StandardError.new("1234567890" * 500), :uri => '/myurl/', :metric => 'path', :request_params => {:x => 'y'})
|
71
70
|
|
72
|
-
|
73
|
-
errors = @error_collector.harvest_errors(old_errors)
|
71
|
+
errors = @error_collector.harvest_errors
|
74
72
|
|
75
73
|
assert_equal errors.length, 1
|
76
74
|
|
@@ -82,22 +80,22 @@ class NewRelic::Agent::ErrorCollectorTest < Test::Unit::TestCase
|
|
82
80
|
def test_collect_failover
|
83
81
|
@error_collector.notice_error(StandardError.new("message"), :metric => 'first', :request_params => {:x => 'y'})
|
84
82
|
|
85
|
-
errors = @error_collector.harvest_errors
|
83
|
+
errors = @error_collector.harvest_errors
|
86
84
|
|
87
85
|
@error_collector.notice_error(StandardError.new("message"), :metric => 'second', :request_params => {:x => 'y'})
|
88
86
|
@error_collector.notice_error(StandardError.new("message"), :metric => 'path', :request_params => {:x => 'y'})
|
89
87
|
@error_collector.notice_error(StandardError.new("message"), :metric => 'last', :request_params => {:x => 'y'})
|
90
88
|
|
91
|
-
|
89
|
+
@error_collector.merge!(errors)
|
90
|
+
errors = @error_collector.harvest_errors
|
92
91
|
|
93
92
|
assert_equal 4, errors.length
|
94
|
-
|
95
|
-
assert_equal 'last', errors.last.path
|
93
|
+
assert_equal_unordered(%w(first second path last), errors.map { |e| e.path })
|
96
94
|
|
97
95
|
@error_collector.notice_error(StandardError.new("message"), :metric => 'first', :request_params => {:x => 'y'})
|
98
96
|
@error_collector.notice_error(StandardError.new("message"), :metric => 'last', :request_params => {:x => 'y'})
|
99
97
|
|
100
|
-
errors = @error_collector.harvest_errors
|
98
|
+
errors = @error_collector.harvest_errors
|
101
99
|
assert_equal 2, errors.length
|
102
100
|
assert_equal 'first', errors.first.path
|
103
101
|
assert_equal 'last', errors.last.path
|
@@ -113,7 +111,7 @@ class NewRelic::Agent::ErrorCollectorTest < Test::Unit::TestCase
|
|
113
111
|
end
|
114
112
|
end
|
115
113
|
|
116
|
-
errors = @error_collector.harvest_errors
|
114
|
+
errors = @error_collector.harvest_errors
|
117
115
|
assert errors.length == max_q_length
|
118
116
|
errors.each_index do |i|
|
119
117
|
err = errors.shift
|
@@ -140,7 +138,7 @@ class NewRelic::Agent::ErrorCollectorTest < Test::Unit::TestCase
|
|
140
138
|
types.each do |test|
|
141
139
|
@error_collector.notice_error(StandardError.new("message"), :metric => 'path',
|
142
140
|
:request_params => {:x => test[0]})
|
143
|
-
assert_equal test[1], @error_collector.harvest_errors
|
141
|
+
assert_equal test[1], @error_collector.harvest_errors[0].params[:request_params][:x]
|
144
142
|
end
|
145
143
|
end
|
146
144
|
|
@@ -150,7 +148,7 @@ class NewRelic::Agent::ErrorCollectorTest < Test::Unit::TestCase
|
|
150
148
|
|
151
149
|
@error_collector.notice_error(IOError.new("message"), :metric => 'path', :request_params => {:x => 'y'})
|
152
150
|
|
153
|
-
errors = @error_collector.harvest_errors
|
151
|
+
errors = @error_collector.harvest_errors
|
154
152
|
|
155
153
|
assert_equal 0, errors.length
|
156
154
|
end
|
@@ -161,7 +159,7 @@ class NewRelic::Agent::ErrorCollectorTest < Test::Unit::TestCase
|
|
161
159
|
NewRelic::Agent.config.apply_config(:'error_collector.ignore_errors' => "IOError")
|
162
160
|
@error_collector.notice_error(IOError.new("message"))
|
163
161
|
|
164
|
-
errors = @error_collector.harvest_errors
|
162
|
+
errors = @error_collector.harvest_errors
|
165
163
|
|
166
164
|
assert_equal 1, errors.length
|
167
165
|
|
@@ -173,7 +171,7 @@ class NewRelic::Agent::ErrorCollectorTest < Test::Unit::TestCase
|
|
173
171
|
@error_collector.notice_error(IOError.new("message"), :metric => 'path', :request_params => {:x => 'y'})
|
174
172
|
@error_collector.notice_error(StandardError.new("message"), :metric => 'path', :request_params => {:x => 'y'})
|
175
173
|
|
176
|
-
errors = @error_collector.harvest_errors
|
174
|
+
errors = @error_collector.harvest_errors
|
177
175
|
|
178
176
|
assert_equal 1, errors.length
|
179
177
|
end
|
@@ -183,8 +181,7 @@ class NewRelic::Agent::ErrorCollectorTest < Test::Unit::TestCase
|
|
183
181
|
@error_collector.notice_error(StandardError.new("YO SQL BAD: serect * flom test where foo = 'bar'"))
|
184
182
|
@error_collector.notice_error(StandardError.new("YO SQL BAD: serect * flom test where foo in (1,2,3,4,5)"))
|
185
183
|
|
186
|
-
|
187
|
-
errors = @error_collector.harvest_errors([])
|
184
|
+
errors = @error_collector.harvest_errors
|
188
185
|
|
189
186
|
assert_equal(NewRelic::NoticedError::STRIPPED_EXCEPTION_REPLACEMENT_MESSAGE, errors[0].message)
|
190
187
|
assert_equal(NewRelic::NoticedError::STRIPPED_EXCEPTION_REPLACEMENT_MESSAGE, errors[1].message)
|