newrelic_rpm 3.7.1.188 → 3.7.2.190.beta
Sign up to get free protection for your applications and to get access to all the features.
- data.tar.gz.sig +3 -2
- data/CHANGELOG +1 -1
- data/Guardfile +3 -3
- data/README.md +1 -1
- data/Rakefile +0 -2
- data/init.rb +2 -5
- data/lib/new_relic/agent.rb +3 -0
- data/lib/new_relic/agent/agent.rb +2 -0
- data/lib/new_relic/agent/configuration/default_source.rb +32 -14
- data/lib/new_relic/agent/configuration/environment_source.rb +1 -0
- data/lib/new_relic/agent/cross_app_monitor.rb +2 -2
- data/lib/new_relic/agent/cross_app_tracing.rb +2 -2
- data/lib/new_relic/agent/error_collector.rb +1 -1
- data/lib/new_relic/agent/http_clients/typhoeus_wrappers.rb +4 -1
- data/lib/new_relic/agent/instrumentation/action_controller_subscriber.rb +10 -8
- data/lib/new_relic/agent/instrumentation/action_view_subscriber.rb +11 -6
- data/lib/new_relic/agent/javascript_instrumentor.rb +27 -36
- data/lib/new_relic/agent/method_tracer.rb +20 -2
- data/lib/new_relic/agent/new_relic_service.rb +35 -27
- data/lib/new_relic/agent/request_sampler.rb +20 -13
- data/lib/new_relic/agent/sampler_collection.rb +4 -0
- data/lib/new_relic/agent/stats_engine/stats_hash.rb +4 -4
- data/lib/new_relic/agent/system_info.rb +25 -15
- data/lib/new_relic/agent/transaction.rb +23 -4
- data/lib/new_relic/agent/transaction_sampler.rb +1 -1
- data/lib/new_relic/cli/install.rb +1 -1
- data/lib/new_relic/control.rb +1 -0
- data/lib/new_relic/helper.rb +1 -29
- data/lib/new_relic/json_wrapper.rb +92 -0
- data/lib/new_relic/language_support.rb +4 -0
- data/lib/new_relic/rack/agent_hooks.rb +4 -0
- data/lib/new_relic/rack/browser_monitoring.rb +4 -0
- data/lib/new_relic/rack/developer_mode.rb +4 -1
- data/lib/new_relic/rack/error_collector.rb +5 -0
- data/lib/new_relic/rack/transaction_reset.rb +20 -0
- data/lib/new_relic/version.rb +1 -1
- data/lib/tasks/install.rake +0 -1
- data/newrelic_rpm.gemspec +1 -1
- data/test/agent_helper.rb +7 -8
- data/test/environments/norails/Gemfile +2 -1
- data/test/environments/rails21/Gemfile +2 -2
- data/test/environments/rails21/config/environment.rb +1 -3
- data/test/environments/rails21/config/environments/development.rb +0 -6
- data/test/environments/rails22/Gemfile +2 -2
- data/test/environments/rails22/config/environment.rb +0 -2
- data/test/environments/rails22/config/environments/development.rb +0 -6
- data/test/environments/rails23/Gemfile +2 -3
- data/test/environments/rails23/config/environment.rb +0 -9
- data/test/environments/rails23/config/environments/development.rb +0 -5
- data/test/environments/rails30/Gemfile +2 -2
- data/test/environments/rails31/Gemfile +2 -2
- data/test/environments/rails32/Gemfile +2 -1
- data/test/environments/rails40/Gemfile +2 -1
- data/test/intentional_fail.rb +1 -2
- data/test/multiverse/lib/multiverse/envfile.rb +1 -5
- data/test/multiverse/lib/multiverse/suite.rb +10 -27
- data/test/multiverse/suites/active_record/ar_method_aliasing.rb +49 -67
- data/test/multiverse/suites/agent_only/encoding_handling_test.rb +128 -0
- data/test/multiverse/suites/agent_only/marshaling_test.rb +7 -9
- data/test/multiverse/suites/agent_only/script/loading.rb +20 -0
- data/test/multiverse/suites/agent_only/start_up_test.rb +7 -0
- data/test/multiverse/suites/bare/Envfile +3 -0
- data/test/multiverse/suites/bare/standalone_instrumentation_test.rb +43 -0
- data/test/multiverse/suites/rails/Envfile +0 -2
- data/test/multiverse/suites/rails/app/views/views/_a_partial.html.erb +1 -0
- data/test/multiverse/suites/rails/app/views/views/index.html.erb +1 -1
- data/test/multiverse/suites/rails/error_tracing_test.rb +1 -1
- data/test/multiverse/suites/rails/request_statistics_test.rb +9 -4
- data/test/multiverse/suites/rails/view_instrumentation_test.rb +111 -106
- data/test/multiverse/suites/typhoeus/Envfile +1 -1
- data/test/multiverse/suites/typhoeus/typhoeus_test.rb +16 -2
- data/test/multiverse/test/multiverse_test.rb +2 -2
- data/test/new_relic/agent/agent/connect_test.rb +1 -1
- data/test/new_relic/agent/agent/start_test.rb +1 -1
- data/test/new_relic/agent/agent/start_worker_thread_test.rb +1 -1
- data/test/new_relic/agent/agent_logger_test.rb +3 -7
- data/test/new_relic/agent/agent_test.rb +33 -57
- data/test/new_relic/agent/apdex_from_server_test.rb +1 -1
- data/test/new_relic/agent/audit_logger_test.rb +5 -8
- data/test/new_relic/agent/autostart_test.rb +1 -1
- data/test/new_relic/agent/browser_token_test.rb +1 -1
- data/test/new_relic/agent/busy_calculator_test.rb +2 -4
- data/test/new_relic/agent/commands/agent_command_router_test.rb +5 -5
- data/test/new_relic/agent/commands/agent_command_test.rb +1 -1
- data/test/new_relic/agent/commands/thread_profiler_session_test.rb +6 -6
- data/test/new_relic/agent/commands/xray_session_collection_test.rb +10 -10
- data/test/new_relic/agent/commands/xray_session_test.rb +1 -1
- data/test/new_relic/agent/configuration/default_source_test.rb +4 -4
- data/test/new_relic/agent/configuration/environment_source_test.rb +14 -2
- data/test/new_relic/agent/configuration/manager_test.rb +3 -3
- data/test/new_relic/agent/configuration/orphan_configuration_test.rb +1 -1
- data/test/new_relic/agent/configuration/server_source_test.rb +1 -1
- data/test/new_relic/agent/configuration/yaml_source_test.rb +2 -2
- data/test/new_relic/agent/cpu_sampler_test.rb +1 -1
- data/test/new_relic/agent/cross_app_monitor_test.rb +3 -3
- data/test/new_relic/agent/cross_app_tracing_test.rb +5 -4
- data/test/new_relic/agent/database_test.rb +1 -1
- data/test/new_relic/agent/datastores/mongo/metric_generator_test.rb +1 -1
- data/test/new_relic/agent/datastores/mongo/metric_translator_test.rb +1 -1
- data/test/new_relic/agent/datastores/mongo/obfuscator_test.rb +1 -1
- data/test/new_relic/agent/datastores/mongo/statement_formatter_test.rb +2 -2
- data/test/new_relic/agent/error_collector/notice_error_test.rb +1 -1
- data/test/new_relic/agent/error_collector_test.rb +5 -3
- data/test/new_relic/agent/event_listener_test.rb +1 -1
- data/test/new_relic/agent/harvester_test.rb +1 -1
- data/test/new_relic/agent/http_clients/uri_util_test.rb +1 -1
- data/test/new_relic/agent/instrumentation/action_controller_subscriber_test.rb +1 -1
- data/test/new_relic/agent/instrumentation/action_view_subscriber_test.rb +1 -1
- data/test/new_relic/agent/instrumentation/active_record_helper_test.rb +1 -1
- data/test/new_relic/agent/instrumentation/active_record_instrumentation_test.rb +495 -495
- data/test/new_relic/agent/instrumentation/active_record_subscriber_test.rb +2 -2
- data/test/new_relic/agent/instrumentation/controller_instrumentation_test.rb +1 -1
- data/test/new_relic/agent/instrumentation/instrumentation_test.rb +1 -1
- data/test/new_relic/agent/instrumentation/metric_frame_test.rb +1 -1
- data/test/new_relic/agent/instrumentation/net_instrumentation_test.rb +4 -6
- data/test/new_relic/agent/instrumentation/queue_time_test.rb +1 -1
- data/test/new_relic/agent/instrumentation/rack_test.rb +1 -1
- data/test/new_relic/agent/instrumentation/sinatra/transaction_namer_test.rb +1 -1
- data/test/new_relic/agent/instrumentation/sinatra_test.rb +1 -1
- data/test/new_relic/agent/instrumentation/task_instrumentation_test.rb +7 -7
- data/test/new_relic/agent/javascript_instrumentor_test.rb +47 -55
- data/test/new_relic/agent/memcache_instrumentation_test.rb +1 -1
- data/test/new_relic/agent/memory_logger_test.rb +1 -1
- data/test/new_relic/agent/method_interrobang_test.rb +2 -3
- data/test/new_relic/agent/method_tracer/class_methods/add_method_tracer_test.rb +4 -4
- data/test/new_relic/agent/method_tracer/instance_methods/trace_execution_scoped_test.rb +1 -1
- data/test/new_relic/agent/method_tracer_test.rb +6 -7
- data/test/new_relic/agent/method_visibility_test.rb +1 -1
- data/test/new_relic/agent/new_relic_service_test.rb +129 -19
- data/test/new_relic/agent/obfuscator_test.rb +1 -1
- data/test/new_relic/agent/pipe_channel_manager_test.rb +143 -145
- data/test/new_relic/agent/pipe_service_test.rb +2 -4
- data/test/new_relic/agent/request_sampler_test.rb +23 -19
- data/test/new_relic/agent/rpm_agent_test.rb +3 -3
- data/test/new_relic/agent/rules_engine_test.rb +1 -1
- data/test/new_relic/agent/sampled_buffer_test.rb +1 -1
- data/test/new_relic/agent/sampler_collection_test.rb +3 -3
- data/test/new_relic/agent/sampler_test.rb +1 -1
- data/test/new_relic/agent/shim_agent_test.rb +1 -1
- data/test/new_relic/agent/sql_sampler_test.rb +4 -6
- data/test/new_relic/agent/stats_engine/gc_profiler_test.rb +1 -1
- data/test/new_relic/agent/stats_engine/metric_stats_test.rb +5 -5
- data/test/new_relic/agent/stats_engine/samplers_test.rb +2 -2
- data/test/new_relic/agent/stats_engine_test.rb +3 -3
- data/test/new_relic/agent/stats_hash_test.rb +2 -2
- data/test/new_relic/agent/stats_test.rb +1 -1
- data/test/new_relic/agent/threading/agent_thread_test.rb +2 -4
- data/test/new_relic/agent/threading/backtrace_node_test.rb +1 -1
- data/test/new_relic/agent/threading/backtrace_service_test.rb +5 -5
- data/test/new_relic/agent/threading/thread_profile_test.rb +1 -1
- data/test/new_relic/agent/transaction/developer_mode_sample_buffer_test.rb +1 -1
- data/test/new_relic/agent/transaction/force_persist_sample_buffer_test.rb +1 -1
- data/test/new_relic/agent/transaction/pop_test.rb +1 -1
- data/test/new_relic/agent/transaction/slowest_sample_buffer_test.rb +1 -1
- data/test/new_relic/agent/transaction/xray_sample_buffer_test.rb +1 -1
- data/test/new_relic/agent/transaction_interrobang_test.rb +2 -3
- data/test/new_relic/agent/transaction_sample_builder_test.rb +16 -14
- data/test/new_relic/agent/transaction_sampler_test.rb +16 -21
- data/test/new_relic/agent/transaction_state_test.rb +1 -1
- data/test/new_relic/agent/transaction_test.rb +61 -1
- data/test/new_relic/agent/transaction_timings_test.rb +1 -1
- data/test/new_relic/agent/worker_loop_test.rb +1 -1
- data/test/new_relic/agent_test.rb +2 -3
- data/test/new_relic/cli/deployments_test.rb +3 -3
- data/test/new_relic/coerce_test.rb +1 -1
- data/test/new_relic/collection_helper_test.rb +1 -1
- data/test/new_relic/control/class_methods_test.rb +2 -2
- data/test/new_relic/control/frameworks/rails_test.rb +1 -1
- data/test/new_relic/control_test.rb +9 -4
- data/test/new_relic/dependency_detection_test.rb +1 -1
- data/test/new_relic/dispatcher_test.rb +1 -1
- data/test/new_relic/environment_report_test.rb +4 -6
- data/test/new_relic/fake_collector.rb +1 -158
- data/test/new_relic/framework_test.rb +2 -1
- data/test/new_relic/http_client_test_cases.rb +2 -3
- data/test/new_relic/json_wrapper_test.rb +77 -0
- data/test/new_relic/language_support_test.rb +1 -1
- data/test/new_relic/license_test.rb +2 -2
- data/test/new_relic/load_test.rb +2 -8
- data/test/new_relic/local_environment_test.rb +1 -1
- data/test/new_relic/metric_data_test.rb +1 -1
- data/test/new_relic/metric_parser/metric_parser_test.rb +1 -1
- data/test/new_relic/metric_spec_test.rb +1 -1
- data/test/new_relic/multiverse_helpers.rb +26 -30
- data/test/new_relic/noticed_error_test.rb +1 -1
- data/test/new_relic/rack/agent_hooks_test.rb +1 -1
- data/test/new_relic/rack/all_test.rb +1 -1
- data/test/new_relic/rack/browser_monitoring_test.rb +4 -2
- data/test/new_relic/rack/deferred_instrumentation_test.rb +3 -5
- data/test/new_relic/rack/developer_mode_helper_test.rb +1 -1
- data/test/new_relic/rack/developer_mode_test.rb +1 -1
- data/test/new_relic/rack/error_collector_test.rb +8 -8
- data/test/new_relic/rack/transaction_reset_test.rb +35 -0
- data/test/new_relic/transaction_analysis/segment_summary_test.rb +2 -2
- data/test/new_relic/transaction_analysis_test.rb +1 -1
- data/test/new_relic/transaction_sample/composite_segment_test.rb +1 -1
- data/test/new_relic/transaction_sample/fake_segment_test.rb +2 -4
- data/test/new_relic/transaction_sample/segment_test.rb +3 -7
- data/test/new_relic/transaction_sample/summary_segment_test.rb +1 -1
- data/test/new_relic/transaction_sample_subtest_test.rb +1 -1
- data/test/new_relic/transaction_sample_test.rb +4 -6
- data/test/new_relic/version_number_test.rb +1 -1
- data/test/performance/lib/performance/instrumentation/gc_stats.rb +1 -1
- data/test/performance/lib/performance/json_reporter.rb +1 -1
- data/test/performance/suites/marshalling.rb +76 -0
- data/test/test_helper.rb +6 -39
- metadata +19 -12
- metadata.gz.sig +0 -0
- data/test/new_relic/helper_test.rb +0 -32
@@ -7,7 +7,7 @@ if defined?(::Rails)
|
|
7
7
|
require File.expand_path(File.join(File.dirname(__FILE__),'..','..','..','test_helper'))
|
8
8
|
require 'new_relic/agent/instrumentation/action_controller_subscriber'
|
9
9
|
|
10
|
-
class NewRelic::Agent::Instrumentation::ActionControllerSubscriberTest <
|
10
|
+
class NewRelic::Agent::Instrumentation::ActionControllerSubscriberTest < MiniTest::Unit::TestCase
|
11
11
|
class TestController
|
12
12
|
include NewRelic::Agent::Instrumentation::ControllerInstrumentation
|
13
13
|
|
@@ -7,7 +7,7 @@ if defined?(::Rails)
|
|
7
7
|
require File.expand_path(File.join(File.dirname(__FILE__),'..','..','..','test_helper'))
|
8
8
|
require 'new_relic/agent/instrumentation/action_view_subscriber'
|
9
9
|
|
10
|
-
class NewRelic::Agent::Instrumentation::ActionViewSubscriberTest <
|
10
|
+
class NewRelic::Agent::Instrumentation::ActionViewSubscriberTest < MiniTest::Unit::TestCase
|
11
11
|
def setup
|
12
12
|
@subscriber = NewRelic::Agent::Instrumentation::ActionViewSubscriber.new
|
13
13
|
@stats_engine = NewRelic::Agent.instance.stats_engine
|
@@ -4,7 +4,7 @@
|
|
4
4
|
require File.expand_path(File.join(File.dirname(__FILE__),'..','..','..','test_helper'))
|
5
5
|
require 'new_relic/agent/instrumentation/active_record_helper'
|
6
6
|
|
7
|
-
class NewRelic::Agent::Instrumentation::ActiveRecordHelperTest <
|
7
|
+
class NewRelic::Agent::Instrumentation::ActiveRecordHelperTest < MiniTest::Unit::TestCase
|
8
8
|
include NewRelic::Agent::Instrumentation
|
9
9
|
|
10
10
|
def test_metric_for_name_find
|
@@ -6,7 +6,7 @@ if defined?(::Rails)
|
|
6
6
|
|
7
7
|
require File.expand_path(File.join(File.dirname(__FILE__),'..','..','..','test_helper'))
|
8
8
|
|
9
|
-
class NewRelic::Agent::Instrumentation::ActiveRecordInstrumentationTest <
|
9
|
+
class NewRelic::Agent::Instrumentation::ActiveRecordInstrumentationTest < MiniTest::Unit::TestCase
|
10
10
|
require 'active_record_fixtures'
|
11
11
|
include NewRelic::Agent::Instrumentation::ControllerInstrumentation
|
12
12
|
|
@@ -78,499 +78,499 @@ class NewRelic::Agent::Instrumentation::ActiveRecordInstrumentationTest < Test::
|
|
78
78
|
end
|
79
79
|
end
|
80
80
|
|
81
|
-
def test_metric_names_jruby
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
end
|
110
|
-
|
111
|
-
def test_metric_names_sqlite
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
end
|
139
|
-
|
140
|
-
def test_metric_names_standard
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
end
|
184
|
-
|
185
|
-
def test_join_metrics_jruby
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
end
|
220
|
-
|
221
|
-
def test_join_metrics_sqlite
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
end
|
258
|
-
|
259
|
-
def test_join_metrics_standard
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
end
|
299
|
-
|
300
|
-
def test_direct_sql
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
end
|
320
|
-
|
321
|
-
def test_other_sql
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
end
|
336
|
-
|
337
|
-
def test_show_sql
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
end
|
349
|
-
|
350
|
-
def test_blocked_instrumentation
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
end
|
361
|
-
|
362
|
-
def test_run_explains
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
end
|
373
|
-
|
374
|
-
def test_prepare_to_send
|
375
|
-
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
|
396
|
-
|
397
|
-
|
398
|
-
|
399
|
-
|
400
|
-
|
401
|
-
end
|
402
|
-
|
403
|
-
def test_transaction_mysql
|
404
|
-
|
405
|
-
|
406
|
-
|
407
|
-
|
408
|
-
|
409
|
-
|
410
|
-
|
411
|
-
|
412
|
-
|
413
|
-
|
414
|
-
|
415
|
-
|
416
|
-
|
417
|
-
|
418
|
-
|
419
|
-
|
420
|
-
|
421
|
-
|
422
|
-
|
423
|
-
|
424
|
-
|
425
|
-
|
426
|
-
|
427
|
-
|
428
|
-
|
429
|
-
|
430
|
-
|
431
|
-
|
432
|
-
|
433
|
-
|
434
|
-
end
|
435
|
-
|
436
|
-
def test_transaction_postgres
|
437
|
-
|
438
|
-
|
439
|
-
|
440
|
-
|
441
|
-
|
442
|
-
|
443
|
-
|
444
|
-
|
445
|
-
|
446
|
-
|
447
|
-
|
448
|
-
|
449
|
-
|
450
|
-
|
451
|
-
|
452
|
-
|
453
|
-
|
454
|
-
|
455
|
-
|
456
|
-
|
457
|
-
|
458
|
-
|
459
|
-
|
460
|
-
|
461
|
-
|
462
|
-
|
463
|
-
|
464
|
-
|
465
|
-
|
466
|
-
end
|
467
|
-
|
468
|
-
def test_transaction_other
|
469
|
-
|
470
|
-
|
471
|
-
|
472
|
-
|
473
|
-
|
474
|
-
|
475
|
-
|
476
|
-
|
477
|
-
|
478
|
-
|
479
|
-
|
480
|
-
|
481
|
-
|
482
|
-
|
483
|
-
|
484
|
-
|
485
|
-
|
486
|
-
|
487
|
-
|
488
|
-
end
|
489
|
-
|
490
|
-
|
491
|
-
if NewRelic::Control.instance.rails_version >= NewRelic::VersionNumber.new("2.1.0")
|
492
|
-
|
493
|
-
|
494
|
-
|
495
|
-
|
496
|
-
|
497
|
-
|
498
|
-
|
499
|
-
|
500
|
-
|
501
|
-
|
502
|
-
|
503
|
-
|
504
|
-
|
505
|
-
|
506
|
-
|
507
|
-
|
508
|
-
|
509
|
-
|
510
|
-
|
511
|
-
|
512
|
-
|
513
|
-
|
514
|
-
|
515
|
-
|
516
|
-
end
|
517
|
-
|
518
|
-
|
519
|
-
def test_error_handling
|
520
|
-
|
521
|
-
|
522
|
-
|
523
|
-
|
524
|
-
|
525
|
-
|
526
|
-
|
527
|
-
|
528
|
-
|
529
|
-
|
530
|
-
|
531
|
-
|
532
|
-
|
533
|
-
|
534
|
-
|
535
|
-
|
536
|
-
|
537
|
-
|
538
|
-
|
539
|
-
|
540
|
-
|
541
|
-
|
542
|
-
|
543
|
-
end
|
544
|
-
|
545
|
-
def test_rescue_handling
|
546
|
-
|
547
|
-
|
548
|
-
|
549
|
-
|
550
|
-
|
551
|
-
|
552
|
-
|
553
|
-
|
554
|
-
|
555
|
-
|
556
|
-
end
|
557
|
-
|
558
|
-
def test_remote_service_metric_respects_dynamic_connection_config
|
559
|
-
|
560
|
-
|
561
|
-
|
562
|
-
|
563
|
-
|
564
|
-
|
565
|
-
|
566
|
-
|
567
|
-
|
568
|
-
|
569
|
-
|
570
|
-
|
571
|
-
|
572
|
-
|
573
|
-
end
|
81
|
+
#def test_metric_names_jruby
|
82
|
+
# # fails due to a bug in rails 3 - log does not provide the correct
|
83
|
+
# # transaction type - it returns 'SQL' instead of 'Foo Create', for example.
|
84
|
+
# return if rails3? || !defined?(JRuby)
|
85
|
+
# expected = %W[
|
86
|
+
# ActiveRecord/all
|
87
|
+
# ActiveRecord/find
|
88
|
+
# ActiveRecord/ActiveRecordFixtures::Order/find
|
89
|
+
# Database/SQL/insert
|
90
|
+
# RemoteService/sql/#{adapter}/localhost
|
91
|
+
# ]
|
92
|
+
|
93
|
+
# if NewRelic::Control.instance.rails_version < '2.1.0'
|
94
|
+
# expected += %W[ActiveRecord/save ActiveRecord/ActiveRecordFixtures::Order/save]
|
95
|
+
# end
|
96
|
+
|
97
|
+
# assert_calls_metrics(*expected) do
|
98
|
+
# m = ActiveRecordFixtures::Order.create :id => 0, :name => 'jeff'
|
99
|
+
# m = ActiveRecordFixtures::Order.find(m.id)
|
100
|
+
# m.id = 999
|
101
|
+
# m.save!
|
102
|
+
# end
|
103
|
+
# metrics = NewRelic::Agent.instance.stats_engine.metrics
|
104
|
+
|
105
|
+
# compare_metrics expected, metrics
|
106
|
+
# check_metric_count("ActiveRecord/ActiveRecordFixtures::Order/find", 1)
|
107
|
+
# # zero because jruby uses a different mysql adapter
|
108
|
+
# check_metric_count("ActiveRecord/ActiveRecordFixtures::Order/create", 0)
|
109
|
+
#end
|
110
|
+
|
111
|
+
#def test_metric_names_sqlite
|
112
|
+
# # fails due to a bug in rails 3 - log does not provide the correct
|
113
|
+
# # transaction type - it returns 'SQL' instead of 'Foo Create', for example.
|
114
|
+
# return if rails3? || !isSqlite? || defined?(JRuby)
|
115
|
+
|
116
|
+
# expected = %W[
|
117
|
+
# ActiveRecord/all
|
118
|
+
# ActiveRecord/find
|
119
|
+
# ActiveRecord/ActiveRecordFixtures::Order/find
|
120
|
+
# ActiveRecord/create
|
121
|
+
# ActiveRecord/ActiveRecordFixtures::Order/create]
|
122
|
+
|
123
|
+
# if NewRelic::Control.instance.rails_version < '2.1.0'
|
124
|
+
# expected += %W[ActiveRecord/save ActiveRecord/ActiveRecordFixtures::Order/save]
|
125
|
+
# end
|
126
|
+
|
127
|
+
# assert_calls_metrics(*expected) do
|
128
|
+
# m = ActiveRecordFixtures::Order.create :id => 0, :name => 'jeff'
|
129
|
+
# m = ActiveRecordFixtures::Order.find(m.id)
|
130
|
+
# m.id = 999
|
131
|
+
# m.save!
|
132
|
+
# end
|
133
|
+
# metrics = NewRelic::Agent.instance.stats_engine.metrics
|
134
|
+
|
135
|
+
# compare_metrics expected, metrics
|
136
|
+
# check_metric_count("ActiveRecord/ActiveRecordFixtures::Order/find", 1)
|
137
|
+
# check_metric_count("ActiveRecord/ActiveRecordFixtures::Order/create", 1)
|
138
|
+
#end
|
139
|
+
|
140
|
+
#def test_metric_names_standard
|
141
|
+
# # fails due to a bug in rails 3 - log does not provide the correct
|
142
|
+
# # transaction type - it returns 'SQL' instead of 'Foo Create', for example.
|
143
|
+
# return if defined?(JRuby) || isSqlite?
|
144
|
+
|
145
|
+
# expected = %W[
|
146
|
+
# ActiveRecord/all
|
147
|
+
# ActiveRecord/find
|
148
|
+
# ActiveRecord/create
|
149
|
+
# ActiveRecord/ActiveRecordFixtures::Order/find
|
150
|
+
# ActiveRecord/ActiveRecordFixtures::Order/create
|
151
|
+
# Database/SQL/other
|
152
|
+
# RemoteService/sql/#{adapter}/localhost]
|
153
|
+
|
154
|
+
# if NewRelic::Control.instance.rails_version < '2.1.0'
|
155
|
+
# expected += ['ActiveRecord/save',
|
156
|
+
# 'ActiveRecord/ActiveRecordFixtures::Order/save']
|
157
|
+
# end
|
158
|
+
|
159
|
+
# if NewRelic::Control.instance.rails_version >= '3.0.0'
|
160
|
+
# expected << 'Database/SQL/insert'
|
161
|
+
# end
|
162
|
+
|
163
|
+
# if NewRelic::Control.instance.rails_version >= '4.0'
|
164
|
+
# expected << 'Database/SQL/update'
|
165
|
+
# end
|
166
|
+
|
167
|
+
# assert_calls_metrics(*expected) do
|
168
|
+
# m = ActiveRecordFixtures::Order.create :id => 1, :name => 'donkey'
|
169
|
+
# m = ActiveRecordFixtures::Order.find(m.id)
|
170
|
+
# m.id = 999
|
171
|
+
# m.save!
|
172
|
+
# end
|
173
|
+
|
174
|
+
# metrics = NewRelic::Agent.instance.stats_engine.metrics
|
175
|
+
|
176
|
+
# compare_metrics expected, metrics
|
177
|
+
# check_metric_count("ActiveRecord/ActiveRecordFixtures::Order/find", 1)
|
178
|
+
# if NewRelic::Control.instance.rails_version < '3.0.0'
|
179
|
+
# check_metric_count("ActiveRecord/ActiveRecordFixtures::Order/create", 1)
|
180
|
+
# else
|
181
|
+
# check_metric_count("Database/SQL/insert", 1)
|
182
|
+
# end
|
183
|
+
#end
|
184
|
+
|
185
|
+
#def test_join_metrics_jruby
|
186
|
+
# return unless defined?(JRuby)
|
187
|
+
# return if rails3?
|
188
|
+
|
189
|
+
# expected_metrics = %W[
|
190
|
+
# ActiveRecord/all
|
191
|
+
# ActiveRecord/destroy
|
192
|
+
# ActiveRecord/ActiveRecordFixtures::Order/destroy
|
193
|
+
# Database/SQL/insert
|
194
|
+
# Database/SQL/delete
|
195
|
+
# Database/SQL/show
|
196
|
+
# ActiveRecord/find
|
197
|
+
# ActiveRecord/ActiveRecordFixtures::Order/find
|
198
|
+
# ActiveRecord/ActiveRecordFixtures::Shipment/find
|
199
|
+
# RemoteService/sql/#{adapter}/localhost
|
200
|
+
# ]
|
201
|
+
|
202
|
+
# assert_calls_metrics(*expected_metrics) do
|
203
|
+
# m = ActiveRecordFixtures::Order.create :name => 'jeff'
|
204
|
+
# m = ActiveRecordFixtures::Order.find(m.id)
|
205
|
+
# s = m.shipments.create
|
206
|
+
# m.shipments.to_a
|
207
|
+
# m.destroy
|
208
|
+
# end
|
209
|
+
|
210
|
+
# metrics = NewRelic::Agent.instance.stats_engine.metrics
|
211
|
+
|
212
|
+
# compare_metrics expected_metrics, metrics
|
213
|
+
|
214
|
+
# check_metric_time('ActiveRecord/all', NewRelic::Agent.get_stats("ActiveRecord/all").total_exclusive_time, 0)
|
215
|
+
# check_metric_count("ActiveRecord/ActiveRecordFixtures::Order/find", 1)
|
216
|
+
# check_metric_count("ActiveRecord/ActiveRecordFixtures::Shipment/find", 1)
|
217
|
+
# check_metric_count("Database/SQL/insert", 3)
|
218
|
+
# check_metric_count("Database/SQL/delete", 1)
|
219
|
+
#end
|
220
|
+
|
221
|
+
#def test_join_metrics_sqlite
|
222
|
+
# return if (defined?(Rails) && Rails::VERSION::MAJOR.to_i == 3)
|
223
|
+
# return if defined?(JRuby)
|
224
|
+
# return unless isSqlite?
|
225
|
+
|
226
|
+
# expected_metrics = %W[
|
227
|
+
# ActiveRecord/all
|
228
|
+
# ActiveRecord/destroy
|
229
|
+
# ActiveRecord/ActiveRecordFixtures::Order/destroy
|
230
|
+
# Database/SQL/insert
|
231
|
+
# Database/SQL/delete
|
232
|
+
# ActiveRecord/find
|
233
|
+
# ActiveRecord/ActiveRecordFixtures::Order/find
|
234
|
+
# ActiveRecord/ActiveRecordFixtures::Shipment/find
|
235
|
+
# ActiveRecord/create
|
236
|
+
# ActiveRecord/ActiveRecordFixtures::Shipment/create
|
237
|
+
# ActiveRecord/ActiveRecordFixtures::Order/create
|
238
|
+
# ]
|
239
|
+
|
240
|
+
# assert_calls_metrics(*expected_metrics) do
|
241
|
+
# m = ActiveRecordFixtures::Order.create :name => 'jeff'
|
242
|
+
# m = ActiveRecordFixtures::Order.find(m.id)
|
243
|
+
# s = m.shipments.create
|
244
|
+
# m.shipments.to_a
|
245
|
+
# m.destroy
|
246
|
+
# end
|
247
|
+
|
248
|
+
# metrics = NewRelic::Agent.instance.stats_engine.metrics
|
249
|
+
# compare_metrics expected_metrics, metrics
|
250
|
+
# if !(defined?(RUBY_DESCRIPTION) && RUBY_DESCRIPTION =~ /Enterprise Edition/)
|
251
|
+
# check_metric_time('ActiveRecord/all', NewRelic::Agent.get_stats("ActiveRecord/all").total_exclusive_time, 0)
|
252
|
+
# end
|
253
|
+
# check_metric_count("ActiveRecord/ActiveRecordFixtures::Order/find", 1)
|
254
|
+
# check_metric_count("ActiveRecord/ActiveRecordFixtures::Shipment/find", 1)
|
255
|
+
# check_metric_count("Database/SQL/insert", 3)
|
256
|
+
# check_metric_count("Database/SQL/delete", 1)
|
257
|
+
#end
|
258
|
+
|
259
|
+
#def test_join_metrics_standard
|
260
|
+
# return if (defined?(Rails) && Rails::VERSION::MAJOR.to_i >= 3)
|
261
|
+
# return if defined?(JRuby) || isSqlite?
|
262
|
+
|
263
|
+
# expected_metrics = %W[
|
264
|
+
# ActiveRecord/all
|
265
|
+
# RemoteService/sql/#{adapter}/localhost
|
266
|
+
# ActiveRecord/destroy
|
267
|
+
# ActiveRecord/ActiveRecordFixtures::Order/destroy
|
268
|
+
# Database/SQL/insert
|
269
|
+
# Database/SQL/delete
|
270
|
+
# ActiveRecord/find
|
271
|
+
# ActiveRecord/ActiveRecordFixtures::Order/find
|
272
|
+
# ActiveRecord/ActiveRecordFixtures::Shipment/find
|
273
|
+
# Database/SQL/other
|
274
|
+
# Database/SQL/show
|
275
|
+
# ActiveRecord/create
|
276
|
+
# ActiveRecord/ActiveRecordFixtures::Shipment/create
|
277
|
+
# ActiveRecord/ActiveRecordFixtures::Order/create
|
278
|
+
# ]
|
279
|
+
|
280
|
+
# assert_calls_metrics(*expected_metrics) do
|
281
|
+
# m = ActiveRecordFixtures::Order.create :name => 'jeff'
|
282
|
+
# m = ActiveRecordFixtures::Order.find(m.id)
|
283
|
+
# s = m.shipments.create
|
284
|
+
# m.shipments.to_a
|
285
|
+
# m.destroy
|
286
|
+
# end
|
287
|
+
|
288
|
+
# metrics = NewRelic::Agent.instance.stats_engine.metrics
|
289
|
+
|
290
|
+
# compare_metrics expected_metrics, metrics
|
291
|
+
# if !(defined?(RUBY_DESCRIPTION) && RUBY_DESCRIPTION =~ /Enterprise Edition/)
|
292
|
+
# check_metric_time('ActiveRecord/all', NewRelic::Agent.get_stats("ActiveRecord/all").total_exclusive_time, 0)
|
293
|
+
# end
|
294
|
+
# check_metric_count("ActiveRecord/ActiveRecordFixtures::Order/find", 1)
|
295
|
+
# check_metric_count("ActiveRecord/ActiveRecordFixtures::Shipment/find", 1)
|
296
|
+
# check_metric_count("Database/SQL/insert", 1)
|
297
|
+
# check_metric_count("Database/SQL/delete", 1)
|
298
|
+
#end
|
299
|
+
|
300
|
+
#def test_direct_sql
|
301
|
+
# assert_nil NewRelic::Agent::Transaction.current
|
302
|
+
# assert_equal 0, NewRelic::Agent.instance.stats_engine.metrics.size, NewRelic::Agent.instance.stats_engine.metrics.inspect
|
303
|
+
|
304
|
+
# expected_metrics = %W[
|
305
|
+
# ActiveRecord/all
|
306
|
+
# Database/SQL/select
|
307
|
+
# RemoteService/sql/#{adapter}/localhost
|
308
|
+
# ]
|
309
|
+
|
310
|
+
# assert_calls_unscoped_metrics(*expected_metrics) do
|
311
|
+
# ActiveRecordFixtures::Order.connection.select_rows "select * from #{ActiveRecordFixtures::Order.table_name}"
|
312
|
+
# end
|
313
|
+
|
314
|
+
# metrics = NewRelic::Agent.instance.stats_engine.metrics
|
315
|
+
# compare_metrics(expected_metrics, metrics)
|
316
|
+
|
317
|
+
# check_unscoped_metric_count('Database/SQL/select', 1)
|
318
|
+
|
319
|
+
#end
|
320
|
+
|
321
|
+
#def test_other_sql
|
322
|
+
# expected_metrics = %W[
|
323
|
+
# ActiveRecord/all
|
324
|
+
# Database/SQL/other
|
325
|
+
# RemoteService/sql/#{adapter}/localhost
|
326
|
+
# ]
|
327
|
+
# assert_calls_unscoped_metrics(*expected_metrics) do
|
328
|
+
# ActiveRecordFixtures::Order.connection.execute "begin"
|
329
|
+
# end
|
330
|
+
|
331
|
+
# metrics = NewRelic::Agent.instance.stats_engine.metrics
|
332
|
+
|
333
|
+
# compare_metrics expected_metrics, metrics
|
334
|
+
# check_unscoped_metric_count('Database/SQL/other', 1)
|
335
|
+
#end
|
336
|
+
|
337
|
+
#def test_show_sql
|
338
|
+
# return if isSqlite?
|
339
|
+
# return if isPostgres?
|
340
|
+
|
341
|
+
# expected_metrics = %W[ActiveRecord/all Database/SQL/show RemoteService/sql/#{adapter}/localhost]
|
342
|
+
# assert_calls_metrics(*expected_metrics) do
|
343
|
+
# ActiveRecordFixtures::Order.connection.execute "show tables"
|
344
|
+
# end
|
345
|
+
# metrics = NewRelic::Agent.instance.stats_engine.metrics
|
346
|
+
# compare_metrics expected_metrics, metrics
|
347
|
+
# check_unscoped_metric_count('Database/SQL/show', 1)
|
348
|
+
#end
|
349
|
+
|
350
|
+
#def test_blocked_instrumentation
|
351
|
+
# ActiveRecordFixtures::Order.add_delay
|
352
|
+
# NewRelic::Agent.disable_all_tracing do
|
353
|
+
# perform_action_with_newrelic_trace :name => 'bogosity' do
|
354
|
+
# all_finder(ActiveRecordFixtures::Order)
|
355
|
+
# end
|
356
|
+
# end
|
357
|
+
# assert_nil NewRelic::Agent.instance.transaction_sampler.last_sample
|
358
|
+
# metrics = NewRelic::Agent.instance.stats_engine.metrics
|
359
|
+
# compare_metrics [], metrics
|
360
|
+
#end
|
361
|
+
|
362
|
+
#def test_run_explains
|
363
|
+
# perform_action_with_newrelic_trace :name => 'bogosity' do
|
364
|
+
# ActiveRecordFixtures::Order.add_delay
|
365
|
+
# all_finder(ActiveRecordFixtures::Order)
|
366
|
+
# end
|
367
|
+
|
368
|
+
# # that's a mouthful. perhaps we should ponder our API.
|
369
|
+
# segment = last_segment(NewRelic::Agent.instance.transaction_sampler.last_sample)
|
370
|
+
# regex = /^SELECT (["`]?#{ActiveRecordFixtures::Order.table_name}["`]?.)?\* FROM ["`]?#{ActiveRecordFixtures::Order.table_name}["`]?$/
|
371
|
+
# assert_match regex, segment.params[:sql].strip
|
372
|
+
#end
|
373
|
+
|
374
|
+
#def test_prepare_to_send
|
375
|
+
# with_config(:'transaction_tracer.explain_enabled' => true,
|
376
|
+
# :'transaction_tracer.explain_threshold' => 0.0) do
|
377
|
+
# perform_action_with_newrelic_trace :name => 'bogosity' do
|
378
|
+
# ActiveRecordFixtures::Order.add_delay
|
379
|
+
# all_finder(ActiveRecordFixtures::Order)
|
380
|
+
# end
|
381
|
+
# sample = NewRelic::Agent.instance.transaction_sampler.last_sample
|
382
|
+
# refute_nil sample
|
383
|
+
|
384
|
+
# includes_gc = false
|
385
|
+
# sample.each_segment {|s| includes_gc ||= s.metric_name =~ /GC/ }
|
386
|
+
|
387
|
+
# sql_segment = last_segment(sample)
|
388
|
+
# refute_nil sql_segment, sample.to_s
|
389
|
+
# assert_match /^SELECT /, sql_segment.params[:sql]
|
390
|
+
# assert sql_segment.duration > 0.0, "Segment duration must be greater than zero."
|
391
|
+
# sample = sample.prepare_to_send!
|
392
|
+
# sql_segment = last_segment(sample)
|
393
|
+
# assert_match /^SELECT /, sql_segment.params[:sql]
|
394
|
+
# explanations = sql_segment.params[:explain_plan]
|
395
|
+
# if (isMysql? || isPostgres?) && !NewRelic::LanguageSupport.using_engine?('jruby')
|
396
|
+
# refute_nil explanations, "No explains in segment: #{sql_segment}"
|
397
|
+
# assert_equal(2, explanations.size,
|
398
|
+
# "No explains in segment: #{sql_segment}")
|
399
|
+
# end
|
400
|
+
# end
|
401
|
+
#end
|
402
|
+
|
403
|
+
#def test_transaction_mysql
|
404
|
+
# return unless isMysql? && !defined?(JRuby)
|
405
|
+
|
406
|
+
# with_config(:record_sql => :obfuscated,
|
407
|
+
# :'transaction_tracer.explain_enabled' => true,
|
408
|
+
# :'transaction_tracer.explain_threshold' => 0.0) do
|
409
|
+
# ActiveRecordFixtures.setup
|
410
|
+
# sample = NewRelic::Agent.instance.transaction_sampler.reset!
|
411
|
+
# perform_action_with_newrelic_trace :name => 'bogosity' do
|
412
|
+
# ActiveRecordFixtures::Order.add_delay
|
413
|
+
# all_finder(ActiveRecordFixtures::Order)
|
414
|
+
# end
|
415
|
+
|
416
|
+
# sample = NewRelic::Agent.instance.transaction_sampler.last_sample
|
417
|
+
# sample = sample.prepare_to_send!
|
418
|
+
# segment = last_segment(sample)
|
419
|
+
# explanation = segment.params[:explain_plan]
|
420
|
+
# refute_nil explanation, "No explains in segment: #{segment}"
|
421
|
+
# assert_equal 2, explanation.size,"No explains in segment: #{segment}"
|
422
|
+
|
423
|
+
# assert_equal 10, explanation[0].size
|
424
|
+
# ['id', 'select_type', 'table'].each do |c|
|
425
|
+
# assert explanation[0].include?(c)
|
426
|
+
# end
|
427
|
+
# ['1', 'SIMPLE', ActiveRecordFixtures::Order.table_name].each do |c|
|
428
|
+
# assert explanation[1][0].include?(c)
|
429
|
+
# end
|
430
|
+
|
431
|
+
# s = NewRelic::Agent.get_stats("ActiveRecord/ActiveRecordFixtures::Order/find")
|
432
|
+
# assert_equal 1, s.call_count
|
433
|
+
# end
|
434
|
+
#end
|
435
|
+
|
436
|
+
#def test_transaction_postgres
|
437
|
+
# return unless isPostgres?
|
438
|
+
|
439
|
+
# with_config(:record_sql => :obfuscated,
|
440
|
+
# :'transaction_tracer.explain_enabled' => true,
|
441
|
+
# :'transaction_tracer.explain_threshold' => 0.0) do
|
442
|
+
# # note that our current test builds do not use postgres, this is
|
443
|
+
# # here strictly for troubleshooting, not CI builds
|
444
|
+
# sample = NewRelic::Agent.instance.transaction_sampler.reset!
|
445
|
+
# perform_action_with_newrelic_trace :name => 'bogosity' do
|
446
|
+
# ActiveRecordFixtures::Order.add_delay
|
447
|
+
# all_finder(ActiveRecordFixtures::Order)
|
448
|
+
# end
|
449
|
+
|
450
|
+
# sample = NewRelic::Agent.instance.transaction_sampler.last_sample
|
451
|
+
|
452
|
+
# sample = sample.prepare_to_send!
|
453
|
+
# segment = last_segment(sample)
|
454
|
+
# explanations = segment.params[:explain_plan]
|
455
|
+
|
456
|
+
# refute_nil explanations, "No explains in segment: #{segment}"
|
457
|
+
# assert_equal 1, explanations.size,"No explains in segment: #{segment}"
|
458
|
+
# assert_equal 1, explanations.first.size
|
459
|
+
|
460
|
+
# assert_equal("Explain Plan", explanations[0][0])
|
461
|
+
# assert_match /Seq Scan on test_data/, explanations[0][1].join(";")
|
462
|
+
|
463
|
+
# s = NewRelic::Agent.get_stats("ActiveRecord/ActiveRecordFixtures::Order/find")
|
464
|
+
# assert_equal 1, s.call_count
|
465
|
+
# end
|
466
|
+
#end
|
467
|
+
|
468
|
+
#def test_transaction_other
|
469
|
+
# return if isMysql? || isPostgres?
|
470
|
+
|
471
|
+
# with_config(:record_sql => :obfuscated,
|
472
|
+
# :'transaction_tracer.explain_enabled' => true,
|
473
|
+
# :'transaction_tracer.explain_threshold' => 0.0) do
|
474
|
+
# sample = NewRelic::Agent.instance.transaction_sampler.reset!
|
475
|
+
# perform_action_with_newrelic_trace :name => 'bogosity' do
|
476
|
+
# ActiveRecordFixtures::Order.add_delay
|
477
|
+
# all_finder(ActiveRecordFixtures::Order)
|
478
|
+
# end
|
479
|
+
|
480
|
+
# sample = NewRelic::Agent.instance.transaction_sampler.last_sample
|
481
|
+
|
482
|
+
# sample = sample.prepare_to_send!
|
483
|
+
# segment = last_segment(sample)
|
484
|
+
|
485
|
+
# s = NewRelic::Agent.get_stats("ActiveRecord/ActiveRecordFixtures::Order/find")
|
486
|
+
# assert_equal 1, s.call_count
|
487
|
+
# end
|
488
|
+
#end
|
489
|
+
|
490
|
+
## These are only valid for rails 2.1 and later
|
491
|
+
#if NewRelic::Control.instance.rails_version >= NewRelic::VersionNumber.new("2.1.0")
|
492
|
+
# ActiveRecordFixtures::Order.class_eval do
|
493
|
+
# if NewRelic::Control.instance.rails_version >= NewRelic::VersionNumber.new("4")
|
494
|
+
# scope :jeffs, lambda { where(:name => 'Jeff') }
|
495
|
+
# elsif NewRelic::Control.instance.rails_version >= NewRelic::VersionNumber.new("3.1")
|
496
|
+
# scope :jeffs, :conditions => { :name => 'Jeff' }
|
497
|
+
# else
|
498
|
+
# named_scope :jeffs, :conditions => { :name => 'Jeff' }
|
499
|
+
# end
|
500
|
+
# end
|
501
|
+
# def test_named_scope
|
502
|
+
# ActiveRecordFixtures::Order.create :name => 'Jeff'
|
503
|
+
|
504
|
+
# find_metric = "ActiveRecord/ActiveRecordFixtures::Order/find"
|
505
|
+
|
506
|
+
# check_metric_count(find_metric, 0)
|
507
|
+
# assert_calls_metrics(find_metric) do
|
508
|
+
# if NewRelic::Control.instance.rails_version >= "4"
|
509
|
+
# x = ActiveRecordFixtures::Order.jeffs.load
|
510
|
+
# else
|
511
|
+
# x = ActiveRecordFixtures::Order.jeffs.find(:all)
|
512
|
+
# end
|
513
|
+
# end
|
514
|
+
# check_metric_count(find_metric, 1)
|
515
|
+
# end
|
516
|
+
#end
|
517
|
+
|
518
|
+
## This is to make sure the all metric is recorded for exceptional cases
|
519
|
+
#def test_error_handling
|
520
|
+
# # have the AR select throw an error
|
521
|
+
# ActiveRecordFixtures::Order.connection.stubs(:log_info).with do | sql, x, y |
|
522
|
+
# raise "Error" if sql =~ /select/
|
523
|
+
# true
|
524
|
+
# end
|
525
|
+
|
526
|
+
# in_web_transaction do
|
527
|
+
# begin
|
528
|
+
# ActiveRecordFixtures::Order.connection.select_rows "select * from #{ActiveRecordFixtures::Order.table_name}"
|
529
|
+
# rescue RuntimeError => e
|
530
|
+
# # catch only the error we raise above
|
531
|
+
# raise unless e.message == 'Error'
|
532
|
+
# end
|
533
|
+
# end
|
534
|
+
|
535
|
+
# assert_metrics_recorded(
|
536
|
+
# 'ActiveRecord/all' => { :call_count => 1 },
|
537
|
+
# 'Database/SQL/select' => { :call_count => 1 }
|
538
|
+
# )
|
539
|
+
|
540
|
+
# if !NewRelic::LanguageSupport.using_engine?('jruby')
|
541
|
+
# assert_metrics_recorded("RemoteService/sql/#{adapter}/localhost" => { :call_count => 1 })
|
542
|
+
# end
|
543
|
+
#end
|
544
|
+
|
545
|
+
#def test_rescue_handling
|
546
|
+
# # Not sure why we get a transaction error with sqlite
|
547
|
+
# return if isSqlite?
|
548
|
+
|
549
|
+
# begin
|
550
|
+
# ActiveRecordFixtures::Order.transaction do
|
551
|
+
# raise ActiveRecord::ActiveRecordError.new('preserve-me!')
|
552
|
+
# end
|
553
|
+
# rescue ActiveRecord::ActiveRecordError => e
|
554
|
+
# assert_equal 'preserve-me!', e.message
|
555
|
+
# end
|
556
|
+
#end
|
557
|
+
|
558
|
+
#def test_remote_service_metric_respects_dynamic_connection_config
|
559
|
+
# return unless isMysql? && !NewRelic::LanguageSupport.using_engine?('jruby')
|
560
|
+
|
561
|
+
# ActiveRecordFixtures::Shipment.connection.execute('SHOW TABLES');
|
562
|
+
# assert_metrics_recorded(["RemoteService/sql/#{adapter}/localhost"])
|
563
|
+
|
564
|
+
# config = ActiveRecordFixtures::Shipment.connection.instance_eval { @config }
|
565
|
+
# config[:host] = '127.0.0.1'
|
566
|
+
# connection = ActiveRecordFixtures::Shipment.establish_connection(config)
|
567
|
+
|
568
|
+
# ActiveRecordFixtures::Shipment.connection.execute('SHOW TABLES');
|
569
|
+
# assert_metrics_recorded(["RemoteService/sql/#{adapter}/127.0.0.1"])
|
570
|
+
|
571
|
+
# config[:host] = 'localhost'
|
572
|
+
# ActiveRecordFixtures::Shipment.establish_connection(config)
|
573
|
+
#end
|
574
574
|
|
575
575
|
private
|
576
576
|
|
@@ -617,7 +617,7 @@ class NewRelic::Agent::Instrumentation::ActiveRecordInstrumentationTest < Test::
|
|
617
617
|
end
|
618
618
|
|
619
619
|
|
620
|
-
class ActiveRecordQueryEncodingTest <
|
620
|
+
class ActiveRecordQueryEncodingTest < MiniTest::Unit::TestCase
|
621
621
|
|
622
622
|
class DatabaseAdapter
|
623
623
|
# we patch in here
|