newrelic_rpm 3.10.0.279 → 3.11.0.283
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/CHANGELOG +61 -0
- data/lib/new_relic/agent.rb +14 -8
- data/lib/new_relic/agent/agent.rb +43 -28
- data/lib/new_relic/agent/agent_logger.rb +21 -20
- data/lib/new_relic/agent/configuration/default_source.rb +31 -1
- data/lib/new_relic/agent/database.rb +2 -1
- data/lib/new_relic/agent/datastores.rb +177 -0
- data/lib/new_relic/agent/datastores/metric_helper.rb +85 -0
- data/lib/new_relic/agent/datastores/mongo/metric_translator.rb +11 -20
- data/lib/new_relic/agent/deprecator.rb +18 -0
- data/lib/new_relic/agent/instrumentation/active_record.rb +20 -35
- data/lib/new_relic/agent/instrumentation/active_record_helper.rb +116 -57
- data/lib/new_relic/agent/instrumentation/active_record_subscriber.rb +11 -20
- data/lib/new_relic/agent/instrumentation/data_mapper.rb +104 -172
- data/lib/new_relic/agent/instrumentation/memcache.rb +104 -52
- data/lib/new_relic/agent/instrumentation/metric_frame.rb +9 -0
- data/lib/new_relic/agent/instrumentation/middleware_proxy.rb +15 -2
- data/lib/new_relic/agent/instrumentation/mongo.rb +5 -18
- data/lib/new_relic/agent/instrumentation/sequel_helper.rb +36 -0
- data/lib/new_relic/agent/new_relic_service.rb +4 -0
- data/lib/new_relic/agent/stats_engine/metric_stats.rb +2 -17
- data/lib/new_relic/agent/threading/backtrace_service.rb +28 -5
- data/lib/new_relic/agent/transaction.rb +63 -34
- data/lib/new_relic/agent/transaction_event_aggregator.rb +0 -4
- data/lib/new_relic/agent/transaction_sampler.rb +11 -5
- data/lib/new_relic/rack/error_collector.rb +0 -1
- data/lib/new_relic/version.rb +1 -1
- data/lib/sequel/extensions/newrelic_instrumentation.rb +28 -56
- data/lib/sequel/plugins/newrelic_instrumentation.rb +28 -45
- data/newrelic_rpm.gemspec +0 -7
- data/test/agent_helper.rb +35 -16
- data/test/environments/rails31/Gemfile +1 -0
- data/test/environments/rails32/Gemfile +1 -0
- data/test/helpers/mongo_metric_builder.rb +2 -3
- data/test/multiverse/lib/multiverse/output_collector.rb +24 -9
- data/test/multiverse/lib/multiverse/suite.rb +5 -0
- data/test/multiverse/suites/active_record/Envfile +6 -4
- data/test/multiverse/suites/active_record/active_record_test.rb +32 -73
- data/test/multiverse/suites/active_record/ar_method_aliasing.rb +0 -1
- data/test/multiverse/suites/activemerchant/activemerchant_test.rb +0 -3
- data/test/multiverse/suites/agent_only/agent_run_id_handling_test.rb +0 -1
- data/test/multiverse/suites/agent_only/audit_log_test.rb +0 -1
- data/test/multiverse/suites/agent_only/collector_exception_handling_test.rb +0 -2
- data/test/multiverse/suites/agent_only/cross_application_tracing_test.rb +0 -1
- data/test/multiverse/suites/agent_only/custom_analytics_events_test.rb +0 -2
- data/test/multiverse/suites/agent_only/custom_queue_time_test.rb +0 -1
- data/test/multiverse/suites/agent_only/encoding_handling_test.rb +0 -2
- data/test/multiverse/suites/agent_only/exclusive_time_test.rb +0 -2
- data/test/multiverse/suites/agent_only/harvest_timestamps_test.rb +0 -1
- data/test/multiverse/suites/agent_only/http_response_code_test.rb +0 -1
- data/test/multiverse/suites/agent_only/keepalive_test.rb +0 -1
- data/test/multiverse/suites/agent_only/key_transactions_test.rb +54 -9
- data/test/multiverse/suites/agent_only/labels_test.rb +0 -2
- data/test/multiverse/suites/agent_only/logging_test.rb +0 -1
- data/test/multiverse/suites/agent_only/marshaling_test.rb +0 -1
- data/test/multiverse/suites/agent_only/pipe_manager_test.rb +0 -2
- data/test/multiverse/suites/agent_only/rename_rule_test.rb +5 -7
- data/test/multiverse/suites/agent_only/rum_instrumentation_test.rb +0 -1
- data/test/multiverse/suites/agent_only/set_transaction_name_test.rb +0 -2
- data/test/multiverse/suites/agent_only/ssl_test.rb +0 -2
- data/test/multiverse/suites/agent_only/synthetics_test.rb +0 -1
- data/test/multiverse/suites/agent_only/testing_app.rb +21 -0
- data/test/multiverse/suites/agent_only/thread_profiling_test.rb +1 -2
- data/test/multiverse/suites/agent_only/transaction_ignoring_test.rb +0 -2
- data/test/multiverse/suites/agent_only/utilization_data_collection_test.rb +0 -1
- data/test/multiverse/suites/agent_only/xray_sessions_test.rb +69 -34
- data/test/multiverse/suites/capistrano/deployment_test.rb +0 -1
- data/test/multiverse/suites/capistrano2/deployment_test.rb +0 -1
- data/test/multiverse/suites/config_file_loading/config_file_loading_test.rb +0 -2
- data/test/multiverse/suites/curb/curb_test.rb +0 -2
- data/test/multiverse/suites/datamapper/Envfile +26 -3
- data/test/multiverse/suites/datamapper/config/newrelic.yml +1 -0
- data/test/multiverse/suites/datamapper/datamapper_test.rb +271 -37
- data/test/multiverse/suites/deferred_instrumentation/sinatra_test.rb +0 -1
- data/test/multiverse/suites/delayed_job/Envfile +31 -8
- data/test/multiverse/suites/delayed_job/delayed_job_sampler_test.rb +0 -3
- data/test/multiverse/suites/delayed_job/unsupported_backend_test.rb +0 -3
- data/test/multiverse/suites/excon/excon_test.rb +0 -2
- data/test/multiverse/suites/grape/grape_test.rb +0 -3
- data/test/multiverse/suites/grape/grape_versioning_test.rb +0 -3
- data/test/multiverse/suites/grape/unsupported_version_test.rb +0 -3
- data/test/multiverse/suites/high_security/high_security_test.rb +0 -1
- data/test/multiverse/suites/httpclient/httpclient_test.rb +0 -2
- data/test/multiverse/suites/json/json_test.rb +0 -1
- data/test/multiverse/suites/marshalling/marshalling_test.rb +0 -1
- data/test/multiverse/suites/memcached/Envfile +52 -0
- data/test/multiverse/suites/memcached/dalli_test.rb +89 -0
- data/test/multiverse/suites/memcached/memcache_client_test.rb +25 -0
- data/test/multiverse/suites/memcached/memcache_test_cases.rb +302 -0
- data/test/multiverse/suites/memcached/memcached_test.rb +159 -0
- data/test/multiverse/suites/mongo/helpers/mongo_operation_tests.rb +26 -17
- data/test/multiverse/suites/mongo/mongo_connection_test.rb +0 -1
- data/test/multiverse/suites/mongo/mongo_instrumentation_test.rb +0 -1
- data/test/multiverse/suites/mongo/mongo_unsupported_version_test.rb +0 -1
- data/test/multiverse/suites/net_http/net_http_test.rb +0 -2
- data/test/multiverse/suites/padrino/padrino_test.rb +0 -3
- data/test/multiverse/suites/rack/http_response_code_test.rb +0 -1
- data/test/multiverse/suites/rack/nested_non_rack_app_test.rb +1 -1
- data/test/multiverse/suites/rack/rack_auto_instrumentation_test.rb +12 -12
- 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/rack_parameter_filtering_test.rb +0 -1
- data/test/multiverse/suites/rack/rack_unsupported_version_test.rb +0 -2
- data/test/multiverse/suites/rack/url_map_test.rb +3 -2
- data/test/multiverse/suites/rails/Envfile +3 -0
- data/test/multiverse/suites/rails/activejob_test.rb +0 -1
- data/test/multiverse/suites/rails/app.rb +0 -1
- data/test/multiverse/suites/rails/parameter_capture_test.rb +13 -0
- data/test/multiverse/suites/rails/rails3_app/app_rails3_plus.rb +5 -0
- data/test/multiverse/suites/rails/transaction_ignoring_test.rb +0 -2
- data/test/multiverse/suites/resque/instrumentation_test.rb +0 -2
- data/test/multiverse/suites/resque/resque_marshalling_test.rb +0 -1
- data/test/multiverse/suites/sequel/sequel_extension_test.rb +135 -0
- data/test/multiverse/suites/sequel/sequel_helpers.rb +62 -0
- data/test/multiverse/suites/sequel/sequel_plugin_test.rb +230 -0
- data/test/multiverse/suites/sidekiq/sidekiq_instrumentation_test.rb +0 -2
- data/test/multiverse/suites/sinatra/ignoring_test.rb +0 -2
- data/test/multiverse/suites/sinatra/nested_middleware_test.rb +0 -2
- data/test/multiverse/suites/sinatra/sinatra_classic_test.rb +0 -1
- data/test/multiverse/suites/sinatra/sinatra_error_tracing_test.rb +0 -2
- data/test/multiverse/suites/sinatra/sinatra_metric_explosion_test.rb +14 -12
- data/test/multiverse/suites/sinatra/sinatra_modular_test.rb +0 -1
- data/test/multiverse/suites/sinatra/sinatra_routes_test.rb +0 -2
- data/test/multiverse/suites/sinatra/sinatra_test_cases.rb +0 -2
- data/test/multiverse/suites/typhoeus/typhoeus_test.rb +0 -2
- data/test/multiverse/suites/yajl/yajl_test.rb +0 -1
- data/test/new_relic/agent/agent/start_test.rb +2 -2
- data/test/new_relic/agent/agent_logger_test.rb +6 -3
- data/test/new_relic/agent/datastores/metric_helper_test.rb +61 -0
- data/test/new_relic/agent/datastores/mongo/metric_translator_test.rb +20 -21
- data/test/new_relic/agent/datastores_test.rb +195 -0
- data/test/new_relic/agent/deprecator_test.rb +52 -0
- data/test/new_relic/agent/instrumentation/action_view_subscriber_test.rb +20 -26
- data/test/new_relic/agent/instrumentation/active_record_helper_test.rb +58 -53
- data/test/new_relic/agent/instrumentation/active_record_subscriber_test.rb +7 -20
- data/test/new_relic/agent/instrumentation/middleware_proxy_test.rb +19 -0
- data/test/new_relic/agent/instrumentation/sequel_helper_test.rb +36 -0
- data/test/new_relic/agent/instrumentation/task_instrumentation_test.rb +1 -0
- data/test/new_relic/agent/method_tracer_test.rb +3 -4
- data/test/new_relic/agent/pipe_channel_manager_test.rb +1 -1
- data/test/new_relic/agent/threading/backtrace_service_test.rb +29 -4
- data/test/new_relic/agent/transaction_event_aggregator_test.rb +0 -4
- data/test/new_relic/agent/transaction_test.rb +100 -2
- data/test/new_relic/agent_test.rb +3 -3
- data/test/new_relic/http_client_test_cases.rb +0 -1
- data/test/new_relic/multiverse_helpers.rb +7 -0
- data/test/new_relic/transaction_ignoring_test_cases.rb +0 -2
- data/test/new_relic/transaction_sample_test.rb +11 -2
- data/test/performance/README.md +37 -17
- data/test/performance/lib/performance.rb +1 -0
- data/test/performance/lib/performance/baseline_compare_reporter.rb +11 -7
- data/test/performance/lib/performance/console_reporter.rb +29 -5
- data/test/performance/lib/performance/formatting_helpers.rb +22 -0
- data/test/performance/lib/performance/instrumentation/stackprof.rb +11 -1
- data/test/performance/lib/performance/result.rb +17 -6
- data/test/performance/lib/performance/runner.rb +7 -3
- data/test/performance/lib/performance/test_case.rb +89 -21
- data/test/performance/script/runner +13 -1
- data/test/performance/suites/active_record.rb +47 -0
- data/test/performance/suites/config.rb +4 -48
- data/test/performance/suites/marshalling.rb +20 -30
- data/test/performance/suites/queue_time.rb +1 -1
- data/test/performance/suites/rack_middleware.rb +1 -1
- data/test/performance/suites/rum_autoinsertion.rb +1 -1
- data/test/performance/suites/sql_obfuscation.rb +2 -2
- data/test/performance/suites/startup.rb +1 -1
- data/test/performance/suites/stats_hash.rb +7 -11
- data/test/performance/suites/thread_profiling.rb +20 -25
- data/test/performance/suites/trace_execution_scoped.rb +2 -2
- data/test/performance/suites/transaction_tracing.rb +4 -2
- data/test/test_helper.rb +5 -1
- metadata +53 -100
- data.tar.gz.sig +0 -0
- data/gem-public_cert.pem +0 -20
- data/lib/new_relic/agent/datastores/mongo/metric_generator.rb +0 -33
- data/test/multiverse/suites/sequel/sequel_instrumentation_test.rb +0 -289
- data/test/new_relic/agent/datastores/mongo/metric_generator_test.rb +0 -69
- data/test/new_relic/agent/memcache_instrumentation_test.rb +0 -155
- metadata.gz.sig +0 -2
data.tar.gz.sig
DELETED
Binary file
|
data/gem-public_cert.pem
DELETED
@@ -1,20 +0,0 @@
|
|
1
|
-
-----BEGIN CERTIFICATE-----
|
2
|
-
MIIDODCCAiCgAwIBAgIBADANBgkqhkiG9w0BAQUFADBCMREwDwYDVQQDDAhzZWN1
|
3
|
-
cml0eTEYMBYGCgmSJomT8ixkARkWCG5ld3JlbGljMRMwEQYKCZImiZPyLGQBGRYD
|
4
|
-
Y29tMB4XDTE0MDIxMjIzMzUzMloXDTE1MDIxMjIzMzUzMlowQjERMA8GA1UEAwwI
|
5
|
-
c2VjdXJpdHkxGDAWBgoJkiaJk/IsZAEZFghuZXdyZWxpYzETMBEGCgmSJomT8ixk
|
6
|
-
ARkWA2NvbTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBANxaTfJVp22V
|
7
|
-
JCFhQTS0Zuyo66ZknUwwoVbhuSoXJ0mo9PZSifiIwr9aHmM9dpSztUamDvXesLpP
|
8
|
-
8HESyhe3sgpK0z7UXbDmtWZZx43qulx3xTObLQauVZcxP8qqGqvRzdovqXnFe8lN
|
9
|
-
sRUnXQjm9kArMI8uHhcU7XvlbQeTtPcjP0U/ZSyKABsJXRamQ/SVCPXqAHXv+OWP
|
10
|
-
t4yDB/MrAQFVSoNisyYtB7Af/izqw0/cnUCAOXGQL24l4Ir0dwMd0K6oAnaG93DB
|
11
|
-
v6yb30VT5elw40BeIhBsjZP731vRgXIlIKYwhVAlkvRkexAy9kH456Vt0fDBBYka
|
12
|
-
eE53BhdcguUCAwEAAaM5MDcwCQYDVR0TBAIwADAdBgNVHQ4EFgQUPJxv/VCFdHOH
|
13
|
-
lINeV2xQGQhFthEwCwYDVR0PBAQDAgSwMA0GCSqGSIb3DQEBBQUAA4IBAQDRCiPq
|
14
|
-
50B4sJN0Gj2T+9g+uXtC845mJD+0BlsAVjLcc+TchxxD3BYeln9c2ErPSIrzZ92Q
|
15
|
-
YlwLvw99ksJ5Qa/tAJCUyE3u9JuldalewRi/FHjoGcdhjUErzIyHtNlnCbTMfScz
|
16
|
-
5T+r8iUhvt0tcZ0/dQ1LFN8vMizN4Rm6JMXsmkHHxuosllQ9Q14sCYd2ekk2UF0l
|
17
|
-
59Jd6iWx3iVmUHSQNXiAdEihcwcx3e71dBNzl6FiR328PzniUjrhoSKzVLQv+JlR
|
18
|
-
1fUxkomKs2EL+FYMwnAb+VmNOhv1S+sJhbjZ30PKgz6vLhT6unieCjLk9wGGmlSK
|
19
|
-
YjbnvA9qraLLajSj
|
20
|
-
-----END CERTIFICATE-----
|
@@ -1,33 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
# This file is distributed under New Relic's license terms.
|
3
|
-
# See https://github.com/newrelic/rpm/blob/master/LICENSE for complete details.
|
4
|
-
|
5
|
-
require 'new_relic/agent/datastores/mongo/metric_translator'
|
6
|
-
|
7
|
-
module NewRelic
|
8
|
-
module Agent
|
9
|
-
module Datastores
|
10
|
-
module Mongo
|
11
|
-
module MetricGenerator
|
12
|
-
def self.generate_metrics_for(name, payload)
|
13
|
-
if NewRelic::Agent::Transaction.recording_web_transaction?
|
14
|
-
request_type = :web
|
15
|
-
else
|
16
|
-
request_type = :other
|
17
|
-
end
|
18
|
-
|
19
|
-
NewRelic::Agent::Datastores::Mongo::MetricTranslator.metrics_for(name, payload, request_type)
|
20
|
-
rescue => e
|
21
|
-
NewRelic::Agent.logger.debug("Failure during Mongo metric generation", e)
|
22
|
-
[]
|
23
|
-
end
|
24
|
-
|
25
|
-
def self.generate_instance_metric_for(host, port, database_name)
|
26
|
-
return unless host && port && database_name
|
27
|
-
NewRelic::Agent::Datastores::Mongo::MetricTranslator.instance_metric(host, port, database_name)
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
@@ -1,289 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
# This file is distributed under New Relic's license terms.
|
3
|
-
# See https://github.com/newrelic/rpm/blob/master/LICENSE for complete details.
|
4
|
-
|
5
|
-
require File.join(File.dirname(__FILE__), 'database.rb')
|
6
|
-
|
7
|
-
if Sequel.const_defined?( :MAJOR ) &&
|
8
|
-
( Sequel::MAJOR > 3 ||
|
9
|
-
Sequel::MAJOR == 3 && Sequel::MINOR >= 37 )
|
10
|
-
|
11
|
-
require 'newrelic_rpm'
|
12
|
-
require File.join(File.dirname(__FILE__), '..', '..', '..', 'agent_helper')
|
13
|
-
|
14
|
-
class NewRelic::Agent::Instrumentation::SequelInstrumentationTest < Minitest::Test
|
15
|
-
|
16
|
-
def setup
|
17
|
-
super
|
18
|
-
|
19
|
-
DB.extension :newrelic_instrumentation
|
20
|
-
|
21
|
-
NewRelic::Agent.manual_start
|
22
|
-
NewRelic::Agent.instance.transaction_sampler.reset!
|
23
|
-
NewRelic::Agent.instance.stats_engine.clear_stats
|
24
|
-
end
|
25
|
-
|
26
|
-
def teardown
|
27
|
-
super
|
28
|
-
|
29
|
-
NewRelic::Agent.shutdown
|
30
|
-
end
|
31
|
-
|
32
|
-
def test_sequel_database_instrumentation_is_loaded
|
33
|
-
assert DB.respond_to?( :primary_metric_for )
|
34
|
-
end
|
35
|
-
|
36
|
-
def test_sequel_model_instrumentation_is_loaded
|
37
|
-
assert Post.respond_to?( :trace_execution_scoped )
|
38
|
-
end
|
39
|
-
|
40
|
-
def test_model_enumerator_generates_metrics
|
41
|
-
in_web_transaction { Post.all }
|
42
|
-
|
43
|
-
assert_remote_service_metrics
|
44
|
-
assert_metrics_recorded([
|
45
|
-
"Database/SQL/select",
|
46
|
-
"ActiveRecord/all",
|
47
|
-
"ActiveRecord/#{Post.name}/all"
|
48
|
-
])
|
49
|
-
end
|
50
|
-
|
51
|
-
def test_model_index_operator_generates_metrics
|
52
|
-
in_web_transaction { Post[11] }
|
53
|
-
|
54
|
-
assert_remote_service_metrics
|
55
|
-
assert_metrics_recorded([
|
56
|
-
"Database/SQL/select",
|
57
|
-
"ActiveRecord/all",
|
58
|
-
"ActiveRecord/#{Post.name}/get"
|
59
|
-
])
|
60
|
-
end
|
61
|
-
|
62
|
-
def test_model_create_method_generates_metrics
|
63
|
-
in_web_transaction do
|
64
|
-
Post.create( :title => 'The Thing', :content => 'A wicked short story.' )
|
65
|
-
end
|
66
|
-
|
67
|
-
assert_remote_service_metrics
|
68
|
-
assert_metrics_recorded([
|
69
|
-
'Database/SQL/insert',
|
70
|
-
'ActiveRecord/all',
|
71
|
-
"ActiveRecord/#{Post.name}/create"
|
72
|
-
])
|
73
|
-
end
|
74
|
-
|
75
|
-
def test_model_update_method_generates_metrics
|
76
|
-
in_web_transaction do
|
77
|
-
post = Post.create( :title => 'All The Things', :content => 'A story about beans.' )
|
78
|
-
post.update( :title => 'A Lot of the Things' )
|
79
|
-
end
|
80
|
-
|
81
|
-
assert_remote_service_metrics
|
82
|
-
assert_metrics_recorded([
|
83
|
-
'Database/SQL/update',
|
84
|
-
'ActiveRecord/all',
|
85
|
-
"ActiveRecord/#{Post.name}/update"
|
86
|
-
])
|
87
|
-
end
|
88
|
-
|
89
|
-
def test_model_update_all_method_generates_metrics
|
90
|
-
in_web_transaction do
|
91
|
-
post = Post.create( :title => 'All The Things', :content => 'A nicer story than yours.' )
|
92
|
-
post.update_all( :title => 'A Whole Hell of a Lot of the Things' )
|
93
|
-
end
|
94
|
-
|
95
|
-
assert_remote_service_metrics
|
96
|
-
assert_metrics_recorded([
|
97
|
-
"Database/SQL/update",
|
98
|
-
"ActiveRecord/all",
|
99
|
-
"ActiveRecord/#{Post.name}/update_all"
|
100
|
-
])
|
101
|
-
end
|
102
|
-
|
103
|
-
def test_model_update_except_method_generates_metrics
|
104
|
-
in_web_transaction do
|
105
|
-
post = Post.create( :title => 'All The Things', :content => 'A story.' )
|
106
|
-
post.update_except( {:title => 'A Bit More of the Things'} )
|
107
|
-
end
|
108
|
-
|
109
|
-
assert_remote_service_metrics
|
110
|
-
assert_metrics_recorded([
|
111
|
-
"Database/SQL/update",
|
112
|
-
"ActiveRecord/all",
|
113
|
-
"ActiveRecord/#{Post.name}/update_except"
|
114
|
-
])
|
115
|
-
end
|
116
|
-
|
117
|
-
def test_model_update_fields_method_generates_metrics
|
118
|
-
in_web_transaction do
|
119
|
-
post = Post.create( :title => 'All The Things', :content => 'A venal short story.' )
|
120
|
-
post.update_fields( {:title => 'A Plethora of Things'}, [:title] )
|
121
|
-
end
|
122
|
-
|
123
|
-
assert_remote_service_metrics
|
124
|
-
assert_metrics_recorded([
|
125
|
-
"Database/SQL/update",
|
126
|
-
"ActiveRecord/all",
|
127
|
-
"ActiveRecord/#{Post.name}/update_fields"
|
128
|
-
])
|
129
|
-
end
|
130
|
-
|
131
|
-
def test_model_update_only_method_generates_metrics
|
132
|
-
in_web_transaction do
|
133
|
-
post = Post.create( :title => 'All The Things', :content => 'A meandering short story.' )
|
134
|
-
post.update_only( {:title => 'A Lot of the Things'}, :title )
|
135
|
-
end
|
136
|
-
|
137
|
-
assert_remote_service_metrics
|
138
|
-
assert_metrics_recorded([
|
139
|
-
"Database/SQL/update",
|
140
|
-
"ActiveRecord/all",
|
141
|
-
"ActiveRecord/#{Post.name}/update_only"
|
142
|
-
])
|
143
|
-
end
|
144
|
-
|
145
|
-
def test_model_save_method_generates_metrics
|
146
|
-
in_web_transaction do
|
147
|
-
post = Post.new( :title => 'An Endless Lot Full of Things',
|
148
|
-
:content => 'A lingering long story.' )
|
149
|
-
post.save
|
150
|
-
end
|
151
|
-
|
152
|
-
assert_remote_service_metrics
|
153
|
-
assert_metrics_recorded([
|
154
|
-
"Database/SQL/insert",
|
155
|
-
"ActiveRecord/all",
|
156
|
-
"ActiveRecord/#{Post.name}/save"
|
157
|
-
])
|
158
|
-
end
|
159
|
-
|
160
|
-
def test_model_delete_method_generates_metrics
|
161
|
-
in_web_transaction do
|
162
|
-
post = Post.create( :title => 'All The Things', :content => 'A nice short story.' )
|
163
|
-
post.delete
|
164
|
-
end
|
165
|
-
|
166
|
-
assert_remote_service_metrics
|
167
|
-
assert_metrics_recorded([
|
168
|
-
"Database/SQL/delete",
|
169
|
-
"ActiveRecord/all",
|
170
|
-
"ActiveRecord/#{Post.name}/delete"
|
171
|
-
])
|
172
|
-
end
|
173
|
-
|
174
|
-
def test_model_destroy_method_generates_metrics
|
175
|
-
in_web_transaction do
|
176
|
-
post = Post.create( :title => 'Most of the Things', :content => 'Another short story.' )
|
177
|
-
post.destroy
|
178
|
-
end
|
179
|
-
|
180
|
-
assert_remote_service_metrics
|
181
|
-
assert_metrics_recorded([
|
182
|
-
"Database/SQL/delete",
|
183
|
-
"ActiveRecord/all",
|
184
|
-
"ActiveRecord/#{Post.name}/destroy"
|
185
|
-
])
|
186
|
-
end
|
187
|
-
|
188
|
-
def test_model_destroy_uses_the_class_name_for_the_metric
|
189
|
-
in_web_transaction do
|
190
|
-
author = Author.create( :name => 'Marlon Forswytthe', :login => 'mfors' )
|
191
|
-
author.destroy
|
192
|
-
end
|
193
|
-
|
194
|
-
assert_remote_service_metrics
|
195
|
-
assert_metrics_recorded([
|
196
|
-
"Database/SQL/delete",
|
197
|
-
"ActiveRecord/all",
|
198
|
-
"ActiveRecord/#{Author.name}/destroy"
|
199
|
-
])
|
200
|
-
end
|
201
|
-
|
202
|
-
def test_slow_queries_get_an_explain_plan
|
203
|
-
with_config( :'transaction_tracer.explain_threshold' => -0.01,
|
204
|
-
:'transaction_tracer.record_sql' => 'raw' ) do
|
205
|
-
segment = last_segment_for do
|
206
|
-
Post[11]
|
207
|
-
end
|
208
|
-
assert_match %r{select \* from `posts` where `id` = 11}i, segment.params[:sql]
|
209
|
-
assert_segment_has_explain_plan( segment )
|
210
|
-
end
|
211
|
-
end
|
212
|
-
|
213
|
-
def test_no_explain_plans_with_single_threaded_connection
|
214
|
-
connect_opts = DB.opts
|
215
|
-
single_threaded_db = Sequel.connect(connect_opts.merge(:single_threaded => true))
|
216
|
-
create_tables(single_threaded_db)
|
217
|
-
model_class = Class.new(Sequel::Model(single_threaded_db[:posts]))
|
218
|
-
|
219
|
-
with_config(:'transaction_tracer.explain_threshold' => -0.01,
|
220
|
-
:'transaction_tracer.record_sql' => 'raw') do
|
221
|
-
segment = last_segment_for do
|
222
|
-
model_class[11]
|
223
|
-
end
|
224
|
-
assert_match %r{select \* from `posts` where `id` = 11}i, segment.params[:sql]
|
225
|
-
assert_equal([], segment.params[:explain_plan], "Should not capture explain plan with single-threaded connection pool")
|
226
|
-
end
|
227
|
-
end
|
228
|
-
|
229
|
-
def test_queries_can_get_explain_plan_with_obfuscated_sql
|
230
|
-
config = {
|
231
|
-
:'transaction_tracer.explain_threshold' => -0.01,
|
232
|
-
:'transaction_tracer.record_sql' => 'obfuscated'
|
233
|
-
}
|
234
|
-
with_config(config) do
|
235
|
-
segment = last_segment_for(:record_sql => :obfuscated) do
|
236
|
-
Post[11]
|
237
|
-
end
|
238
|
-
assert_match %r{select \* from `posts` where `id` = \?}i, segment.params[:sql]
|
239
|
-
assert_segment_has_explain_plan( segment )
|
240
|
-
end
|
241
|
-
end
|
242
|
-
|
243
|
-
|
244
|
-
#
|
245
|
-
# Helpers
|
246
|
-
#
|
247
|
-
|
248
|
-
# Pattern to match the column headers of a Sqlite explain plan
|
249
|
-
SQLITE_EXPLAIN_PLAN_COLUMNS_RE =
|
250
|
-
%r{\|addr\s*\|opcode\s*\|p1\s*\|p2\s*\|p3\s*\|p4\s*\|p5\s*\|comment\s*\|}
|
251
|
-
|
252
|
-
# This is particular to sqlite plans currently. To abstract it up, we'd need to
|
253
|
-
# be able to specify a flavor (e.g., :sqlite, :postgres, :mysql, etc.)
|
254
|
-
def assert_segment_has_explain_plan( segment, msg=nil )
|
255
|
-
msg = "Expected #{segment.inspect} to have an explain plan"
|
256
|
-
assert_block( msg ) { segment.params[:explain_plan].join =~ SQLITE_EXPLAIN_PLAN_COLUMNS_RE }
|
257
|
-
end
|
258
|
-
|
259
|
-
def assert_remote_service_metrics
|
260
|
-
engine = NewRelic::Agent.instance.stats_engine
|
261
|
-
if (jruby?)
|
262
|
-
assert engine.metrics.none? {|s| s.start_with?("RemoteService/")}, "Sqlite on JRuby doesn't report adapter right for this metric. Why's it here?"
|
263
|
-
else
|
264
|
-
assert_includes engine.metrics, "RemoteService/sql/sqlite/localhost"
|
265
|
-
end
|
266
|
-
end
|
267
|
-
|
268
|
-
def last_segment_for(options={})
|
269
|
-
in_transaction('sandwiches/index') do
|
270
|
-
yield
|
271
|
-
end
|
272
|
-
sample = NewRelic::Agent.instance.transaction_sampler.last_sample
|
273
|
-
sample.prepare_to_send!
|
274
|
-
last_segment(sample)
|
275
|
-
end
|
276
|
-
|
277
|
-
def last_segment(txn_sample)
|
278
|
-
l_segment = nil
|
279
|
-
txn_sample.root_segment.each_segment do |segment|
|
280
|
-
l_segment = segment
|
281
|
-
end
|
282
|
-
l_segment
|
283
|
-
end
|
284
|
-
|
285
|
-
end
|
286
|
-
|
287
|
-
else
|
288
|
-
puts "Skipping tests in #{__FILE__} because unsupported Sequel version"
|
289
|
-
end
|
@@ -1,69 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
# This file is distributed under New Relic's license terms.
|
3
|
-
# See https://github.com/newrelic/rpm/blob/master/LICENSE for complete details.
|
4
|
-
|
5
|
-
require File.expand_path(File.join(File.dirname(__FILE__),'..','..','..','..','test_helper'))
|
6
|
-
require 'new_relic/agent/datastores/mongo/metric_generator'
|
7
|
-
|
8
|
-
class NewRelic::Agent::Datastores::Mongo::MetricGeneratorTest < Minitest::Test
|
9
|
-
include ::NewRelic::TestHelpers::MongoMetricBuilder
|
10
|
-
|
11
|
-
def setup
|
12
|
-
@payload = { :collection => 'tribbles', :database => 'enterprise' }
|
13
|
-
end
|
14
|
-
|
15
|
-
def test_generate_metrics_for_includes_all_web_for_web_requests
|
16
|
-
NewRelic::Agent::Transaction.stubs(:recording_web_transaction?).returns(true)
|
17
|
-
metrics = NewRelic::Agent::Datastores::Mongo::MetricGenerator.generate_metrics_for(:insert, @payload)
|
18
|
-
|
19
|
-
assert_includes metrics, 'Datastore/allWeb'
|
20
|
-
end
|
21
|
-
|
22
|
-
def test_generate_metrics_for_does_not_include_all_other_for_web_requests
|
23
|
-
NewRelic::Agent::Transaction.stubs(:recording_web_transaction?).returns(true)
|
24
|
-
metrics = NewRelic::Agent::Datastores::Mongo::MetricGenerator.generate_metrics_for(:insert, @payload)
|
25
|
-
|
26
|
-
refute metrics.include? 'Datastore/allOther'
|
27
|
-
end
|
28
|
-
|
29
|
-
def test_generate_metrics_for_includes_all_other_for_other_requests
|
30
|
-
NewRelic::Agent::Transaction.stubs(:recording_web_transaction?).returns(false)
|
31
|
-
metrics = NewRelic::Agent::Datastores::Mongo::MetricGenerator.generate_metrics_for(:insert, @payload)
|
32
|
-
|
33
|
-
assert_includes metrics, 'Datastore/allOther'
|
34
|
-
end
|
35
|
-
|
36
|
-
def test_generate_metrics_for_does_not_include_all_web_for_other_requests
|
37
|
-
NewRelic::Agent::Transaction.stubs(:recording_web_transaction?).returns(false)
|
38
|
-
metrics = NewRelic::Agent::Datastores::Mongo::MetricGenerator.generate_metrics_for(:insert, @payload)
|
39
|
-
|
40
|
-
refute metrics.include? 'Datastore/allWeb'
|
41
|
-
end
|
42
|
-
|
43
|
-
def test_generate_metrics_for_is_graceful_if_exceptions_are_raised
|
44
|
-
NewRelic::Agent::Datastores::Mongo::MetricTranslator.stubs(:metrics_for).raises("Booom")
|
45
|
-
metrics = NewRelic::Agent::Datastores::Mongo::MetricGenerator.generate_metrics_for(:insert, @payload)
|
46
|
-
|
47
|
-
assert_empty metrics
|
48
|
-
end
|
49
|
-
|
50
|
-
def test_generate_instance_metric_for_returns_instance_metric_for_given_attributes
|
51
|
-
result = NewRelic::Agent::Datastores::Mongo::MetricGenerator.generate_instance_metric_for('host', 'port', 'database')
|
52
|
-
assert_equal 'Datastore/instance/MongoDB/host:port/database', result
|
53
|
-
end
|
54
|
-
|
55
|
-
def test_generate_metrics_for_does_not_include_instance_metric_without_host
|
56
|
-
result = NewRelic::Agent::Datastores::Mongo::MetricGenerator.generate_instance_metric_for(nil, 'port', 'database')
|
57
|
-
assert_nil result
|
58
|
-
end
|
59
|
-
|
60
|
-
def test_generate_metrics_for_does_not_include_instance_metric_without_port
|
61
|
-
result = NewRelic::Agent::Datastores::Mongo::MetricGenerator.generate_instance_metric_for('host', nil, 'database')
|
62
|
-
assert_nil result
|
63
|
-
end
|
64
|
-
|
65
|
-
def test_generate_metrics_for_does_not_include_instance_metric_without_database_name
|
66
|
-
result = NewRelic::Agent::Datastores::Mongo::MetricGenerator.generate_instance_metric_for('host', 'port', nil)
|
67
|
-
assert_nil result
|
68
|
-
end
|
69
|
-
end
|
@@ -1,155 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
# This file is distributed under New Relic's license terms.
|
3
|
-
# See https://github.com/newrelic/rpm/blob/master/LICENSE for complete details.
|
4
|
-
|
5
|
-
require File.expand_path(File.join(File.dirname(__FILE__),'..','..','test_helper'))
|
6
|
-
|
7
|
-
memcached_ready = false
|
8
|
-
classes = {
|
9
|
-
# 'memcache' => 'MemCache',
|
10
|
-
# 'dalli' => 'Dalli::Client',
|
11
|
-
'memcached' => 'Memcached'
|
12
|
-
# 'spymemcached' => 'Spymemcached'
|
13
|
-
}
|
14
|
-
begin
|
15
|
-
TCPSocket.new('localhost', 11211)
|
16
|
-
classes.each do |req, const|
|
17
|
-
begin
|
18
|
-
require req
|
19
|
-
MEMCACHED_CLASS = const.constantize
|
20
|
-
puts "Testing #{MEMCACHED_CLASS}"
|
21
|
-
memcached_ready = true
|
22
|
-
rescue LoadError
|
23
|
-
rescue NameError
|
24
|
-
end
|
25
|
-
end
|
26
|
-
rescue Errno::ECONNREFUSED
|
27
|
-
rescue Errno::ETIMEDOUT
|
28
|
-
end
|
29
|
-
|
30
|
-
if memcached_ready
|
31
|
-
class NewRelic::Agent::MemcacheInstrumentationTest < Minitest::Test
|
32
|
-
include NewRelic::Agent::Instrumentation::ControllerInstrumentation
|
33
|
-
|
34
|
-
def setup
|
35
|
-
NewRelic::Agent.manual_start
|
36
|
-
@engine = NewRelic::Agent.instance.stats_engine
|
37
|
-
|
38
|
-
case MEMCACHED_CLASS.name
|
39
|
-
when 'Memcached'
|
40
|
-
@cache = MEMCACHED_CLASS.new('localhost', :support_cas => true)
|
41
|
-
when 'Spymemcached'
|
42
|
-
@cache = MEMCACHED_CLASS.new('localhost:11211')
|
43
|
-
else
|
44
|
-
@cache = MEMCACHED_CLASS.new('localhost')
|
45
|
-
end
|
46
|
-
@key = 'schluessel'
|
47
|
-
@cache.set('schluessel', 1)
|
48
|
-
end
|
49
|
-
|
50
|
-
def teardown
|
51
|
-
if MEMCACHED_CLASS.name == 'Memcached'
|
52
|
-
@cache.flush
|
53
|
-
elsif MEMCACHED_CLASS.name == 'Spymemcached'
|
54
|
-
@cache.flush
|
55
|
-
@cache.instance_eval{ @client.shutdown }
|
56
|
-
else
|
57
|
-
@cache.flush_all
|
58
|
-
end
|
59
|
-
end
|
60
|
-
|
61
|
-
def _call_test_method_in_web_transaction(method, *args)
|
62
|
-
@engine.clear_stats
|
63
|
-
perform_action_with_newrelic_trace(:name=>'action', :category => :controller) do
|
64
|
-
@cache.send(method.to_sym, *[@key, *args])
|
65
|
-
end
|
66
|
-
end
|
67
|
-
|
68
|
-
def _call_test_method_in_background_task(method, *args)
|
69
|
-
@engine.clear_stats
|
70
|
-
perform_action_with_newrelic_trace(:name => 'bg_task', :category => :task) do
|
71
|
-
@cache.send(method.to_sym, *[@key, *args])
|
72
|
-
end
|
73
|
-
end
|
74
|
-
|
75
|
-
def test_reads__web
|
76
|
-
commands = ['get']
|
77
|
-
commands << 'get_multi' unless MEMCACHED_CLASS.name == 'Spymemcached'
|
78
|
-
expected_metrics = commands
|
79
|
-
expected_metrics = ['single_get', 'multi_get'] if MEMCACHED_CLASS.name == 'Memcached' && Memcached::VERSION >= '1.8.0'
|
80
|
-
commands.zip(expected_metrics) do |method, metric|
|
81
|
-
if @cache.class.method_defined?(method)
|
82
|
-
_call_test_method_in_web_transaction(method)
|
83
|
-
compare_metrics ["Memcache/#{metric}", "Memcache/allWeb", "Memcache/#{metric}:Controller/NewRelic::Agent::MemcacheInstrumentationTest/action"],
|
84
|
-
@engine.metrics.select{|m| m =~ /^memcache.*/i}
|
85
|
-
end
|
86
|
-
end
|
87
|
-
end
|
88
|
-
|
89
|
-
def test_writes__web
|
90
|
-
%w[delete].each do |method|
|
91
|
-
if @cache.class.method_defined?(method)
|
92
|
-
_call_test_method_in_web_transaction(method)
|
93
|
-
expected_metrics = ["Memcache/#{method}", "Memcache/allWeb", "Memcache/#{method}:Controller/NewRelic::Agent::MemcacheInstrumentationTest/action"]
|
94
|
-
compare_metrics expected_metrics, @engine.metrics.select{|m| m =~ /^memcache.*/i}
|
95
|
-
end
|
96
|
-
end
|
97
|
-
|
98
|
-
%w[set add].each do |method|
|
99
|
-
@cache.delete(@key) rescue nil
|
100
|
-
if @cache.class.method_defined?(method)
|
101
|
-
expected_metrics = ["Memcache/#{method}", "Memcache/allWeb", "Memcache/#{method}:Controller/NewRelic::Agent::MemcacheInstrumentationTest/action"]
|
102
|
-
_call_test_method_in_web_transaction(method, 'value')
|
103
|
-
compare_metrics expected_metrics, @engine.metrics.select{|m| m =~ /^memcache.*/i}
|
104
|
-
end
|
105
|
-
end
|
106
|
-
end
|
107
|
-
|
108
|
-
def test_reads__background
|
109
|
-
commands = ['get']
|
110
|
-
commands << 'get_multi' unless MEMCACHED_CLASS.name == 'Spymemcached'
|
111
|
-
expected_metrics = commands
|
112
|
-
expected_metrics = ['single_get', 'multi_get'] if MEMCACHED_CLASS.name == 'Memcached' && Memcached::VERSION >= '1.8.0'
|
113
|
-
commands.zip(expected_metrics) do |method, metric|
|
114
|
-
if @cache.class.method_defined?(method)
|
115
|
-
_call_test_method_in_background_task(method)
|
116
|
-
compare_metrics ["Memcache/#{metric}", "Memcache/allOther", "Memcache/#{metric}:OtherTransaction/Background/NewRelic::Agent::MemcacheInstrumentationTest/bg_task"],
|
117
|
-
@engine.metrics.select{|m| m =~ /^memcache.*/i}
|
118
|
-
end
|
119
|
-
end
|
120
|
-
end
|
121
|
-
|
122
|
-
def test_writes__background
|
123
|
-
%w[delete].each do |method|
|
124
|
-
expected_metrics = ["Memcache/#{method}", "Memcache/allOther", "Memcache/#{method}:OtherTransaction/Background/NewRelic::Agent::MemcacheInstrumentationTest/bg_task"]
|
125
|
-
if @cache.class.method_defined?(method)
|
126
|
-
_call_test_method_in_background_task(method)
|
127
|
-
compare_metrics expected_metrics, @engine.metrics.select{|m| m =~ /^memcache.*/i}
|
128
|
-
end
|
129
|
-
end
|
130
|
-
|
131
|
-
%w[set add].each do |method|
|
132
|
-
@cache.delete(@key) rescue nil
|
133
|
-
expected_metrics = ["Memcache/#{method}", "Memcache/allOther", "Memcache/#{method}:OtherTransaction/Background/NewRelic::Agent::MemcacheInstrumentationTest/bg_task"]
|
134
|
-
if @cache.class.method_defined?(method)
|
135
|
-
_call_test_method_in_background_task(method, 'value')
|
136
|
-
compare_metrics expected_metrics, @engine.metrics.select{|m| m =~ /^memcache.*/i}
|
137
|
-
end
|
138
|
-
end
|
139
|
-
end
|
140
|
-
|
141
|
-
def test_handles_cas
|
142
|
-
expected_metrics = ["cas"]
|
143
|
-
expected_metrics = ["single_get", "single_cas"] if MEMCACHED_CLASS.name == 'Memcached' && Memcached::VERSION >= '1.8.0'
|
144
|
-
expected_metrics = ["Memcache/allOther"] + expected_metrics.flat_map {|m| ["Memcache/#{m}", "Memcache/#{m}:OtherTransaction/Background/NewRelic::Agent::MemcacheInstrumentationTest/bg_task"] }
|
145
|
-
if @cache.class.method_defined?(:cas)
|
146
|
-
@engine.clear_stats
|
147
|
-
perform_action_with_newrelic_trace(:name => 'bg_task', :category => :task) do
|
148
|
-
@cache.cas(@key) {|val| val += 2 }
|
149
|
-
end
|
150
|
-
compare_metrics expected_metrics, @engine.metrics.select{|m| m =~ /^memcache.*/i}
|
151
|
-
assert_equal 3, @cache.get(@key)
|
152
|
-
end
|
153
|
-
end
|
154
|
-
end
|
155
|
-
end
|