newrelic_rpm 3.17.1.326 → 3.17.2.327

Sign up to get free protection for your applications and to get access to all the features.
Files changed (52) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +10 -21
  3. data/{CHANGELOG → CHANGELOG.md} +143 -93
  4. data/lib/new_relic/agent/configuration/default_source.rb +31 -19
  5. data/lib/new_relic/agent/configuration/environment_source.rb +1 -1
  6. data/lib/new_relic/agent/instrumentation/active_record_4.rb +2 -2
  7. data/lib/new_relic/agent/instrumentation/active_record_5.rb +89 -0
  8. data/lib/new_relic/agent/instrumentation/active_record_helper.rb +3 -3
  9. data/lib/new_relic/agent/instrumentation/controller_instrumentation.rb +2 -2
  10. data/lib/new_relic/agent/instrumentation/data_mapper.rb +2 -0
  11. data/lib/new_relic/agent/instrumentation/memcache/dalli.rb +8 -6
  12. data/lib/new_relic/agent/instrumentation/mongodb_command_subscriber.rb +3 -2
  13. data/lib/new_relic/agent/instrumentation/rails5/action_controller.rb +12 -3
  14. data/lib/new_relic/agent/instrumentation/redis.rb +2 -1
  15. data/lib/new_relic/agent/instrumentation/sinatra/ignorer.rb +1 -1
  16. data/lib/new_relic/agent/new_relic_service.rb +6 -2
  17. data/lib/new_relic/agent/transaction/datastore_segment.rb +31 -7
  18. data/lib/new_relic/agent/transaction/tracing.rb +6 -1
  19. data/lib/new_relic/latest_changes.rb +1 -1
  20. data/lib/new_relic/version.rb +3 -3
  21. data/newrelic_rpm.gemspec +2 -1
  22. data/test/environments/rails21/Gemfile +1 -1
  23. data/test/environments/rails22/Gemfile +2 -1
  24. data/test/environments/rails23/Gemfile +6 -1
  25. data/test/fixtures/cross_agent_tests/datastores/README.md +1 -1
  26. data/test/fixtures/cross_agent_tests/datastores/datastore_api.json +443 -0
  27. data/test/fixtures/cross_agent_tests/datastores/datastore_instances.json +0 -47
  28. data/test/multiverse/lib/multiverse/runner.rb +2 -1
  29. data/test/multiverse/suites/memcached/dalli_test.rb +5 -12
  30. data/test/multiverse/suites/resque/instrumentation_test.rb +4 -0
  31. data/test/multiverse/suites/sidekiq/sidekiq_server.rb +5 -1
  32. data/test/multiverse/suites/sinatra/Envfile +8 -0
  33. data/test/multiverse/suites/sinatra/sinatra_error_tracing_test.rb +1 -1
  34. data/test/multiverse/suites/sinatra/sinatra_test_cases.rb +27 -9
  35. data/test/multiverse/suites/typhoeus/Envfile +5 -0
  36. data/test/new_relic/agent/api_tests/datastore_api_test.rb +64 -0
  37. data/test/new_relic/agent/configuration/default_source_test.rb +6 -3
  38. data/test/new_relic/agent/instrumentation/active_record_subscriber_test.rb +27 -1
  39. data/test/new_relic/agent/instrumentation/instance_identification_test.rb +4 -22
  40. data/test/new_relic/agent/instrumentation/mongodb_command_subscriber_test.rb +7 -0
  41. data/test/new_relic/agent/new_relic_service_test.rb +10 -2
  42. data/test/new_relic/agent/transaction/datastore_segment_test.rb +96 -6
  43. data/test/new_relic/agent/transaction/tracing_test.rb +9 -0
  44. data/test/new_relic/agent_test.rb +2 -1
  45. data/test/new_relic/latest_changes_test.rb +1 -1
  46. data/test/new_relic/rack/error_collector_test.rb +4 -0
  47. data/test/script/before_install/gemstash_mirror.sh +10 -0
  48. data/test/script/before_install/jruby_bundler.sh +22 -0
  49. data/test/script/before_install/revert_rubygems.sh +15 -0
  50. data/test/script/before_script/install_mongodb.sh +12 -0
  51. metadata +11 -5
  52. data/test/script/install_mongodb.sh +0 -6
@@ -100,6 +100,13 @@ class NewRelic::Agent::Instrumentation::MongodbCommandSubscriberTest < Minitest:
100
100
  assert_equal('mongodb-test', node[:database_name])
101
101
  end
102
102
 
