newrelic_rpm 3.16.0.318 → 3.16.1.320
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +13 -4
- data/CHANGELOG +41 -2
- data/lib/new_relic/agent/database.rb +15 -4
- data/lib/new_relic/agent/database/explain_plan_helpers.rb +2 -1
- data/lib/new_relic/agent/datastores.rb +13 -13
- data/lib/new_relic/agent/datastores/metric_helper.rb +33 -2
- data/lib/new_relic/agent/datastores/mongo/metric_translator.rb +3 -9
- data/lib/new_relic/agent/error_collector.rb +2 -2
- data/lib/new_relic/agent/instrumentation/active_record.rb +9 -19
- data/lib/new_relic/agent/instrumentation/active_record_helper.rb +2 -6
- data/lib/new_relic/agent/instrumentation/active_record_subscriber.rb +49 -40
- data/lib/new_relic/agent/instrumentation/data_mapper.rb +29 -23
- data/lib/new_relic/agent/instrumentation/grape.rb +20 -11
- data/lib/new_relic/agent/instrumentation/memcache.rb +8 -10
- data/lib/new_relic/agent/instrumentation/mongo.rb +25 -16
- data/lib/new_relic/agent/instrumentation/mongodb_command_subscriber.rb +14 -19
- data/lib/new_relic/agent/method_tracer_helpers.rb +4 -8
- data/lib/new_relic/agent/sql_sampler.rb +14 -1
- data/lib/new_relic/agent/stats_engine/metric_stats.rb +18 -0
- data/lib/new_relic/agent/supported_versions.rb +2 -3
- data/lib/new_relic/agent/traced_method_stack.rb +7 -1
- data/lib/new_relic/agent/transaction.rb +6 -0
- data/lib/new_relic/agent/transaction/abstract_segment.rb +73 -0
- data/lib/new_relic/agent/transaction/datastore_segment.rb +49 -0
- data/lib/new_relic/agent/transaction/segment.rb +30 -0
- data/lib/new_relic/agent/transaction/tracing.rb +53 -0
- data/lib/new_relic/agent/transaction_sampler.rb +8 -1
- data/lib/new_relic/noticed_error.rb +3 -1
- data/lib/new_relic/version.rb +1 -1
- data/lib/sequel/extensions/newrelic_instrumentation.rb +22 -15
- data/lib/sequel/plugins/newrelic_instrumentation.rb +4 -3
- data/newrelic_rpm.gemspec +1 -9
- data/test/environments/lib/environments/runner.rb +6 -4
- data/test/environments/norails/Gemfile +9 -3
- data/test/environments/rails21/Gemfile +6 -3
- data/test/environments/rails22/Gemfile +5 -2
- data/test/environments/rails23/Gemfile +1 -1
- data/test/environments/rails30/Gemfile +1 -1
- data/test/environments/rails31/Gemfile +1 -1
- data/test/environments/rails32/Gemfile +1 -1
- data/test/environments/rails40/Gemfile +2 -2
- data/test/environments/rails41/Gemfile +2 -2
- data/test/environments/rails42/Gemfile +2 -2
- data/test/environments/rails50/Gemfile +2 -2
- data/test/helpers/mongo_metric_builder.rb +3 -4
- data/test/multiverse/lib/multiverse/shell_utils.rb +27 -0
- data/test/multiverse/lib/multiverse/suite.rb +47 -2
- data/test/multiverse/suites/active_record/Envfile +1 -1
- data/test/multiverse/suites/delayed_job/Envfile +2 -0
- data/test/multiverse/suites/grape/grape_versioning_test.rb +55 -1
- data/test/multiverse/suites/grape/grape_versioning_test_api.rb +61 -3
- data/test/multiverse/suites/mongo/mongo_instrumentation_test.rb +18 -0
- data/test/multiverse/suites/rails/Envfile +3 -3
- data/test/multiverse/suites/rails/error_tracing_test.rb +2 -2
- data/test/multiverse/suites/sequel/Envfile +7 -0
- data/test/multiverse/suites/sequel/sequel_extension_test.rb +1 -1
- data/test/new_relic/agent/database_test.rb +9 -0
- data/test/new_relic/agent/datastores/metric_helper_test.rb +76 -43
- data/test/new_relic/agent/datastores/mongo/metric_translator_test.rb +67 -117
- data/test/new_relic/agent/datastores_test.rb +17 -0
- data/test/new_relic/agent/error_collector_test.rb +21 -5
- data/test/new_relic/agent/instrumentation/active_record_helper_test.rb +40 -45
- data/test/new_relic/agent/instrumentation/active_record_subscriber_test.rb +2 -3
- data/test/new_relic/agent/instrumentation/mongodb_command_subscriber_test.rb +2 -0
- data/test/new_relic/agent/method_tracer_test.rb +54 -52
- data/test/new_relic/agent/mock_scope_listener.rb +4 -1
- data/test/new_relic/agent/sql_sampler_test.rb +15 -0
- data/test/new_relic/agent/transaction/abstract_segment_test.rb +94 -0
- data/test/new_relic/agent/transaction/datastore_segment_test.rb +99 -0
- data/test/new_relic/agent/transaction/segment_test.rb +53 -0
- data/test/new_relic/agent/transaction/tracing_test.rb +121 -0
- data/test/new_relic/agent/transaction_sampler_test.rb +13 -0
- data/test/new_relic/noticed_error_test.rb +7 -0
- data/test/performance/suites/datastores.rb +59 -0
- data/test/performance/suites/trace_execution_scoped.rb +8 -9
- metadata +13 -46
@@ -134,8 +134,8 @@ class ErrorsWithoutSSCTest < RailsMultiverseTest
|
|
134
134
|
|
135
135
|
def test_should_capture_error_raised_in_view
|
136
136
|
get '/error/view_error'
|
137
|
-
|
138
|
-
|
137
|
+
assert_equal 1, errors.size
|
138
|
+
assert_includes ['this is an uncaught view error', 'ActionView::Template::Error'], errors[0].message
|
139
139
|
end
|
140
140
|
|
141
141
|
def test_should_capture_error_raised_in_controller
|
@@ -32,3 +32,10 @@ gemfile <<-RB
|
|
32
32
|
gem 'sqlite3', :platform => :ruby
|
33
33
|
gem 'sequel', '4.0.0'
|
34
34
|
RB
|
35
|
+
|
36
|
+
gemfile <<-RB
|
37
|
+
gem 'newrelic_rpm', :require => false, :path => File.expand_path('../../../../')
|
38
|
+
gem 'jdbc-sqlite3', '3.7.2', :platform => :jruby
|
39
|
+
gem 'sqlite3', :platform => :ruby
|
40
|
+
gem 'sequel', '4.35.0'
|
41
|
+
RB
|
@@ -68,7 +68,7 @@ class SequelExtensionTest < Minitest::Test
|
|
68
68
|
|
69
69
|
def test_doesnt_block_constraint_errors
|
70
70
|
first_post = @posts.insert(:title => 'The Thing', :content => 'A wicked short story.')
|
71
|
-
assert_raises(Sequel::DatabaseError) do
|
71
|
+
assert_raises(Sequel::DatabaseError, Sequel::UniqueConstraintViolation) do
|
72
72
|
@posts.insert(:id => first_post, :title => 'Copy Cat', :content => 'A wicked short story.')
|
73
73
|
end
|
74
74
|
end
|
@@ -470,6 +470,15 @@ class NewRelic::Agent::DatabaseTest < Minitest::Test
|
|
470
470
|
end
|
471
471
|
end
|
472
472
|
|
473
|
+
def test_database_statement_does_not_mutate_sql
|
474
|
+
table_name = 'a' * 17_000
|
475
|
+
sql = "select * from #{table_name}"
|
476
|
+
expected_sql = sql.dup
|
477
|
+
statement = NewRelic::Agent::Database::Statement.new sql, {:adapter => :mysql}
|
478
|
+
refute_equal sql, statement.sql
|
479
|
+
assert_equal expected_sql, sql
|
480
|
+
end
|
481
|
+
|
473
482
|
# Ruby 1.8 doesn't have String#encoding
|
474
483
|
def encoding_from_string(str)
|
475
484
|
if str.respond_to?(:encoding)
|
@@ -56,77 +56,110 @@ module NewRelic
|
|
56
56
|
assert_equal expected, result
|
57
57
|
end
|
58
58
|
|
59
|
-
def
|
59
|
+
def test_scoped_metric_for_with_collection
|
60
|
+
expected = "Datastore/statement/JonanDB/wiggles/select"
|
61
|
+
result = Datastores::MetricHelper.scoped_metric_for(@product, @operation, @collection)
|
62
|
+
assert_equal expected, result
|
63
|
+
end
|
64
|
+
|
65
|
+
def test_scoped_metric_for_without_collection
|
66
|
+
expected = "Datastore/operation/JonanDB/select"
|
67
|
+
result = Datastores::MetricHelper.scoped_metric_for(@product, @operation)
|
68
|
+
assert_equal expected, result
|
69
|
+
end
|
70
|
+
|
71
|
+
def test_unscoped_metrics_for_in_web_context
|
72
|
+
Transaction.stubs(:recording_web_transaction?).returns(true)
|
73
|
+
expected = [
|
74
|
+
"Datastore/operation/JonanDB/select",
|
75
|
+
"Datastore/JonanDB/allWeb",
|
76
|
+
"Datastore/JonanDB/all",
|
77
|
+
"Datastore/allWeb",
|
78
|
+
"Datastore/all"
|
79
|
+
]
|
80
|
+
|
81
|
+
result = Datastores::MetricHelper.unscoped_metrics_for(@product, @operation, @collection)
|
82
|
+
assert_equal expected, result
|
83
|
+
end
|
84
|
+
|
85
|
+
def test_unscoped_metrics_for_outside_web_context
|
86
|
+
Transaction.stubs(:recording_web_transaction?).returns(false)
|
87
|
+
expected = [
|
88
|
+
"Datastore/operation/JonanDB/select",
|
89
|
+
"Datastore/JonanDB/allOther",
|
90
|
+
"Datastore/JonanDB/all",
|
91
|
+
"Datastore/allOther",
|
92
|
+
"Datastore/all"
|
93
|
+
]
|
94
|
+
|
95
|
+
result = Datastores::MetricHelper.unscoped_metrics_for(@product, @operation, @collection)
|
96
|
+
assert_equal expected, result
|
97
|
+
end
|
98
|
+
|
99
|
+
def test_unscoped_metrics_for_without_collection
|
100
|
+
Transaction.stubs(:recording_web_transaction?).returns(false)
|
101
|
+
expected = [
|
102
|
+
"Datastore/JonanDB/allOther",
|
103
|
+
"Datastore/JonanDB/all",
|
104
|
+
"Datastore/allOther",
|
105
|
+
"Datastore/all"
|
106
|
+
]
|
107
|
+
|
108
|
+
result = Datastores::MetricHelper.unscoped_metrics_for(@product, @operation)
|
109
|
+
assert_equal expected, result
|
110
|
+
end
|
111
|
+
|
112
|
+
def test_product_operation_collection_for_obeys_collection_and_operation_overrides
|
60
113
|
in_transaction do
|
61
114
|
NewRelic::Agent.with_database_metric_name("Model", "new_method") do
|
62
|
-
|
63
|
-
|
64
|
-
"Datastore/operation/JonanDB/new_method",
|
65
|
-
"Datastore/JonanDB/allOther",
|
66
|
-
"Datastore/JonanDB/all",
|
67
|
-
"Datastore/allOther",
|
68
|
-
"Datastore/all"
|
69
|
-
]
|
70
|
-
|
71
|
-
result = Datastores::MetricHelper.metrics_for(@product, "original_method")
|
115
|
+
result = Datastores::MetricHelper.product_operation_collection_for(@product, "original_method")
|
116
|
+
expected = [@product, "new_method", "Model"]
|
72
117
|
assert_equal expected, result
|
73
118
|
end
|
74
119
|
end
|
75
120
|
end
|
76
121
|
|
77
|
-
def
|
122
|
+
def test_product_operation_collection_for_obeys_collection_override
|
78
123
|
in_transaction do
|
79
124
|
NewRelic::Agent.with_database_metric_name("Model", nil) do
|
80
|
-
|
81
|
-
|
82
|
-
"Datastore/operation/JonanDB/original_method",
|
83
|
-
"Datastore/JonanDB/allOther",
|
84
|
-
"Datastore/JonanDB/all",
|
85
|
-
"Datastore/allOther",
|
86
|
-
"Datastore/all"
|
87
|
-
]
|
88
|
-
|
89
|
-
result = Datastores::MetricHelper.metrics_for(@product, "original_method")
|
125
|
+
result = Datastores::MetricHelper.product_operation_collection_for(@product, "original_method")
|
126
|
+
expected = [@product, "original_method", "Model"]
|
90
127
|
assert_equal expected, result
|
91
128
|
end
|
92
129
|
end
|
93
130
|
end
|
94
131
|
|
95
|
-
def
|
132
|
+
def test_product_operation_collection_for_ignore_overrides_for_other_products
|
96
133
|
in_transaction do
|
97
134
|
NewRelic::Agent.with_database_metric_name("Model", "new_method", "FauxDB") do
|
98
|
-
|
99
|
-
|
100
|
-
"Datastore/JonanDB/allOther",
|
101
|
-
"Datastore/JonanDB/all",
|
102
|
-
"Datastore/allOther",
|
103
|
-
"Datastore/all"
|
104
|
-
]
|
105
|
-
|
106
|
-
result = Datastores::MetricHelper.metrics_for(@product, "original_method")
|
135
|
+
result = Datastores::MetricHelper.product_operation_collection_for(@product, "original_method")
|
136
|
+
expected = [@product, "original_method", nil]
|
107
137
|
assert_equal expected, result
|
108
138
|
end
|
109
139
|
end
|
110
140
|
end
|
111
141
|
|
112
|
-
def
|
142
|
+
def test_product_operation_collection_for_applies_overrides_by_generic_product_name
|
113
143
|
in_transaction do
|
114
144
|
NewRelic::Agent.with_database_metric_name("Model", "new_method") do
|
115
|
-
|
116
|
-
|
117
|
-
"Datastore/operation/MoreSpecificDB/new_method",
|
118
|
-
"Datastore/MoreSpecificDB/allOther",
|
119
|
-
"Datastore/MoreSpecificDB/all",
|
120
|
-
"Datastore/allOther",
|
121
|
-
"Datastore/all"
|
122
|
-
]
|
123
|
-
|
124
|
-
result = Datastores::MetricHelper.metrics_for("MoreSpecificDB", "original_method", nil, @product)
|
145
|
+
result = Datastores::MetricHelper.product_operation_collection_for("MoreSpecificDB", "original_method", nil, @product)
|
146
|
+
expected = ["MoreSpecificDB", "new_method", "Model"]
|
125
147
|
assert_equal expected, result
|
126
148
|
end
|
127
149
|
end
|
128
150
|
end
|
129
151
|
|
152
|
+
def test_operation_from_sql
|
153
|
+
sql = "SELECT * FROM blogs where id = 5"
|
154
|
+
operation = Datastores::MetricHelper.operation_from_sql sql
|
155
|
+
assert_equal "select", operation
|
156
|
+
end
|
157
|
+
|
158
|
+
def test_operation_from_sql_returns_other_for_unrecognized_operation
|
159
|
+
sql = "DESCRIBE blogs"
|
160
|
+
operation = Datastores::MetricHelper.operation_from_sql sql
|
161
|
+
assert_equal "Other", operation
|
162
|
+
end
|
130
163
|
end
|
131
164
|
end
|
132
165
|
end
|
@@ -13,94 +13,60 @@ class NewRelic::Agent::Datastores::Mongo::MetricTranslatorTest < Minitest::Test
|
|
13
13
|
@collection_name = 'tribbles'
|
14
14
|
end
|
15
15
|
|
16
|
-
def
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
assert_equal expected, metrics
|
21
|
-
end
|
22
|
-
|
23
|
-
def test_build_metrics_includes_web
|
24
|
-
in_web_transaction do
|
25
|
-
metrics = build_test_metrics('test')
|
26
|
-
assert_includes metrics, 'Datastore/allWeb'
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
def test_build_metrics_includes_other
|
31
|
-
in_background_transaction do
|
32
|
-
metrics = build_test_metrics('test')
|
33
|
-
assert_includes metrics, 'Datastore/allOther'
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
def test_build_metrics_includes_all_for_web
|
38
|
-
in_web_transaction do
|
39
|
-
metrics = build_test_metrics('test')
|
40
|
-
assert_includes metrics, 'Datastore/all'
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
def test_build_metrics_includes_all_for_other
|
45
|
-
in_background_transaction do
|
46
|
-
metrics = build_test_metrics('test')
|
47
|
-
assert_includes metrics, 'Datastore/all'
|
48
|
-
end
|
16
|
+
def test_operation_and_collection_for_insert
|
17
|
+
result = NewRelic::Agent::Datastores::Mongo::MetricTranslator.operation_and_collection_for(:insert, { :collection => @collection_name })
|
18
|
+
assert_equal ['insert', @collection_name], result
|
49
19
|
end
|
50
20
|
|
51
|
-
def
|
52
|
-
NewRelic::Agent::Datastores::
|
53
|
-
|
54
|
-
|
21
|
+
def test_operation_and_collection_for_is_graceful_if_exceptions_are_raised
|
22
|
+
NewRelic::Agent::Datastores::Mongo::MetricTranslator.stubs(:find_one?).raises("Boom")
|
23
|
+
result = NewRelic::Agent::Datastores::Mongo::MetricTranslator.operation_and_collection_for(:find, {})
|
24
|
+
assert_nil result
|
55
25
|
end
|
56
26
|
|
57
|
-
def
|
27
|
+
def test_operation_and_collection_for_find
|
58
28
|
payload = { :database => @database_name,
|
59
29
|
:collection => @collection_name,
|
60
30
|
:selector => { "name" => "soterios johnson" } }
|
61
31
|
|
62
|
-
|
63
|
-
expected = build_test_metrics(:find)
|
32
|
+
result = NewRelic::Agent::Datastores::Mongo::MetricTranslator.operation_and_collection_for(:find, payload)
|
64
33
|
|
65
|
-
assert_equal
|
34
|
+
assert_equal ['find', @collection_name], result
|
66
35
|
end
|
67
36
|
|
68
|
-
def
|
37
|
+
def test_operation_and_collection_for_find_one
|
69
38
|
payload = { :database => @database_name,
|
70
39
|
:collection => @collection_name,
|
71
40
|
:selector => {},
|
72
41
|
:limit => -1 }
|
73
42
|
|
74
|
-
|
75
|
-
expected = build_test_metrics(:findOne)
|
43
|
+
result = NewRelic::Agent::Datastores::Mongo::MetricTranslator.operation_and_collection_for(:find, payload)
|
76
44
|
|
77
|
-
assert_equal
|
45
|
+
assert_equal ['findOne' ,@collection_name], result
|
78
46
|
end
|
79
47
|
|
80
|
-
def
|
48
|
+
def test_operation_and_collection_for_remove
|
81
49
|
payload = { :database => @database_name,
|
82
50
|
:collection => @collection_name,
|
83
51
|
:selector => { "name" => "soterios johnson" } }
|
84
52
|
|
85
|
-
|
86
|
-
expected = build_test_metrics(:remove)
|
53
|
+
result = NewRelic::Agent::Datastores::Mongo::MetricTranslator.operation_and_collection_for(:remove, payload)
|
87
54
|
|
88
|
-
assert_equal
|
55
|
+
assert_equal ['remove', @collection_name], result
|
89
56
|
end
|
90
57
|
|
91
|
-
def
|
58
|
+
def test_operation_and_collection_for_update
|
92
59
|
payload = { :database => @database_name,
|
93
60
|
:collection => @collection_name,
|
94
61
|
:selector => { "name" => "soterios johnson" },
|
95
62
|
:document => { "name" => "codemonkey" } }
|
96
63
|
|
97
|
-
|
98
|
-
expected = build_test_metrics(:update)
|
64
|
+
result = NewRelic::Agent::Datastores::Mongo::MetricTranslator.operation_and_collection_for(:update, payload)
|
99
65
|
|
100
|
-
assert_equal
|
66
|
+
assert_equal ['update', @collection_name], result
|
101
67
|
end
|
102
68
|
|
103
|
-
def
|
69
|
+
def test_operation_and_collection_for_distinct
|
104
70
|
payload = { :database => @database_name,
|
105
71
|
:collection => "$cmd",
|
106
72
|
:limit => -1,
|
@@ -108,13 +74,12 @@ class NewRelic::Agent::Datastores::Mongo::MetricTranslatorTest < Minitest::Test
|
|
108
74
|
:key => "name",
|
109
75
|
:query => nil } }
|
110
76
|
|
111
|
-
|
112
|
-
expected = build_test_metrics(:distinct)
|
77
|
+
result = NewRelic::Agent::Datastores::Mongo::MetricTranslator.operation_and_collection_for(:distinct, payload)
|
113
78
|
|
114
|
-
assert_equal
|
79
|
+
assert_equal ['distinct', @collection_name], result
|
115
80
|
end
|
116
81
|
|
117
|
-
def
|
82
|
+
def test_operation_and_collection_for_count
|
118
83
|
payload = { :database => @database_name,
|
119
84
|
:collection => "$cmd",
|
120
85
|
:limit => -1,
|
@@ -122,13 +87,12 @@ class NewRelic::Agent::Datastores::Mongo::MetricTranslatorTest < Minitest::Test
|
|
122
87
|
"query" => {},
|
123
88
|
"fields" => nil } }
|
124
89
|
|
125
|
-
|
126
|
-
expected = build_test_metrics(:count)
|
90
|
+
result = NewRelic::Agent::Datastores::Mongo::MetricTranslator.operation_and_collection_for(:find, payload)
|
127
91
|
|
128
|
-
assert_equal
|
92
|
+
assert_equal ['count', @collection_name], result
|
129
93
|
end
|
130
94
|
|
131
|
-
def
|
95
|
+
def test_operation_and_collection_for_group
|
132
96
|
payload = { :database => @database_name,
|
133
97
|
:collection => "$cmd",
|
134
98
|
:limit => -1,
|
@@ -138,26 +102,24 @@ class NewRelic::Agent::Datastores::Mongo::MetricTranslatorTest < Minitest::Test
|
|
138
102
|
"initial" => {:count=>0},
|
139
103
|
"key" => {"name"=>1}}}}
|
140
104
|
|
141
|
-
|
142
|
-
expected = build_test_metrics(:group)
|
105
|
+
result = NewRelic::Agent::Datastores::Mongo::MetricTranslator.operation_and_collection_for(:find, payload)
|
143
106
|
|
144
|
-
assert_equal
|
107
|
+
assert_equal ['group', @collection_name], result
|
145
108
|
end
|
146
109
|
|
147
|
-
def
|
110
|
+
def test_operation_and_collection_for_aggregate
|
148
111
|
payload = { :database => @database_name,
|
149
112
|
:collection => "$cmd",
|
150
113
|
:limit => -1,
|
151
114
|
:selector => { "aggregate" => @collection_name,
|
152
115
|
"pipeline" => [{"$group" => {:_id => "$says", :total => {"$sum" => 1}}}]}}
|
153
116
|
|
154
|
-
|
155
|
-
expected = build_test_metrics(:aggregate)
|
117
|
+
result = NewRelic::Agent::Datastores::Mongo::MetricTranslator.operation_and_collection_for(:find, payload)
|
156
118
|
|
157
|
-
assert_equal
|
119
|
+
assert_equal ['aggregate', @collection_name], result
|
158
120
|
end
|
159
121
|
|
160
|
-
def
|
122
|
+
def test_operation_and_collection_for_mapreduce
|
161
123
|
payload = { :database => @database_name,
|
162
124
|
:collection => "$cmd",
|
163
125
|
:limit => -1,
|
@@ -166,14 +128,13 @@ class NewRelic::Agent::Datastores::Mongo::MetricTranslatorTest < Minitest::Test
|
|
166
128
|
"reduce" => stub("BSON::Code"),
|
167
129
|
:out => "results"}}
|
168
130
|
|
169
|
-
|
170
|
-
expected = build_test_metrics(:mapreduce)
|
131
|
+
result = NewRelic::Agent::Datastores::Mongo::MetricTranslator.operation_and_collection_for(:find, payload)
|
171
132
|
|
172
|
-
assert_equal
|
133
|
+
assert_equal ['mapreduce', @collection_name], result
|
173
134
|
end
|
174
135
|
|
175
136
|
|
176
|
-
def
|
137
|
+
def test_operation_and_collection_for_find_and_modify
|
177
138
|
payload = { :database => @database_name,
|
178
139
|
:collection => "$cmd",
|
179
140
|
:limit => -1,
|
@@ -181,13 +142,12 @@ class NewRelic::Agent::Datastores::Mongo::MetricTranslatorTest < Minitest::Test
|
|
181
142
|
:query => { "name" => "soterios johnson" },
|
182
143
|
:update => {"name" => "codemonkey" } } }
|
183
144
|
|
184
|
-
|
185
|
-
expected = build_test_metrics(:findAndModify)
|
145
|
+
result = NewRelic::Agent::Datastores::Mongo::MetricTranslator.operation_and_collection_for(:find, payload)
|
186
146
|
|
187
|
-
assert_equal
|
147
|
+
assert_equal ['findAndModify', @collection_name], result
|
188
148
|
end
|
189
149
|
|
190
|
-
def
|
150
|
+
def test_operation_and_collection_for_find_and_remove
|
191
151
|
payload = { :database => @database_name,
|
192
152
|
:collection => "$cmd",
|
193
153
|
:limit => -1,
|
@@ -195,89 +155,82 @@ class NewRelic::Agent::Datastores::Mongo::MetricTranslatorTest < Minitest::Test
|
|
195
155
|
:query => { "name" => "soterios johnson" },
|
196
156
|
:remove => true } }
|
197
157
|
|
198
|
-
|
199
|
-
expected = build_test_metrics(:findAndRemove)
|
158
|
+
result = NewRelic::Agent::Datastores::Mongo::MetricTranslator.operation_and_collection_for(:find, payload)
|
200
159
|
|
201
|
-
assert_equal
|
160
|
+
assert_equal ['findAndRemove', @collection_name], result
|
202
161
|
end
|
203
162
|
|
204
|
-
def
|
163
|
+
def test_operation_and_collection_for_create_index
|
205
164
|
payload = { :database => @database_name,
|
206
165
|
:collection => "system.indexes",
|
207
166
|
:documents => [ { :name => "name_1",
|
208
167
|
:ns => "#{@database_name}.#{@collection_name}",
|
209
168
|
:key => { "name" => 1 } } ] }
|
210
169
|
|
211
|
-
|
212
|
-
expected = build_test_metrics(:createIndex)
|
170
|
+
result = NewRelic::Agent::Datastores::Mongo::MetricTranslator.operation_and_collection_for(:insert, payload)
|
213
171
|
|
214
|
-
assert_equal
|
172
|
+
assert_equal ['createIndex', @collection_name], result
|
215
173
|
end
|
216
174
|
|
217
|
-
def
|
175
|
+
def test_operation_and_collection_for_drop_indexes
|
218
176
|
payload = { :database => @database_name,
|
219
177
|
:collection => "$cmd",
|
220
178
|
:limit => -1,
|
221
179
|
:selector => { :deleteIndexes => @collection_name,
|
222
180
|
:index => "*" } }
|
223
181
|
|
224
|
-
|
225
|
-
expected = build_test_metrics(:dropIndexes)
|
182
|
+
result = NewRelic::Agent::Datastores::Mongo::MetricTranslator.operation_and_collection_for(:find, payload)
|
226
183
|
|
227
|
-
assert_equal
|
184
|
+
assert_equal ['dropIndexes', @collection_name], result
|
228
185
|
end
|
229
186
|
|
230
|
-
def
|
187
|
+
def test_operation_and_collection_for_drop_index
|
231
188
|
payload = { :database => @database_name,
|
232
189
|
:collection => "$cmd",
|
233
190
|
:limit => -1,
|
234
191
|
:selector => { :deleteIndexes => @collection_name,
|
235
192
|
:index => "name_1" } }
|
236
193
|
|
237
|
-
|
238
|
-
expected = build_test_metrics(:dropIndex)
|
194
|
+
result = NewRelic::Agent::Datastores::Mongo::MetricTranslator.operation_and_collection_for(:find, payload)
|
239
195
|
|
240
|
-
assert_equal
|
196
|
+
assert_equal ['dropIndex', @collection_name], result
|
241
197
|
end
|
242
198
|
|
243
|
-
def
|
199
|
+
def test_operation_and_collection_for_reindex
|
244
200
|
payload = { :database => @database_name,
|
245
201
|
:collection => "$cmd",
|
246
202
|
:limit => -1,
|
247
203
|
:selector => { :reIndex=> @collection_name } }
|
248
204
|
|
249
|
-
|
250
|
-
expected = build_test_metrics(:reIndex)
|
205
|
+
result = NewRelic::Agent::Datastores::Mongo::MetricTranslator.operation_and_collection_for(:find, payload)
|
251
206
|
|
252
|
-
assert_equal
|
207
|
+
assert_equal ['reIndex', @collection_name], result
|
253
208
|
end
|
254
209
|
|
255
|
-
def
|
210
|
+
def test_operation_and_collection_for_drop_collection
|
256
211
|
payload = { :database => @database_name,
|
257
212
|
:collection =>"$cmd",
|
258
213
|
:limit => -1,
|
259
214
|
:selector => { :drop => @collection_name } }
|
260
215
|
|
261
|
-
|
262
|
-
expected = build_test_metrics(:drop)
|
216
|
+
result = NewRelic::Agent::Datastores::Mongo::MetricTranslator.operation_and_collection_for(:find, payload)
|
263
217
|
|
264
|
-
assert_equal
|
218
|
+
assert_equal ['drop', @collection_name], result
|
265
219
|
end
|
266
220
|
|
267
|
-
def
|
221
|
+
def test_operation_and_collection_for_rename_collection
|
268
222
|
payload = { :database => @database_name,
|
269
223
|
:collection => "$cmd",
|
270
224
|
:limit => -1,
|
271
225
|
:selector => { :renameCollection => "#{@database_name}.#{@collection_name}",
|
272
226
|
:to=>"#{@database_name}.renamed_#{@collection_name}" } }
|
273
227
|
|
274
|
-
|
275
|
-
expected = build_test_metrics(:renameCollection)
|
228
|
+
result = NewRelic::Agent::Datastores::Mongo::MetricTranslator.operation_and_collection_for(:find, payload)
|
276
229
|
|
277
|
-
assert_equal
|
230
|
+
assert_equal ['renameCollection', @collection_name], result
|
278
231
|
end
|
279
232
|
|
280
|
-
def
|
233
|
+
def test_operation_and_collection_for_ismaster
|
281
234
|
payload = { :database => @database_name,
|
282
235
|
:collection => "$cmd",
|
283
236
|
:limit => -1,
|
@@ -285,25 +238,23 @@ class NewRelic::Agent::Datastores::Mongo::MetricTranslatorTest < Minitest::Test
|
|
285
238
|
|
286
239
|
@collection_name = "$cmd"
|
287
240
|
|
288
|
-
|
289
|
-
expected = build_test_metrics(:ismaster)
|
241
|
+
result = NewRelic::Agent::Datastores::Mongo::MetricTranslator.operation_and_collection_for(:find, payload)
|
290
242
|
|
291
|
-
assert_equal
|
243
|
+
assert_equal ['ismaster', @collection_name], result
|
292
244
|
end
|
293
245
|
|
294
|
-
def
|
246
|
+
def test_operation_and_collection_for_collstats
|
295
247
|
payload = { :database => @database_name,
|
296
248
|
:collection =>"$cmd",
|
297
249
|
:limit => -1,
|
298
250
|
:selector => { :collstats => @collection_name } }
|
299
251
|
|
300
|
-
|
301
|
-
expected = build_test_metrics(:collstats)
|
252
|
+
result = NewRelic::Agent::Datastores::Mongo::MetricTranslator.operation_and_collection_for(:find, payload)
|
302
253
|
|
303
|
-
assert_equal
|
254
|
+
assert_equal ['collstats', @collection_name], result
|
304
255
|
end
|
305
256
|
|
306
|
-
def
|
257
|
+
def test_operation_and_collection_for_unknown_command
|
307
258
|
payload = { :database => @database_name,
|
308
259
|
:collection => "$cmd",
|
309
260
|
:limit => -1,
|
@@ -311,10 +262,9 @@ class NewRelic::Agent::Datastores::Mongo::MetricTranslatorTest < Minitest::Test
|
|
311
262
|
|
312
263
|
@collection_name = "$cmd"
|
313
264
|
|
314
|
-
|
315
|
-
expected = build_test_metrics(:mongomongomongo)
|
265
|
+
result = NewRelic::Agent::Datastores::Mongo::MetricTranslator.operation_and_collection_for(:find, payload)
|
316
266
|
|
317
|
-
assert_equal
|
267
|
+
assert_equal ['mongomongomongo', @collection_name], result
|
318
268
|
assert_metrics_recorded(["Supportability/Mongo/UnknownCollection"])
|
319
269
|
end
|
320
270
|
end
|