newrelic_rpm 3.18.1.330 → 4.0.0.332
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +2 -74
- data/CHANGELOG.md +77 -0
- data/CONTRIBUTING.md +14 -6
- data/LICENSE +1 -88
- data/lib/new_relic/agent.rb +2 -103
- data/lib/new_relic/agent/agent.rb +3 -32
- data/lib/new_relic/agent/commands/thread_profiler_session.rb +2 -6
- data/lib/new_relic/agent/configuration/default_source.rb +1 -8
- data/lib/new_relic/agent/configuration/yaml_source.rb +1 -12
- data/lib/new_relic/agent/cross_app_monitor.rb +2 -1
- data/lib/new_relic/agent/cross_app_tracing.rb +4 -2
- data/lib/new_relic/agent/datastores/mongo.rb +1 -1
- data/lib/new_relic/agent/datastores/redis.rb +1 -1
- data/lib/new_relic/agent/encoding_normalizer.rb +1 -20
- data/lib/new_relic/agent/error_collector.rb +8 -21
- data/lib/new_relic/agent/inbound_request_monitor.rb +4 -1
- data/lib/new_relic/agent/instrumentation/active_record_helper.rb +14 -30
- data/lib/new_relic/agent/instrumentation/active_record_subscriber.rb +1 -1
- data/lib/new_relic/agent/instrumentation/controller_instrumentation.rb +4 -5
- data/lib/new_relic/agent/instrumentation/curb.rb +2 -2
- data/lib/new_relic/agent/instrumentation/excon.rb +3 -3
- data/lib/new_relic/agent/instrumentation/grape.rb +3 -3
- data/lib/new_relic/agent/instrumentation/httpclient.rb +2 -2
- data/lib/new_relic/agent/instrumentation/memcache/dalli.rb +2 -2
- data/lib/new_relic/agent/instrumentation/middleware_proxy.rb +2 -2
- data/lib/new_relic/agent/instrumentation/middleware_tracing.rb +3 -7
- data/lib/new_relic/agent/instrumentation/queue_time.rb +13 -15
- data/lib/new_relic/agent/instrumentation/rack.rb +4 -50
- data/lib/new_relic/agent/instrumentation/rake.rb +1 -1
- data/lib/new_relic/agent/instrumentation/resque.rb +1 -2
- data/lib/new_relic/agent/instrumentation/sinatra.rb +0 -1
- data/lib/new_relic/agent/instrumentation/typhoeus.rb +2 -2
- data/lib/new_relic/agent/javascript_instrumentor.rb +3 -2
- data/lib/new_relic/agent/method_tracer.rb +1 -60
- data/lib/new_relic/agent/new_relic_service.rb +3 -2
- data/lib/new_relic/agent/new_relic_service/encoders.rb +5 -6
- data/lib/new_relic/agent/new_relic_service/json_marshaller.rb +7 -16
- data/lib/new_relic/agent/pipe_channel_manager.rb +1 -3
- data/lib/new_relic/agent/pipe_service.rb +1 -3
- data/lib/new_relic/agent/rules_engine.rb +2 -17
- data/lib/new_relic/agent/stats_engine.rb +0 -2
- data/lib/new_relic/agent/stats_engine/metric_stats.rb +0 -48
- data/lib/new_relic/agent/supported_versions.rb +12 -19
- data/lib/new_relic/agent/threading/backtrace_service.rb +1 -1
- data/lib/new_relic/agent/transaction.rb +0 -3
- data/lib/new_relic/agent/transaction/attributes.rb +1 -10
- data/lib/new_relic/agent/vm.rb +1 -4
- data/lib/new_relic/agent/vm/jruby_vm.rb +1 -3
- data/lib/new_relic/agent/vm/mri_vm.rb +2 -10
- data/lib/new_relic/control.rb +1 -2
- data/lib/new_relic/control/frameworks/rails.rb +1 -1
- data/lib/new_relic/control/frameworks/rails3.rb +1 -2
- data/lib/new_relic/control/frameworks/rails4.rb +1 -1
- data/lib/new_relic/control/frameworks/rails5.rb +1 -1
- data/lib/new_relic/control/instance_methods.rb +1 -1
- data/{vendor/gems/dependency_detection-0.0.1.build/lib → lib/new_relic}/dependency_detection.rb +0 -1
- data/lib/new_relic/helper.rb +6 -13
- data/lib/new_relic/language_support.rb +44 -139
- data/lib/new_relic/metric_spec.rb +0 -17
- data/lib/new_relic/noticed_error.rb +18 -27
- data/lib/new_relic/version.rb +3 -48
- data/lib/tasks/versions.rake +7 -5
- data/newrelic_rpm.gemspec +1 -16
- data/test/agent_helper.rb +4 -2
- data/test/environments/lib/environments/runner.rb +5 -14
- data/test/environments/norails/Gemfile +0 -8
- data/test/environments/rails21/Gemfile +0 -8
- data/test/environments/rails21/config/database.yml +1 -1
- data/test/environments/rails22/Gemfile +0 -8
- data/test/environments/rails22/config/database.yml +1 -1
- data/test/environments/rails23/Gemfile +1 -7
- data/test/environments/rails23/config/database.yml +1 -1
- data/test/environments/rails30/Gemfile +0 -1
- data/test/environments/rails30/config/database.yml +1 -1
- data/test/environments/rails31/Gemfile +0 -3
- data/test/environments/rails31/config/database.yml +1 -1
- data/test/environments/rails32/Gemfile +0 -3
- data/test/environments/rails32/config/database.yml +1 -1
- data/test/environments/rails40/Gemfile +0 -26
- data/test/environments/rails40/config/database.yml +1 -1
- data/test/environments/rails41/Gemfile +0 -18
- data/test/environments/rails41/config/database.yml +1 -1
- data/test/environments/rails42/Gemfile +0 -22
- data/test/environments/rails42/config/database.yml +1 -1
- data/test/environments/rails50/Gemfile +0 -13
- data/test/environments/rails50/config/database.yml +1 -1
- data/test/helpers/logging.rb +37 -0
- data/test/helpers/minitest.rb +50 -0
- data/test/helpers/misc.rb +87 -0
- data/test/helpers/transaction_sample.rb +44 -0
- data/test/multiverse/lib/multiverse/suite.rb +6 -91
- data/test/multiverse/script/runner +1 -1
- data/test/multiverse/suites/active_record/Envfile +1 -28
- data/test/multiverse/suites/active_record/active_record_test.rb +6 -6
- data/test/multiverse/suites/active_record/config/database.rb +2 -3
- data/test/multiverse/suites/active_record/config/database.yml +0 -2
- data/test/multiverse/suites/activemerchant/Envfile +4 -18
- data/test/multiverse/suites/agent_only/encoding_handling_test.rb +7 -15
- data/test/multiverse/suites/agent_only/error_events_test.rb +1 -7
- data/test/multiverse/suites/agent_only/harvest_timestamps_test.rb +4 -20
- data/test/multiverse/suites/agent_only/labels_test.rb +1 -1
- data/test/multiverse/suites/agent_only/marshaling_test.rb +5 -10
- data/test/multiverse/suites/agent_only/script/public_api_when_disabled.rb +0 -11
- data/test/multiverse/suites/agent_only/start_up_test.rb +3 -3
- data/test/multiverse/suites/agent_only/synthetics_test.rb +1 -1
- data/test/multiverse/suites/agent_only/thread_profiling_test.rb +0 -3
- data/test/multiverse/suites/agent_only/xray_sessions_test.rb +0 -3
- data/test/multiverse/suites/capistrano/Envfile +2 -4
- data/test/multiverse/suites/capistrano2/Envfile +0 -4
- data/test/multiverse/suites/curb/Envfile +3 -7
- data/test/multiverse/suites/datamapper/Envfile +2 -2
- data/test/multiverse/suites/datamapper/datamapper_test.rb +2 -2
- data/test/multiverse/suites/deferred_instrumentation/sinatra_test.rb +0 -1
- data/test/multiverse/suites/delayed_job/Envfile +28 -41
- data/test/multiverse/suites/excon/Envfile +0 -3
- data/test/multiverse/suites/grape/Envfile +0 -4
- data/test/multiverse/suites/grape/grape_versioning_test.rb +2 -2
- data/test/multiverse/suites/grape/grape_versioning_test_api.rb +2 -2
- data/test/multiverse/suites/json/Envfile +1 -9
- data/test/multiverse/suites/marshalling/Envfile +0 -9
- data/test/multiverse/suites/memcached/Envfile +5 -23
- data/test/multiverse/suites/mongo/Envfile +9 -11
- data/test/multiverse/suites/padrino/Envfile +0 -6
- data/test/multiverse/suites/rack/http_response_code_test.rb +0 -1
- data/test/multiverse/suites/rack/rack_auto_instrumentation_test.rb +5 -10
- data/test/multiverse/suites/rack/rack_cascade_test.rb +0 -1
- data/test/multiverse/suites/rack/rack_env_mutation_test.rb +0 -1
- data/test/multiverse/suites/rack/response_content_type_test.rb +0 -1
- data/test/multiverse/suites/rails/Envfile +1 -19
- data/test/multiverse/suites/rails/activejob_test.rb +1 -2
- data/test/multiverse/suites/rails/error_tracing_test.rb +0 -13
- data/test/multiverse/suites/rails/gc_instrumentation_test.rb +12 -32
- data/test/multiverse/suites/rake/Envfile +15 -22
- data/test/multiverse/suites/redis/redis_instrumentation_test.rb +1 -1
- data/test/multiverse/suites/sequel/database.rb +1 -4
- data/test/multiverse/suites/sidekiq/Envfile +13 -23
- data/test/multiverse/suites/sinatra/sinatra_test_cases.rb +3 -3
- data/test/multiverse/suites/typhoeus/Envfile +0 -19
- data/test/multiverse/suites/typhoeus/typhoeus_test.rb +3 -3
- data/test/multiverse/suites/yajl/Envfile +5 -0
- data/test/multiverse/suites/yajl/yajl_test.rb +1 -3
- data/test/new_relic/agent/agent/start_test.rb +3 -3
- data/test/new_relic/agent/agent_logger_test.rb +2 -2
- data/test/new_relic/agent/agent_test.rb +2 -2
- data/test/new_relic/agent/attribute_processing_test.rb +3 -4
- data/test/new_relic/agent/audit_logger_test.rb +4 -6
- data/test/new_relic/agent/aws_info_test.rb +17 -1
- data/test/new_relic/agent/busy_calculator_test.rb +14 -16
- data/test/new_relic/agent/configuration/manager_test.rb +1 -7
- data/test/new_relic/agent/cross_app_monitor_test.rb +1 -1
- data/test/new_relic/agent/database_test.rb +2 -10
- data/test/new_relic/agent/datastores/mongo/event_formatter_test.rb +90 -93
- data/test/new_relic/agent/datastores/redis_test.rb +14 -16
- data/test/new_relic/agent/encoding_normalizer_test.rb +38 -40
- data/test/new_relic/agent/error_collector_test.rb +16 -49
- data/test/new_relic/agent/instrumentation/active_record_helper_test.rb +0 -6
- data/test/new_relic/agent/instrumentation/active_record_subscriber_test.rb +1 -1
- data/test/new_relic/agent/instrumentation/mongodb_command_subscriber_test.rb +101 -103
- data/test/new_relic/agent/instrumentation/rack_test.rb +11 -14
- data/test/new_relic/agent/instrumentation/task_instrumentation_test.rb +0 -10
- data/test/new_relic/agent/javascript_instrumentor_test.rb +2 -2
- data/test/new_relic/agent/method_tracer/class_methods/add_method_tracer_test.rb +0 -10
- data/test/new_relic/agent/method_tracer_test.rb +35 -76
- data/test/new_relic/agent/new_relic_service_test.rb +86 -102
- data/test/new_relic/agent/pipe_channel_manager_test.rb +4 -9
- data/test/new_relic/agent/pipe_service_test.rb +2 -3
- data/test/new_relic/agent/rpm_agent_test.rb +0 -4
- data/test/new_relic/agent/sampled_buffer_test.rb +2 -2
- data/test/new_relic/agent/samplers/cpu_sampler_test.rb +28 -0
- data/test/new_relic/agent/samplers/memory_sampler_test.rb +66 -0
- data/test/new_relic/agent/sized_buffer_test.rb +1 -1
- data/test/new_relic/agent/stats_engine/gc_profiler_test.rb +2 -14
- data/test/new_relic/agent/stats_engine/metric_stats_test.rb +44 -66
- data/test/new_relic/agent/stats_test.rb +6 -8
- data/test/new_relic/agent/synthetics_event_buffer_test.rb +1 -1
- data/test/new_relic/agent/transaction/attributes_test.rb +4 -12
- data/test/new_relic/agent/transaction_test.rb +2 -10
- data/test/new_relic/agent/utilization_data_test.rb +17 -1
- data/test/new_relic/agent/vm/mri_vm_test.rb +5 -7
- data/test/new_relic/agent_test.rb +0 -43
- data/test/new_relic/coerce_test.rb +1 -3
- data/test/new_relic/fake_collector.rb +3 -3
- data/test/new_relic/fake_external_server.rb +1 -1
- data/test/new_relic/fake_server.rb +1 -1
- data/test/new_relic/http_client_test_cases.rb +3 -3
- data/test/new_relic/language_support_test.rb +6 -12
- data/test/new_relic/latest_changes_test.rb +0 -11
- data/test/new_relic/license_test.rb +3 -8
- data/test/new_relic/multiverse_helpers.rb +1 -1
- data/test/new_relic/noticed_error_test.rb +11 -7
- data/test/new_relic/rack/browser_monitoring_test.rb +1 -3
- data/test/nullverse/nullverse_helper.rb +1 -1
- data/test/performance/lib/performance.rb +1 -1
- data/test/performance/lib/performance/instrumentation/gc_stats.rb +4 -6
- data/test/performance/lib/performance/instrumentation/perf_tools.rb +1 -1
- data/test/performance/lib/performance/instrumentation/stackprof.rb +1 -1
- data/test/performance/lib/performance/platform.rb +1 -8
- data/test/performance/script/runner +1 -3
- data/test/performance/suites/active_record.rb +3 -24
- data/test/test_helper.rb +9 -216
- metadata +9 -45
- data/lib/conditional_vendored_dependency_detection.rb +0 -7
- data/lib/new_relic/agent/hash_extensions.rb +0 -41
- data/lib/new_relic/agent/instrumentation/metric_frame.rb +0 -39
- data/lib/new_relic/agent/instrumentation/rails/errors.rb +0 -51
- data/lib/new_relic/agent/instrumentation/rails3/errors.rb +0 -47
- data/lib/new_relic/agent/instrumentation/rails4/errors.rb +0 -46
- data/lib/new_relic/agent/stats_engine/samplers.rb +0 -22
- data/lib/new_relic/agent/vm/rubinius_vm.rb +0 -140
- data/lib/new_relic/json_wrapper.rb +0 -78
- data/lib/new_relic/okjson.rb +0 -602
- data/lib/new_relic/rack/error_collector.rb +0 -27
- data/lib/new_relic/timer_lib.rb +0 -31
- data/test/helpers/runtime_detection.rb +0 -17
- data/test/multiverse/suites/no_json/Envfile +0 -12
- data/test/multiverse/suites/no_json/config/newrelic.yml +0 -27
- data/test/multiverse/suites/no_json/marshal_config_test.rb +0 -22
- data/test/new_relic/agent/hash_extensions_test.rb +0 -59
- data/test/new_relic/agent/instrumentation/metric_frame_test.rb +0 -22
- data/test/new_relic/agent/stats_engine/samplers_test.rb +0 -98
- data/test/new_relic/agent/vm/rubinius_vm_test.rb +0 -69
- data/test/new_relic/json_wrapper_test.rb +0 -32
- data/test/new_relic/rack/deferred_instrumentation_test.rb +0 -33
- data/test/new_relic/rack/error_collector_test.rb +0 -83
- data/test/new_relic/version_number_test.rb +0 -101
- data/test/script/before_install/revert_rubygems.sh +0 -15
- data/test/script/before_install/update_bundler.sh +0 -12
- data/vendor/gems/dependency_detection-0.0.1.build/lib/dependency_detection/version.rb +0 -7
@@ -162,34 +162,32 @@ class NewRelic::Agent::MetricStatsTest < Minitest::Test
|
|
162
162
|
])
|
163
163
|
end
|
164
164
|
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
@engine.tl_record_scoped_and_unscoped_metrics('m2', ['m4'], 1)
|
177
|
-
end
|
165
|
+
def test_record_scoped_and_unscoped_metrics_is_thread_safe
|
166
|
+
threads = []
|
167
|
+
nthreads = 25
|
168
|
+
iterations = 100
|
169
|
+
|
170
|
+
nthreads.times do |tid|
|
171
|
+
threads << Thread.new do
|
172
|
+
iterations.times do
|
173
|
+
in_transaction('txn') do
|
174
|
+
@engine.tl_record_scoped_and_unscoped_metrics('m1', ['m3'], 1)
|
175
|
+
@engine.tl_record_scoped_and_unscoped_metrics('m2', ['m4'], 1)
|
178
176
|
end
|
179
177
|
end
|
180
178
|
end
|
181
|
-
threads.each { |t| t.join }
|
182
|
-
|
183
|
-
expected = { :call_count => nthreads * iterations }
|
184
|
-
assert_metrics_recorded(
|
185
|
-
'm1' => expected,
|
186
|
-
'm2' => expected,
|
187
|
-
['m1', 'txn'] => expected,
|
188
|
-
['m2', 'txn'] => expected,
|
189
|
-
'm3' => expected,
|
190
|
-
'm4' => expected
|
191
|
-
)
|
192
179
|
end
|
180
|
+
threads.each { |t| t.join }
|
181
|
+
|
182
|
+
expected = { :call_count => nthreads * iterations }
|
183
|
+
assert_metrics_recorded(
|
184
|
+
'm1' => expected,
|
185
|
+
'm2' => expected,
|
186
|
+
['m1', 'txn'] => expected,
|
187
|
+
['m2', 'txn'] => expected,
|
188
|
+
'm3' => expected,
|
189
|
+
'm4' => expected
|
190
|
+
)
|
193
191
|
end
|
194
192
|
|
195
193
|
def test_record_scoped_and_unscoped_metrics_records_unscoped_if_not_in_txn
|
@@ -206,41 +204,22 @@ class NewRelic::Agent::MetricStatsTest < Minitest::Test
|
|
206
204
|
)
|
207
205
|
end
|
208
206
|
|
209
|
-
def test_get_no_scope
|
210
|
-
s1 = @engine.get_stats "a"
|
211
|
-
s2 = @engine.get_stats "a"
|
212
|
-
s3 = @engine.get_stats "b"
|
213
|
-
|
214
|
-
refute_nil s1
|
215
|
-
refute_nil s2
|
216
|
-
refute_nil s3
|
217
|
-
|
218
|
-
assert s1 == s2
|
219
|
-
refute_same(s1, s3)
|
220
|
-
end
|
221
|
-
|
222
207
|
def test_harvest
|
223
208
|
@engine.clear_stats
|
224
|
-
s1 = @engine.get_stats "a"
|
225
|
-
s2 = @engine.get_stats "c"
|
226
209
|
|
227
|
-
|
228
|
-
|
229
|
-
|
210
|
+
@engine.tl_record_unscoped_metrics "a", 10
|
211
|
+
@engine.tl_record_unscoped_metrics "c", 1
|
212
|
+
@engine.tl_record_unscoped_metrics "c", 3
|
230
213
|
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
assert_equal 4, @engine.get_stats("c").total_call_time
|
214
|
+
assert_metrics_recorded({
|
215
|
+
"a" => {:call_count => 1, :total_call_time => 10},
|
216
|
+
"c" => {:call_count => 2, :total_call_time => 4}
|
217
|
+
})
|
236
218
|
|
237
219
|
harvested = @engine.harvest!.to_h
|
238
220
|
|
239
221
|
# after harvest, all the metrics should be reset
|
240
|
-
|
241
|
-
assert_equal 0, @engine.get_stats("a").total_call_time
|
242
|
-
assert_equal 0, @engine.get_stats("c").call_count
|
243
|
-
assert_equal 0, @engine.get_stats("c").total_call_time
|
222
|
+
refute_metrics_recorded %w(a c)
|
244
223
|
|
245
224
|
spec_a = NewRelic::MetricSpec.new('a')
|
246
225
|
|
@@ -258,9 +237,9 @@ class NewRelic::Agent::MetricStatsTest < Minitest::Test
|
|
258
237
|
rules_engine = NewRelic::Agent::RulesEngine.new([rule])
|
259
238
|
|
260
239
|
@engine.metric_rules = rules_engine
|
261
|
-
@engine.
|
262
|
-
@engine.
|
263
|
-
@engine.
|
240
|
+
@engine.tl_record_unscoped_metrics('Custom/foo/1/bar/22', 1)
|
241
|
+
@engine.tl_record_unscoped_metrics('Custom/foo/3/bar/44', 1)
|
242
|
+
@engine.tl_record_unscoped_metrics('Custom/foo/5/bar/66', 1)
|
264
243
|
|
265
244
|
harvested = @engine.harvest!.to_h
|
266
245
|
|
@@ -290,16 +269,15 @@ class NewRelic::Agent::MetricStatsTest < Minitest::Test
|
|
290
269
|
end
|
291
270
|
|
292
271
|
def test_harvest_with_merge
|
293
|
-
|
294
|
-
|
295
|
-
assert_equal 1, @engine.get_stats("a").call_count
|
272
|
+
@engine.tl_record_unscoped_metrics "a", 1
|
273
|
+
assert_metrics_recorded "a" => {:call_count => 1, :total_call_time => 1}
|
296
274
|
|
297
275
|
harvest = @engine.harvest!
|
298
276
|
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
277
|
+
assert_metrics_not_recorded "a"
|
278
|
+
|
279
|
+
@engine.tl_record_unscoped_metrics "a", 2
|
280
|
+
assert_metrics_recorded "a" => {:call_count => 1, :total_call_time => 2}
|
303
281
|
|
304
282
|
# this should merge the contents of the previous harvest,
|
305
283
|
# so the stats for metric "a" should have 2 data points
|
@@ -311,7 +289,7 @@ class NewRelic::Agent::MetricStatsTest < Minitest::Test
|
|
311
289
|
end
|
312
290
|
|
313
291
|
def test_merge_merges
|
314
|
-
@engine.
|
292
|
+
@engine.tl_record_unscoped_metrics "foo", 1
|
315
293
|
|
316
294
|
other_stats_hash = NewRelic::Agent::StatsHash.new()
|
317
295
|
other_stats_hash.record(NewRelic::MetricSpec.new('foo'), 1)
|
@@ -319,10 +297,10 @@ class NewRelic::Agent::MetricStatsTest < Minitest::Test
|
|
319
297
|
|
320
298
|
@engine.merge!(other_stats_hash)
|
321
299
|
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
300
|
+
assert_metrics_recorded ({
|
301
|
+
'foo' => {:call_count => 2},
|
302
|
+
'bar' => {:call_count => 1}
|
303
|
+
})
|
326
304
|
end
|
327
305
|
|
328
306
|
def test_harvest_adds_harvested_at_time
|
@@ -168,18 +168,16 @@ class NewRelic::Agent::StatsTest < Minitest::Test
|
|
168
168
|
assert_equal(42, chained_stats.total_call_time)
|
169
169
|
end
|
170
170
|
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
s1.trace_call 7.to_r
|
171
|
+
def test_to_json_enforces_float_values
|
172
|
+
s1 = NewRelic::Agent::Stats.new
|
173
|
+
s1.trace_call 3.to_r
|
174
|
+
s1.trace_call 7.to_r
|
176
175
|
|
177
|
-
|
178
|
-
end
|
176
|
+
assert_equal 3.0, JSON.load(s1.to_json)['min_call_time']
|
179
177
|
end
|
180
178
|
|
181
179
|
private
|
182
|
-
def validate
|
180
|
+
def validate(stats, count, total, min, max, exclusive = nil)
|
183
181
|
assert_equal count, stats.call_count
|
184
182
|
assert_equal total, stats.total_call_time
|
185
183
|
assert_equal min, stats.min_call_time
|
@@ -3,7 +3,7 @@
|
|
3
3
|
# See https://github.com/newrelic/rpm/blob/master/LICENSE for complete details.
|
4
4
|
|
5
5
|
require File.expand_path(File.join(File.dirname(__FILE__),'..','..','test_helper'))
|
6
|
-
require '
|
6
|
+
require 'new_relic/agent/event_buffer_test_cases'
|
7
7
|
require 'new_relic/agent/synthetics_event_buffer'
|
8
8
|
|
9
9
|
module NewRelic::Agent
|
@@ -118,12 +118,8 @@ class AttributesTest < Minitest::Test
|
|
118
118
|
|
119
119
|
custom_attributes = attributes.custom_attributes_for(AttributeFilter::DST_TRANSACTION_TRACER)
|
120
120
|
result = custom_attributes["key"]
|
121
|
-
|
122
|
-
|
123
|
-
assert result.bytesize < NewRelic::Agent::Transaction::Attributes::VALUE_LIMIT
|
124
|
-
else
|
125
|
-
assert_equal NewRelic::Agent::Transaction::Attributes::VALUE_LIMIT, result.bytesize
|
126
|
-
end
|
121
|
+
assert result.valid_encoding?
|
122
|
+
assert result.bytesize < NewRelic::Agent::Transaction::Attributes::VALUE_LIMIT
|
127
123
|
end
|
128
124
|
|
129
125
|
def test_truncates_multibyte_symbol
|
@@ -135,12 +131,8 @@ class AttributesTest < Minitest::Test
|
|
135
131
|
|
136
132
|
custom_attributes = attributes.custom_attributes_for(AttributeFilter::DST_TRANSACTION_TRACER)
|
137
133
|
result = custom_attributes["key"]
|
138
|
-
|
139
|
-
|
140
|
-
assert result.bytesize < NewRelic::Agent::Transaction::Attributes::VALUE_LIMIT
|
141
|
-
else
|
142
|
-
assert_equal NewRelic::Agent::Transaction::Attributes::VALUE_LIMIT, result.bytesize
|
143
|
-
end
|
134
|
+
assert result.valid_encoding?
|
135
|
+
assert result.bytesize < NewRelic::Agent::Transaction::Attributes::VALUE_LIMIT
|
144
136
|
end
|
145
137
|
|
146
138
|
def test_limits_key_length
|
@@ -680,13 +680,6 @@ class NewRelic::Agent::TransactionTest < Minitest::Test
|
|
680
680
|
end
|
681
681
|
end
|
682
682
|
|
683
|
-
def test_user_attributes_alias_to_custom_parameters
|
684
|
-
in_transaction('user_attributes') do |txn|
|
685
|
-
txn.set_user_attributes(:set_instance => :set_instance)
|
686
|
-
assert_has_custom_attribute(txn, "set_instance")
|
687
|
-
end
|
688
|
-
end
|
689
|
-
|
690
683
|
def test_notice_error_in_current_transaction_saves_it_for_finishing
|
691
684
|
in_transaction('failing') do |txn|
|
692
685
|
NewRelic::Agent::Transaction.notice_error("")
|
@@ -885,11 +878,10 @@ class NewRelic::Agent::TransactionTest < Minitest::Test
|
|
885
878
|
end
|
886
879
|
|
887
880
|
def with_java_classes_loaded
|
888
|
-
|
889
|
-
::NewRelic::Agent::Transaction.send(:class_variable_set, :@@java_classes_loaded, true)
|
881
|
+
::NewRelic::Agent::Transaction.class_variable_set :@@java_classes_loaded, true
|
890
882
|
yield
|
891
883
|
ensure
|
892
|
-
::NewRelic::Agent::Transaction.
|
884
|
+
::NewRelic::Agent::Transaction.class_variable_set :@@java_classes_loaded, false
|
893
885
|
end
|
894
886
|
|
895
887
|
def test_cpu_burn_normal
|
@@ -7,6 +7,22 @@ require 'new_relic/agent/utilization_data'
|
|
7
7
|
|
8
8
|
module NewRelic::Agent
|
9
9
|
class UtilizationDataTest < Minitest::Test
|
10
|
+
|
11
|
+
# recurses through hashes and arrays and symbolizes keys
|
12
|
+
def self.symbolize_keys_in_object(object)
|
13
|
+
case object
|
14
|
+
when Hash
|
15
|
+
object.inject({}) do |memo, (k, v)|
|
16
|
+
memo[k.to_sym] = symbolize_keys_in_object(v)
|
17
|
+
memo
|
18
|
+
end
|
19
|
+
when Array
|
20
|
+
object.map {|o| symbolize_keys_in_object(o)}
|
21
|
+
else
|
22
|
+
object
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
10
26
|
def setup
|
11
27
|
stub_aws_info
|
12
28
|
end
|
@@ -170,7 +186,7 @@ module NewRelic::Agent
|
|
170
186
|
|
171
187
|
load_cross_agent_test("utilization/utilization_json").each do |test_case|
|
172
188
|
|
173
|
-
test_case =
|
189
|
+
test_case = NewRelic::Agent::UtilizationDataTest.symbolize_keys_in_object test_case
|
174
190
|
define_method("test_#{test_case[:testname]}".tr(" ", "_")) do
|
175
191
|
setup_cross_agent_test_stubs test_case
|
176
192
|
# This is a little bit ugly, but TravisCI runs these tests in a docker environment,
|
@@ -5,7 +5,7 @@
|
|
5
5
|
require File.expand_path(File.join(File.dirname(__FILE__),'..', '..','..','test_helper'))
|
6
6
|
require 'new_relic/agent/vm/mri_vm'
|
7
7
|
|
8
|
-
unless NewRelic::LanguageSupport.jruby?
|
8
|
+
unless NewRelic::LanguageSupport.jruby?
|
9
9
|
module NewRelic
|
10
10
|
module Agent
|
11
11
|
module VM
|
@@ -15,12 +15,10 @@ unless NewRelic::LanguageSupport.jruby? || NewRelic::LanguageSupport.rubinius?
|
|
15
15
|
@vm = MriVM.new
|
16
16
|
end
|
17
17
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
refute_nil @snap.gc_total_time
|
23
|
-
end
|
18
|
+
def test_gather_gc_time_sets_gc_total_time_if_gc_profiler_is_enabled
|
19
|
+
NewRelic::LanguageSupport.stubs(:gc_profiler_enabled?).returns(true)
|
20
|
+
@vm.gather_gc_time(@snap)
|
21
|
+
refute_nil @snap.gc_total_time
|
24
22
|
end
|
25
23
|
|
26
24
|
def test_gather_gc_time_does_not_set_gc_total_time_if_gc_profiler_is_disabled
|
@@ -63,12 +63,6 @@ module NewRelic
|
|
63
63
|
NewRelic::Agent.after_fork
|
64
64
|
end
|
65
65
|
|
66
|
-
def test_reset_stats
|
67
|
-
mock_agent = mocked_agent
|
68
|
-
mock_agent.expects(:drop_buffered_data)
|
69
|
-
NewRelic::Agent.reset_stats
|
70
|
-
end
|
71
|
-
|
72
66
|
def test_manual_start_default
|
73
67
|
mock_control = mocked_control
|
74
68
|
mock_control.expects(:init_plugin).with({:agent_enabled => true, :sync_startup => true})
|
@@ -100,23 +94,6 @@ module NewRelic
|
|
100
94
|
NewRelic::Agent.shutdown
|
101
95
|
end
|
102
96
|
|
103
|
-
def test_get_stats
|
104
|
-
agent = mocked_agent
|
105
|
-
mock_stats_engine = mock('stats_engine')
|
106
|
-
agent.expects(:stats_engine).returns(mock_stats_engine)
|
107
|
-
mock_stats_engine.expects(:get_stats).with('Custom/test/metric', false)
|
108
|
-
NewRelic::Agent.get_stats('Custom/test/metric')
|
109
|
-
end
|
110
|
-
|
111
|
-
# note that this is the same as get_stats above, they're just aliases
|
112
|
-
def test_get_stats_no_scope
|
113
|
-
agent = mocked_agent
|
114
|
-
mock_stats_engine = mock('stats_engine')
|
115
|
-
agent.expects(:stats_engine).returns(mock_stats_engine)
|
116
|
-
mock_stats_engine.expects(:get_stats).with('Custom/test/metric', false)
|
117
|
-
NewRelic::Agent.get_stats_no_scope('Custom/test/metric')
|
118
|
-
end
|
119
|
-
|
120
97
|
def test_agent_logs_warning_when_not_started
|
121
98
|
with_unstarted_agent do
|
122
99
|
expects_logging(:warn, includes("hasn't been started"))
|
@@ -137,11 +114,6 @@ module NewRelic
|
|
137
114
|
NewRelic::Agent.instance_eval { @agent = old_agent }
|
138
115
|
end
|
139
116
|
|
140
|
-
def test_abort_transaction_bang
|
141
|
-
NewRelic::Agent::Transaction.expects(:abort_transaction!)
|
142
|
-
NewRelic::Agent.abort_transaction!
|
143
|
-
end
|
144
|
-
|
145
117
|
def test_is_transaction_traced_true
|
146
118
|
NewRelic::Agent::TransactionState.tl_get.record_tt = true
|
147
119
|
assert_equal(true, NewRelic::Agent.tl_is_transaction_traced?, 'should be true since the thread local is set')
|
@@ -420,21 +392,6 @@ module NewRelic
|
|
420
392
|
end
|
421
393
|
end
|
422
394
|
|
423
|
-
def test_add_custom_parameters_deprecated
|
424
|
-
NewRelic::Agent::Deprecator.expects(:deprecate)
|
425
|
-
NewRelic::Agent.add_custom_parameters(:is => "bunk")
|
426
|
-
end
|
427
|
-
|
428
|
-
def test_add_request_parameters_deprecated
|
429
|
-
NewRelic::Agent::Deprecator.expects(:deprecate)
|
430
|
-
NewRelic::Agent.add_request_parameters(:is => "bunk")
|
431
|
-
end
|
432
|
-
|
433
|
-
def test_set_user_attributes_deprecated
|
434
|
-
NewRelic::Agent::Deprecator.expects(:deprecate)
|
435
|
-
NewRelic::Agent.set_user_attributes(:is => "bunk")
|
436
|
-
end
|
437
|
-
|
438
395
|
def test_modules_and_classes_return_name_properly
|
439
396
|
valid = [Module, Class]
|
440
397
|
stack = [NewRelic]
|
@@ -16,9 +16,7 @@ class CoerceTest < Minitest::Test
|
|
16
16
|
assert_equal 1, int(Rational(1, 1))
|
17
17
|
assert_equal 0, int("invalid")
|
18
18
|
assert_equal 0, int(nil)
|
19
|
-
|
20
|
-
# http://ruby-doc.org/core-1.8.7/Symbol.html#method-i-to_i
|
21
|
-
assert_equal 0, int(:wat) unless RUBY_VERSION < '1.9'
|
19
|
+
assert_equal 0, int(:wat)
|
22
20
|
end
|
23
21
|
|
24
22
|
def test_int_coerce_logs
|
@@ -10,7 +10,7 @@ require 'timeout'
|
|
10
10
|
require 'ostruct'
|
11
11
|
require 'fake_server'
|
12
12
|
|
13
|
-
require 'json'
|
13
|
+
require 'json'
|
14
14
|
|
15
15
|
module NewRelic
|
16
16
|
class FakeCollector < FakeServer
|
@@ -117,7 +117,7 @@ module NewRelic
|
|
117
117
|
if @mock.keys.include? method
|
118
118
|
status, body = @mock[method].evaluate
|
119
119
|
res.status = status
|
120
|
-
res.write ::
|
120
|
+
res.write ::JSON.dump(body)
|
121
121
|
else
|
122
122
|
res.status = 500
|
123
123
|
res.write "Method not found"
|
@@ -129,7 +129,7 @@ module NewRelic
|
|
129
129
|
raw_body = req.body.read
|
130
130
|
raw_body = Zlib::Inflate.inflate(raw_body) if req.env["HTTP_CONTENT_ENCODING"] == "deflate"
|
131
131
|
|
132
|
-
body = ::
|
132
|
+
body = ::JSON.load(raw_body)
|
133
133
|
rescue
|
134
134
|
body = "UNABLE TO DECODE BODY: #{raw_body}"
|
135
135
|
|
@@ -437,7 +437,7 @@ module HttpClientTestCases
|
|
437
437
|
# https://newrelic.atlassian.net/browse/RUBY-1244
|
438
438
|
def test_failure_in_our_start_code_still_records_externals
|
439
439
|
# Fake a failure in our start-up code...
|
440
|
-
|
440
|
+
::JSON.stubs(:dump).raises("Boom!")
|
441
441
|
|
442
442
|
with_config(:"cross_application_tracer.enabled" => true) do
|
443
443
|
in_transaction { get_response }
|
@@ -449,7 +449,7 @@ module HttpClientTestCases
|
|
449
449
|
# https://newrelic.atlassian.net/browse/RUBY-1244
|
450
450
|
def test_failure_to_add_tt_node_doesnt_append_params_to_wrong_node
|
451
451
|
# Fake a failure in our start-up code...
|
452
|
-
|
452
|
+
::JSON.stubs(:dump).raises("Boom!")
|
453
453
|
|
454
454
|
in_transaction do
|
455
455
|
with_config(:"cross_application_tracer.enabled" => true) do
|
@@ -606,7 +606,7 @@ module HttpClientTestCases
|
|
606
606
|
|
607
607
|
def decode_payload(payload)
|
608
608
|
obfuscator = NewRelic::Agent::Obfuscator.new('gringletoes')
|
609
|
-
|
609
|
+
::JSON.load(obfuscator.deobfuscate(payload))
|
610
610
|
end
|
611
611
|
|
612
612
|
def set_explicit_transaction_name(name)
|