103
+ def test_does_not_record_unknown_unknown_metric_when_data_empty
104
+ address = stub('address', :host => "", :port => "")
105
+ @started_event.stubs(:address).returns(address)
106
+ simulate_query
107
+ assert_metrics_not_recorded('Datastore/instance/MongoDB/unknown/unknown')
108
+ end
109
+
103
110
 
104
111
 
105
112
  def simulate_query
@@ -208,13 +208,21 @@ class NewRelicServiceTest < Minitest::Test
208
208
  end
209
209
  end
210
210
 
211
- def test_initialize_uses_correct_license_key_settings
211
+ def test_initialize_uses_license_key_from_config
212
212
  with_config(:license_key => 'abcde') do
213
213
  service = NewRelic::Agent::NewRelicService.new
214
- assert_equal 'abcde', service.instance_variable_get(:@license_key)
214
+ assert_equal 'abcde', service.send(:license_key)
215
215
  end
216
216
  end
217
217
 
218
+ def test_initialize_uses_license_key_from_manual_start
219
+ service = NewRelic::Agent::NewRelicService.new
220
+ NewRelic::Agent.manual_start :license_key => "geronimo"
221
+
222
+ assert_equal 'geronimo', service.send(:license_key)
223
+ NewRelic::Agent.shutdown
224
+ end
225
+
218
226
  def test_connect_sets_agent_id_and_config_data
219
227
  response = @service.connect
220
228
  assert_equal 1, response['agent_run_id']
@@ -66,13 +66,13 @@ module NewRelic
66
66
  def test_segment_records_expected_metrics_with_instance_identifier
67
67
  Transaction.stubs(:recording_web_transaction?).returns(true)
68
68
 
69
- segment = DatastoreSegment.new "SQLite", "select", nil, "localhost", "1337807"
69
+ segment = DatastoreSegment.new "SQLite", "select", nil, "jonan-01", "1337807"
70
70
  segment.start
71
71
  advance_time 1
72
72
  segment.finish
73
73
 
74
74
  assert_metrics_recorded [
75
- "Datastore/instance/SQLite/localhost/1337807",
75
+ "Datastore/instance/SQLite/jonan-01/1337807",
76
76
  "Datastore/operation/SQLite/select",
77
77
  "Datastore/SQLite/allWeb",
78
78
  "Datastore/SQLite/all",
@@ -81,16 +81,63 @@ module NewRelic
81
81
  ]
82
82
  end
83
83
 
84
+ def test_segment_records_expected_metrics_with_instance_identifier_host_only
85
+ Transaction.stubs(:recording_web_transaction?).returns(true)
86
+
87
+ segment = DatastoreSegment.new "SQLite", "select", nil, "jonan-01"
88
+ segment.start
89
+ advance_time 1
90
+ segment.finish
91
+
92
+ assert_metrics_recorded [
93
+ "Datastore/instance/SQLite/jonan-01/unknown",
94
+ "Datastore/operation/SQLite/select",
95
+ "Datastore/SQLite/allWeb",
96
+ "Datastore/SQLite/all",
97
+ "Datastore/allWeb",
98
+ "Datastore/all"
99
+ ]
100
+ end
101
+
102
+ def test_segment_records_expected_metrics_with_instance_identifier_port_only
103
+ Transaction.stubs(:recording_web_transaction?).returns(true)
104
+
105
+ segment = DatastoreSegment.new "SQLite", "select", nil, nil, 1337807
106
+ segment.start
107
+ advance_time 1
108
+ segment.finish
109
+
110
+ assert_metrics_recorded [
111
+ "Datastore/instance/SQLite/unknown/1337807",
112
+ "Datastore/operation/SQLite/select",
113
+ "Datastore/SQLite/allWeb",
114
+ "Datastore/SQLite/all",
115
+ "Datastore/allWeb",
116
+ "Datastore/all"
117
+ ]
118
+ end
119
+
120
+ def test_segment_does_not_record_expected_metrics_with_empty_data
121
+ Transaction.stubs(:recording_web_transaction?).returns(true)
122
+
123
+ segment = DatastoreSegment.new "SQLite", "select", nil
124
+ segment.start
125
+ advance_time 1
126
+ segment.finish
127
+
128
+ assert_metrics_not_recorded "Datastore/instance/SQLite/unknown/unknown"
129
+ end
130
+
84
131
  def test_segment_does_not_record_instance_id_metrics_when_disabled
85
132
  with_config(:'datastore_tracer.instance_reporting.enabled' => false) do
86
133
  Transaction.stubs(:recording_web_transaction?).returns(true)
87
134
 
88
- segment = DatastoreSegment.new "SQLite", "select", nil, "localhost/1337807"
135
+ segment = DatastoreSegment.new "SQLite", "select", nil, "jonan-01", "1337807"
89
136
  segment.start
90
137
  advance_time 1
91
138
  segment.finish
92
139
 
93
- assert_metrics_not_recorded "Datastore/instance/SQLite/localhost/1337807"
140
+ assert_metrics_not_recorded "Datastore/instance/SQLite/jonan-01/1337807"
94
141
  end
95
142
  end
96
143
 
@@ -98,7 +145,7 @@ module NewRelic
98
145
  segment = nil
99
146
 
100
147
  in_transaction do
101
- segment = NewRelic::Agent::Transaction.start_datastore_segment "SQLite", "select", nil, "localhost", "1337807"
148
+ segment = NewRelic::Agent::Transaction.start_datastore_segment "SQLite", "select", nil, "jonan-01", "1337807"
102
149
  advance_time 1
103
150
  segment.finish
104
151
  end
@@ -106,10 +153,21 @@ module NewRelic
106
153
  sample = NewRelic::Agent.agent.transaction_sampler.last_sample
107
154
  node = find_node_with_name(sample, segment.name)
108
155
 
109
- assert_equal "localhost", node.params[:host]
156
+ assert_equal "jonan-01", node.params[:host]
110
157
  assert_equal "1337807", node.params[:port_path_or_id]
111
158
  end
112
159
 
160
+ def test_localhost_replaced_by_system_hostname
161
+ NewRelic::Agent::Hostname.stubs(:get).returns("jonan.gummy_planet")
162
+
163
+ %w[localhost 0.0.0.0 127.0.0.1 0:0:0:0:0:0:0:1 0:0:0:0:0:0:0:0 ::1 ::].each do |host|
164
+ segment = NewRelic::Agent::Transaction.start_datastore_segment "SQLite", "select", "blogs", host, "1337"
165
+ segment.finish
166
+
167
+ assert_equal "jonan.gummy_planet", segment.host
168
+ end
169
+ end
170
+
113
171
  def test_does_not_add_instance_identifier_segment_parameter_when_disabled
114
172
  with_config(:'datastore_tracer.instance_reporting.enabled' => false) do
115
173
  segment = nil
@@ -223,6 +281,38 @@ module NewRelic
223
281
  segment.finish
224
282
  end
225
283
  end
284
+
285
+ def test_set_instance_info_with_valid_data
286
+ segment = DatastoreSegment.new "SQLite", "select", nil
287
+ segment.set_instance_info 'jonan.gummy_planet', 1337807
288
+ assert_equal 'jonan.gummy_planet', segment.host
289
+ assert_equal '1337807', segment.port_path_or_id
290
+ end
291
+
292
+ def test_set_instance_info_with_empty_host
293
+ segment = DatastoreSegment.new "SQLite", "select", nil
294
+ segment.set_instance_info nil, 1337807
295
+ assert_equal 'unknown', segment.host
296
+ assert_equal '1337807', segment.port_path_or_id
297
+ end
298
+
299
+ def test_set_instance_info_with_empty_port_path_or_id
300
+ segment = DatastoreSegment.new "SQLite", "select", nil
301
+ segment.set_instance_info 'jonan.gummy_planet', nil
302
+ assert_equal 'jonan.gummy_planet', segment.host
303
+ assert_equal 'unknown', segment.port_path_or_id
304
+ end
305
+
306
+ def test_set_instance_info_with_empty_data
307
+ segment = DatastoreSegment.new "SQLite", "select", nil
308
+ segment.set_instance_info nil, nil
309
+ assert_nil segment.host
310
+ assert_nil segment.port_path_or_id
311
+
312
+ segment.set_instance_info '', ''
313
+ assert_nil segment.host
314
+ assert_nil segment.port_path_or_id
315
+ end
226
316
  end
227
317
  end
228
318
  end
@@ -91,6 +91,15 @@ module NewRelic
91
91
  end
92
92
  end
93
93
 
94
+ def test_start_datastore_segment_provides_defaults_without_params
95
+ segment = Transaction.start_datastore_segment
96
+ segment.finish
97
+
98
+ assert_equal "Datastore/operation/Unknown/other", segment.name
99
+ assert_equal "Unknown", segment.product
100
+ assert_equal "other", segment.operation
101
+ end
102
+
94
103
  def test_start_segment_with_tracing_disabled_in_transaction
95
104
  segment = nil
96
105
  in_transaction "test_txn" do |txn|
@@ -451,7 +451,7 @@ module NewRelic
451
451
  end
452
452
 
453
453
  if a.respond_to? :constants
454
- stack.concat a.constants.map { |c| a.const_get c }.select do |c|
454
+ consts = a.constants.map { |c| a.const_get c }.select do |c|
455
455
  if valid.include?(c.class) && !c.ancestors.include?(Minitest::Test)
456
456
  assert_instance_of String, c.name
457
457
  c.name.start_with?(a.name)
@@ -459,6 +459,7 @@ module NewRelic
459
459
  false
460
460
  end
461
461
  end
462
+ stack.concat consts
462
463
  end
463
464
 
464
465
  break if stack.empty?
@@ -14,7 +14,7 @@ module NewRelic
14
14
  # the gem post-installation, since that's run in our gem's context. So
15
15
  # just fix up the pathing in the test for finding default changelog.
16
16
  if RUBY_VERSION < '1.9.1'
17
- NewRelic::LatestChanges.stubs(:default_changelog).returns(File.join(File.dirname(__FILE__), '..', '..', 'CHANGELOG'))
17
+ NewRelic::LatestChanges.stubs(:default_changelog).returns(File.join(File.dirname(__FILE__), '..', '..', 'CHANGELOG.md'))
18
18
  end
19
19
  end
20
20
 
@@ -30,6 +30,10 @@ module NewRelic::Rack
30
30
  assert NewRelic::Agent.instance.error_collector.enabled?
31
31
  end
32
32
 
33
+ def teardown
34
+ NewRelic::Agent.drop_buffered_data
35
+ end
36
+
33
37
  def test_notice_and_reraise_errors
34
38
  assert_raises RuntimeError do
35
39
  get '/'
@@ -0,0 +1,10 @@
1
+ #!/bin/bash
2
+ #
3
+ # our testing kicks off > 180 travis "builds" so let's use a local gemstash
4
+ # mirror for all of our rubygems needs if we are in our internal testing env
5
+
6
+ set -ev
7
+
8
+ if [ -n "$GEMSTASH_MIRROR" ]; then
9
+ bundle config mirror.https://rubygems.org $GEMSTASH_MIRROR
10
+ fi
@@ -0,0 +1,22 @@
1
+ #!/bin/bash
2
+ #
3
+ # currently there's an incompatibility between Bundler 1.13 with JRuby 1.7, see Bundler issue #4975
4
+ # so we revert bundler versions to 1.12.5 on that version
5
+ #
6
+ # further digging suggests the bundler/jruby problem was actually a jruby bug,
7
+ # apparently fixed in 1.7.26. if we upgrade our older jruby testing, which seems
8
+ # unlikely at this point, be sure to change this uninstall line to point to the
9
+ # correct location.
10
+ #
11
+ # TODO: remove when older rubies are deprecated, RUBY-1668
12
+
13
+ set -ev
14
+
15
+ if [[ `ruby --version` =~ ^jruby\ 1\. ]]; then
16
+ gem uninstall -x -i $HOME/.rvm/gems/jruby-1.7.23@global bundler
17
+ if [ -n "$GEMSTASH_MIRROR" ]; then
18
+ gem install --clear-sources --source $GEMSTASH_MIRROR bundler -v 1.12.5
19
+ else
20
+ gem install bundler -v 1.12.5
21
+ fi
22
+ fi
@@ -0,0 +1,15 @@
1
+ #!/bin/bash
2
+ #
3
+ # revert to older rubygems version for ruby versions prior to 2.0
4
+ #
5
+ # TODO: remove when older rubies are deprecated, RUBY-1668
6
+
7
+ set -ev
8
+
9
+ if [[ `ruby --version` =~ ^ruby\ 1\. ]]; then
10
+ if [ -n "$GEMSTASH_MIRROR" ]; then
11
+ gem update --clear-sources --source $GEMSTASH_MIRROR --system 1.8.25
12
+ else
13
+ gem update --system 1.8.25
14
+ fi
15
+ fi
@@ -0,0 +1,12 @@
1
+ #!/bin/bash
2
+ #
3
+ # Travis default Mongo is currently 2.4.14, which has some instrumentation differences with >= 2.6.
4
+
5
+ set -ev
6
+
7
+ if [[ $GROUP == "database" ]]; then
8
+ wget http://fastdl.mongodb.org/linux/mongodb-linux-x86_64-${MONGODB}.tgz -O /tmp/mongodb.tgz
9
+ mkdir -p /tmp/mongodb/data
10
+ tar -xvf /tmp/mongodb.tgz -C /tmp/mongodb
11
+ /tmp/mongodb/mongodb-linux-x86_64-${MONGODB}/bin/mongod --dbpath /tmp/mongodb/data --bind_ip 127.0.0.1 --noauth &> /dev/null &
12
+ fi
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: newrelic_rpm
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.17.1.326
4
+ version: 3.17.2.327
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tim Krajcar
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2016-11-01 00:00:00.000000000 Z
14
+ date: 2016-12-06 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: rake
@@ -154,7 +154,7 @@ executables:
154
154
  - nrdebug
155
155
  extensions: []
156
156
  extra_rdoc_files:
157
- - CHANGELOG
157
+ - CHANGELOG.md
158
158
  - LICENSE
159
159
  - README.md
160
160
  - CONTRIBUTING.md
@@ -164,7 +164,7 @@ files:
164
164
  - ".project"
165
165
  - ".travis.yml"
166
166
  - ".yardopts"
167
- - CHANGELOG
167
+ - CHANGELOG.md
168
168
  - CONTRIBUTING.md
169
169
  - Gemfile
170
170
  - Guardfile
@@ -251,6 +251,7 @@ files:
251
251
  - lib/new_relic/agent/instrumentation/active_merchant.rb
252
252
  - lib/new_relic/agent/instrumentation/active_record.rb
253
253
  - lib/new_relic/agent/instrumentation/active_record_4.rb
254
+ - lib/new_relic/agent/instrumentation/active_record_5.rb
254
255
  - lib/new_relic/agent/instrumentation/active_record_helper.rb
255
256
  - lib/new_relic/agent/instrumentation/active_record_subscriber.rb
256
257
  - lib/new_relic/agent/instrumentation/acts_as_solr.rb
@@ -550,6 +551,7 @@ files:
550
551
  - test/fixtures/cross_agent_tests/data_transport/data_transport.json
551
552
  - test/fixtures/cross_agent_tests/data_transport/data_transport.md
552
553
  - test/fixtures/cross_agent_tests/datastores/README.md
554
+ - test/fixtures/cross_agent_tests/datastores/datastore_api.json
553
555
  - test/fixtures/cross_agent_tests/datastores/datastore_instances.json
554
556
  - test/fixtures/cross_agent_tests/docker_container_id/README.md
555
557
  - test/fixtures/cross_agent_tests/docker_container_id/cases.json
@@ -981,6 +983,7 @@ files:
981
983
  - test/new_relic/agent/agent_test.rb
982
984
  - test/new_relic/agent/agent_test_controller.rb
983
985
  - test/new_relic/agent/apdex_from_server_test.rb
986
+ - test/new_relic/agent/api_tests/datastore_api_test.rb
984
987
  - test/new_relic/agent/attribute_filter_test.rb
985
988
  - test/new_relic/agent/attribute_processing_test.rb
986
989
  - test/new_relic/agent/audit_logger_test.rb
@@ -1211,8 +1214,11 @@ files:
1211
1214
  - test/performance/suites/thread_profiling.rb
1212
1215
  - test/performance/suites/trace_execution_scoped.rb
1213
1216
  - test/performance/suites/transaction_tracing.rb
1217
+ - test/script/before_install/gemstash_mirror.sh
1218
+ - test/script/before_install/jruby_bundler.sh
1219
+ - test/script/before_install/revert_rubygems.sh
1220
+ - test/script/before_script/install_mongodb.sh
1214
1221
  - test/script/ci.sh
1215
- - test/script/install_mongodb.sh
1216
1222
  - test/script/path_hash.rb
1217
1223
  - test/test_helper.rb
1218
1224
  - ui/helpers/developer_mode_helper.rb
@@ -1,6 +0,0 @@
1
- #!/bin/bash
2
-
3
- wget http://fastdl.mongodb.org/linux/mongodb-linux-x86_64-${MONGODB}.tgz -O /tmp/mongodb.tgz
4
- mkdir -p /tmp/mongodb/data
5
- tar -xvf /tmp/mongodb.tgz -C /tmp/mongodb
6
- /tmp/mongodb/mongodb-linux-x86_64-${MONGODB}/bin/mongod --dbpath /tmp/mongodb/data --bind_ip 127.0.0.1 --noauth &> /dev/null &