newrelic_rpm 3.6.1.88 → 3.6.2.90.beta

Sign up to get free protection for your applications and to get access to all the features.
Files changed (30) hide show
  1. data/CHANGELOG +20 -0
  2. data/Gemfile +1 -0
  3. data/lib/new_relic/agent/autostart.rb +4 -3
  4. data/lib/new_relic/agent/database.rb +14 -17
  5. data/lib/new_relic/agent/instrumentation/active_record.rb +15 -2
  6. data/lib/new_relic/agent/instrumentation/active_record_helper.rb +1 -1
  7. data/lib/new_relic/agent/instrumentation/active_record_subscriber.rb +14 -2
  8. data/lib/new_relic/agent/instrumentation/net.rb +11 -5
  9. data/lib/new_relic/agent/instrumentation/resque.rb +5 -3
  10. data/lib/new_relic/agent/instrumentation/sequel.rb +40 -0
  11. data/lib/new_relic/agent/sql_sampler.rb +14 -4
  12. data/lib/new_relic/agent/transaction_sampler.rb +13 -10
  13. data/lib/new_relic/build.rb +2 -2
  14. data/lib/new_relic/transaction_sample/segment.rb +12 -5
  15. data/lib/new_relic/version.rb +1 -1
  16. data/lib/sequel/extensions/newrelic_instrumentation.rb +103 -0
  17. data/lib/sequel/plugins/newrelic_instrumentation.rb +83 -0
  18. data/test/multiverse/suites/agent_only/thread_profiling_test.rb +1 -1
  19. data/test/multiverse/suites/resque/instrumentation_test.rb +2 -0
  20. data/test/new_relic/agent/database_test.rb +15 -12
  21. data/test/new_relic/agent/instrumentation/net_instrumentation_test.rb +13 -3
  22. data/test/new_relic/agent/instrumentation/sequel_test.rb +285 -0
  23. data/test/new_relic/agent/sql_sampler_test.rb +27 -4
  24. data/test/new_relic/agent/transaction_sampler_test.rb +14 -14
  25. data/test/new_relic/transaction_sample/segment_test.rb +24 -2
  26. data/test/new_relic/transaction_sample_test.rb +1 -1
  27. data/test/test_helper.rb +19 -5
  28. data.tar.gz.sig +0 -0
  29. metadata +17 -26
  30. metadata.gz.sig +0 -0
@@ -40,7 +40,7 @@ class NewRelic::Agent::SqlSamplerTest < Test::Unit::TestCase
40
40
  def test_notice_sql_truncates_query
41
41
  @sampler.notice_first_scope_push nil
42
42
  message = 'a' * 17_000
43
- @sampler.notice_sql message, "Database/test/select", nil, 1.5
43
+ @sampler.notice_sql(message, "Database/test/select", nil, 1.5)
44
44
  assert_equal('a' * 16_381 + '...', @sampler.transaction_data.sql_data[0].sql)
45
45
  end
46
46
 
@@ -127,10 +127,17 @@ class NewRelic::Agent::SqlSamplerTest < Test::Unit::TestCase
127
127
  data = NewRelic::Agent::TransactionSqlData.new
128
128
  data.set_transaction_info("/c/a", {}, 'guid')
129
129
  data.set_transaction_name("WebTransaction/Controller/c/a")
130
+ explainer = NewRelic::Agent::Instrumentation::ActiveRecord::EXPLAINER
130
131
  queries = [
131
- NewRelic::Agent::SlowSql.new("select * from test", "Database/test/select", {}, 1.5),
132
- NewRelic::Agent::SlowSql.new("select * from test", "Database/test/select", {}, 1.2),
133
- NewRelic::Agent::SlowSql.new("select * from test2", "Database/test2/select", {}, 1.1)
132
+ NewRelic::Agent::SlowSql.new("select * from test",
133
+ "Database/test/select", {},
134
+ 1.5, nil, &explainer),
135
+ NewRelic::Agent::SlowSql.new("select * from test",
136
+ "Database/test/select", {},
137
+ 1.2, nil, &explainer),
138
+ NewRelic::Agent::SlowSql.new("select * from test2",
139
+ "Database/test2/select", {},
140
+ 1.1, nil, &explainer)
134
141
  ]
135
142
  data.sql_data.concat(queries)
136
143
  @sampler.harvest_slow_sql data
@@ -199,6 +206,22 @@ class NewRelic::Agent::SqlSamplerTest < Test::Unit::TestCase
199
206
  end
200
207
  end
201
208
 
209
+ def test_can_directly_marshal_traces_for_pipe_transmittal
210
+ with_config(:'transaction_tracer.explain_enabled' => false) do
211
+ data = NewRelic::Agent::TransactionSqlData.new
212
+ explainer = NewRelic::Agent::Instrumentation::ActiveRecord::EXPLAINER
213
+ data.sql_data.concat([NewRelic::Agent::SlowSql.new("select * from test",
214
+ "Database/test/select",
215
+ {}, 1.5, &explainer)])
216
+ @sampler.harvest_slow_sql(data)
217
+ sql_traces = @sampler.harvest
218
+
219
+ assert_nothing_raised do
220
+ Marshal.dump(sql_traces)
221
+ end
222
+ end
223
+ end
224
+
202
225
  def test_to_collector_array
203
226
  with_config(:'transaction_tracer.explain_enabled' => false) do
204
227
  data = NewRelic::Agent::TransactionSqlData.new
@@ -421,14 +421,14 @@ class NewRelic::Agent::TransactionSamplerTest < Test::Unit::TestCase
421
421
 
422
422
  def test_notice_sql_recording_sql
423
423
  Thread.current[:record_sql] = true
424
- @sampler.expects(:notice_extra_data).with('some sql', 1.0, :sql, 'a config', :connection_config)
425
- @sampler.notice_sql('some sql', 'a config', 1.0)
424
+ @sampler.expects(:notice_extra_data).with('some sql', 1.0, :sql)
425
+ @sampler.notice_sql('some sql', {:config => 'a config'}, 1.0)
426
426
  end
427
427
 
428
428
  def test_notice_sql_not_recording
429
429
  Thread.current[:record_sql] = false
430
- @sampler.expects(:notice_extra_data).with('some sql', 1.0, :sql, 'a config', :connection_config).never # <--- important
431
- @sampler.notice_sql('some sql', 'a config', 1.0)
430
+ @sampler.expects(:notice_extra_data).with('some sql', 1.0, :sql).never # <--- important
431
+ @sampler.notice_sql('some sql', {:config => 'a config'}, 1.0)
432
432
  end
433
433
 
434
434
  def test_notice_nosql
@@ -817,7 +817,7 @@ class NewRelic::Agent::TransactionSamplerTest < Test::Unit::TestCase
817
817
 
818
818
  Thread::current[:record_sql] = false
819
819
 
820
- @sampler.notice_sql("test", nil, 0)
820
+ @sampler.notice_sql("test", {}, 0)
821
821
 
822
822
  segment = @sampler.send(:builder).current_segment
823
823
 
@@ -827,7 +827,7 @@ class NewRelic::Agent::TransactionSamplerTest < Test::Unit::TestCase
827
827
  def test_stack_trace__sql
828
828
  with_config(:'transaction_tracer.stack_trace_threshold' => 0) do
829
829
  @sampler.notice_first_scope_push Time.now.to_f
830
- @sampler.notice_sql("test", nil, 1)
830
+ @sampler.notice_sql("test", {}, 1)
831
831
  segment = @sampler.send(:builder).current_segment
832
832
 
833
833
  assert segment[:sql]
@@ -849,7 +849,7 @@ class NewRelic::Agent::TransactionSamplerTest < Test::Unit::TestCase
849
849
  def test_nil_stacktrace
850
850
  with_config(:'transaction_tracer.stack_trace_threshold' => 2) do
851
851
  @sampler.notice_first_scope_push Time.now.to_f
852
- @sampler.notice_sql("test", nil, 1)
852
+ @sampler.notice_sql("test", {}, 1)
853
853
  segment = @sampler.send(:builder).current_segment
854
854
 
855
855
  assert segment[:sql]
@@ -864,7 +864,7 @@ class NewRelic::Agent::TransactionSamplerTest < Test::Unit::TestCase
864
864
 
865
865
  len = 0
866
866
  while len <= 16384
867
- @sampler.notice_sql(sql, nil, 0)
867
+ @sampler.notice_sql(sql, {}, 0)
868
868
  len += sql.length
869
869
  end
870
870
 
@@ -881,7 +881,7 @@ class NewRelic::Agent::TransactionSamplerTest < Test::Unit::TestCase
881
881
 
882
882
  orig_sql = "SELECT * from Jim where id=66"
883
883
 
884
- @sampler.notice_sql(orig_sql, nil, 0)
884
+ @sampler.notice_sql(orig_sql, {}, 0)
885
885
 
886
886
  segment = @sampler.send(:builder).current_segment
887
887
 
@@ -909,9 +909,9 @@ class NewRelic::Agent::TransactionSamplerTest < Test::Unit::TestCase
909
909
  with_config(:'transaction_tracer.limit_segments' => 3) do
910
910
  run_sample_trace do
911
911
  @sampler.notice_push_scope
912
- @sampler.notice_sql("SELECT * FROM sandwiches WHERE bread = 'hallah'", nil, 0)
912
+ @sampler.notice_sql("SELECT * FROM sandwiches WHERE bread = 'hallah'", {}, 0)
913
913
  @sampler.notice_push_scope
914
- @sampler.notice_sql("SELECT * FROM sandwiches WHERE bread = 'semolina'", nil, 0)
914
+ @sampler.notice_sql("SELECT * FROM sandwiches WHERE bread = 'semolina'", {}, 0)
915
915
  @sampler.notice_pop_scope "a11"
916
916
  @sampler.notice_pop_scope "a1"
917
917
  end
@@ -963,13 +963,13 @@ class NewRelic::Agent::TransactionSamplerTest < Test::Unit::TestCase
963
963
  @sampler.notice_transaction(nil, {})
964
964
  @sampler.notice_first_scope_push start
965
965
  @sampler.notice_push_scope
966
- @sampler.notice_sql("SELECT * FROM sandwiches WHERE bread = 'wheat'", nil, 0)
966
+ @sampler.notice_sql("SELECT * FROM sandwiches WHERE bread = 'wheat'", {}, 0)
967
967
  @sampler.notice_push_scope
968
- @sampler.notice_sql("SELECT * FROM sandwiches WHERE bread = 'white'", nil, 0)
968
+ @sampler.notice_sql("SELECT * FROM sandwiches WHERE bread = 'white'", {}, 0)
969
969
  yield if block_given?
970
970
  @sampler.notice_pop_scope "ab"
971
971
  @sampler.notice_push_scope
972
- @sampler.notice_sql("SELECT * FROM sandwiches WHERE bread = 'french'", nil, 0)
972
+ @sampler.notice_sql("SELECT * FROM sandwiches WHERE bread = 'french'", {}, 0)
973
973
  @sampler.notice_pop_scope "ac"
974
974
  @sampler.notice_pop_scope "a"
975
975
  @sampler.notice_scope_empty(@txn, (stop || Time.now.to_f))
@@ -376,7 +376,10 @@ class NewRelic::TransactionSample::SegmentTest < Test::Unit::TestCase
376
376
  def test_explain_sql_raising_an_error
377
377
  s = NewRelic::TransactionSample::Segment.new(Time.now, 'Custom/test/metric', nil)
378
378
  config = mock('config')
379
- s.params = {:sql => 'SELECT', :connection_config => config}
379
+ statement = NewRelic::Agent::Database::Statement.new('SELECT')
380
+ statement.config = config
381
+ statement.explainer = NewRelic::Agent::Instrumentation::ActiveRecord::EXPLAINER
382
+ s.params = {:sql => statement}
380
383
  connection = mock('connection')
381
384
  NewRelic::Agent::Database.expects(:get_connection).with(config).raises(RuntimeError.new("whee"))
382
385
  assert_nothing_raised do
@@ -384,6 +387,25 @@ class NewRelic::TransactionSample::SegmentTest < Test::Unit::TestCase
384
387
  end
385
388
  end
386
389
 
390
+ def test_explain_sql_can_handle_missing_config
391
+ # If TT segment came over from Resque child, might not be a Statement
392
+ s = NewRelic::TransactionSample::Segment.new(Time.now, 'Custom/test/metric', nil)
393
+ s.params = { :sql => "SELECT * FROM galaxy" }
394
+ assert_nothing_raised do
395
+ s.explain_sql
396
+ end
397
+ end
398
+
399
+ def test_explain_sql_can_use_already_existing_plan
400
+ s = NewRelic::TransactionSample::Segment.new(Time.now, 'Custom/test/metric', nil)
401
+ s.params = {
402
+ :sql => "SELECT * FROM galaxy",
403
+ :explain_plan => "EXPLAIN IT!"
404
+ }
405
+
406
+ assert_equal("EXPLAIN IT!", s.explain_sql)
407
+ end
408
+
387
409
  def test_params_equal
388
410
  s = NewRelic::TransactionSample::Segment.new(Time.now, 'Custom/test/metric', nil)
389
411
  assert_equal(nil, s.instance_eval { @params })
@@ -393,7 +415,7 @@ class NewRelic::TransactionSample::SegmentTest < Test::Unit::TestCase
393
415
  s.params = params
394
416
  assert_equal(params, s.instance_eval { @params })
395
417
  end
396
-
418
+
397
419
  def test_obfuscated_sql
398
420
  sql = 'select * from table where id = 1'
399
421
  s = NewRelic::TransactionSample::Segment.new(Time.now, 'Custom/test/metric', nil)
@@ -183,7 +183,7 @@ class NewRelic::TransactionSampleTest < Test::Unit::TestCase
183
183
  sampler.notice_push_scope "level0"
184
184
  sampler.notice_push_scope "level-1"
185
185
  sampler.notice_push_scope "level-2"
186
- sampler.notice_sql(::SQL_STATEMENT, nil, 0)
186
+ sampler.notice_sql(::SQL_STATEMENT, {}, 0)
187
187
  sampler.notice_pop_scope "level-2"
188
188
  sampler.notice_pop_scope "level-1"
189
189
  sampler.notice_pop_scope "level0"
data/test/test_helper.rb CHANGED
@@ -264,6 +264,20 @@ def with_config(config_hash, opts={})
264
264
  end
265
265
  end
266
266
 
267
+
268
+ def with_verbose_logging
269
+ orig_logger = NewRelic::Agent.logger
270
+ $stderr.puts '', '---', ''
271
+ new_logger = NewRelic::Agent::AgentLogger.new( {:log_level => 'debug'}, '', Logger.new($stderr) )
272
+ NewRelic::Agent.logger = new_logger
273
+
274
+ yield
275
+
276
+ ensure
277
+ NewRelic::Agent.logger = orig_logger
278
+ end
279
+
280
+
267
281
  # Need to be a bit sloppy when testing against the logging--let everything
268
282
  # through, but check we (at least) get our particular message we care about
269
283
  def expects_logging(level, *with_params)
@@ -356,8 +370,8 @@ module TransactionSampleTestHelper
356
370
  sampler.notice_first_scope_push Time.now.to_f
357
371
  sampler.notice_transaction(nil, :jim => "cool")
358
372
  sampler.notice_push_scope "a"
359
- sql.each {|sql_statement| sampler.notice_sql(sql_statement, {:adapter => "test"}, 0 ) }
360
-
373
+ explainer = NewRelic::Agent::Instrumentation::ActiveRecord::EXPLAINER
374
+ sql.each {|sql_statement| sampler.notice_sql(sql_statement, {:adapter => "test"}, 0, &explainer) }
361
375
  sleep 0.02
362
376
  yield if block_given?
363
377
  sampler.notice_pop_scope "a"
@@ -370,13 +384,13 @@ module TransactionSampleTestHelper
370
384
  sampler.notice_first_scope_push Time.now.to_f
371
385
  sampler.notice_transaction(path, {})
372
386
  sampler.notice_push_scope "Controller/sandwiches/index"
373
- sampler.notice_sql("SELECT * FROM sandwiches WHERE bread = 'wheat'", nil, 0)
387
+ sampler.notice_sql("SELECT * FROM sandwiches WHERE bread = 'wheat'", {}, 0)
374
388
  sampler.notice_push_scope "ab"
375
- sampler.notice_sql("SELECT * FROM sandwiches WHERE bread = 'white'", nil, 0)
389
+ sampler.notice_sql("SELECT * FROM sandwiches WHERE bread = 'white'", {}, 0)
376
390
  yield sampler if block_given?
377
391
  sampler.notice_pop_scope "ab"
378
392
  sampler.notice_push_scope "lew"
379
- sampler.notice_sql("SELECT * FROM sandwiches WHERE bread = 'french'", nil, 0)
393
+ sampler.notice_sql("SELECT * FROM sandwiches WHERE bread = 'french'", {}, 0)
380
394
  sampler.notice_pop_scope "lew"
381
395
  sampler.notice_pop_scope "Controller/sandwiches/index"
382
396
  sampler.notice_scope_empty(stub('txn', :name => path, :custom_parameters => {}))
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,8 +1,8 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: newrelic_rpm
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.6.1.88
5
- prerelease:
4
+ version: 3.6.2.90.beta
5
+ prerelease: 9
6
6
  platform: ruby
7
7
  authors:
8
8
  - Jason Clark
@@ -41,7 +41,7 @@ cert_chain:
41
41
  cHUySWFQWE92bTNUOEc0TzZxWnZobkxoL1VpZW4rK0RqOGVGQmVjVFBvTThw
42
42
  VmpLM3BoNQpuL0V3dVpDY0U2Z2h0Q0NNCi0tLS0tRU5EIENFUlRJRklDQVRF
43
43
  LS0tLS0K
44
- date: 2013-04-29 00:00:00.000000000 Z
44
+ date: 2013-05-06 00:00:00.000000000 Z
45
45
  dependencies: []
46
46
  description: ! 'New Relic is a performance management system, developed by New Relic,
47
47
 
@@ -145,6 +145,7 @@ files:
145
145
  - lib/new_relic/agent/instrumentation/rails4/errors.rb
146
146
  - lib/new_relic/agent/instrumentation/rainbows_instrumentation.rb
147
147
  - lib/new_relic/agent/instrumentation/resque.rb
148
+ - lib/new_relic/agent/instrumentation/sequel.rb
148
149
  - lib/new_relic/agent/instrumentation/sidekiq.rb
149
150
  - lib/new_relic/agent/instrumentation/sinatra.rb
150
151
  - lib/new_relic/agent/instrumentation/sunspot.rb
@@ -227,6 +228,8 @@ files:
227
228
  - lib/new_relic/url_rule.rb
228
229
  - lib/new_relic/version.rb
229
230
  - lib/newrelic_rpm.rb
231
+ - lib/sequel/extensions/newrelic_instrumentation.rb
232
+ - lib/sequel/plugins/newrelic_instrumentation.rb
230
233
  - lib/tasks/all.rb
231
234
  - lib/tasks/install.rake
232
235
  - lib/tasks/tests.rake
@@ -355,6 +358,7 @@ files:
355
358
  - test/new_relic/agent/instrumentation/net_instrumentation_test.rb
356
359
  - test/new_relic/agent/instrumentation/queue_time_test.rb
357
360
  - test/new_relic/agent/instrumentation/rack_test.rb
361
+ - test/new_relic/agent/instrumentation/sequel_test.rb
358
362
  - test/new_relic/agent/instrumentation/sinatra_test.rb
359
363
  - test/new_relic/agent/instrumentation/task_instrumentation_test.rb
360
364
  - test/new_relic/agent/memcache_instrumentation_test.rb
@@ -508,29 +512,16 @@ files:
508
512
  - lib/new_relic/build.rb
509
513
  homepage: http://www.github.com/newrelic/rpm
510
514
  licenses: []
511
- post_install_message: ! "\n# New Relic Ruby Agent Release Notes #\n\n## v3.6.1 ##\n\n*
512
- Full URIs for HTTP requests are recorded in transaction traces\n\n When recording
513
- a transaction trace node for an outgoing HTTP call via\n Net::HTTP, the agent will
514
- now save the full URI (instead of just the hostname)\n for the request. Embedded
515
- credentials, the query string, and the fragment will\n be stripped from the URI
516
- before it is saved.\n\n* Simplify Agent Autostart Logic\n\n Previously the agent
517
- would only start when it detected a supported\n \"Dispatcher\", meaning a known
518
- web server or background task framework. This\n was problematic for customers
519
- using webservers that the agent was not\n configured to detect (e.g. Puma). Now
520
- the agent will attempt to report any\n time it detects it is running in a monitored
521
- environment (e.g. production).\n There are two exceptions to this. The agent will
522
- not autostart in a rails\n console or irb session or when the process was invoked
523
- by a rake task (e.g.\n rake assets:precompile). The NEWRELIC_ENABLE environment
524
- variable can be set\n to true or false to force the agent to start or not start.\n\n*
525
- Don't attempt to resolve collector hostname when proxy is in use\n\n When a proxy
526
- is configured, the agent will not attempt to lookup and cache the\n IP address
527
- of New Relic server to which it is sending data, since DNS may not\n be available
528
- in some environments. Thanks to Bill Kirtley for the contribution\n\n* Added NewRelic::Agent.set_transaction_name
529
- and NewRelic::Agent.get_transaction_name\n\n Ordinarily the name of your transaction
530
- is defined up-front, but if you'd like to \n change the name of a transaction while
531
- it is still running you can use \n **NewRelic::Agent.set_transaction_name()**.
532
- \ Similarly, if you need to know the name\n of the currently running transaction,
533
- you can use **NewRelic::Agent.get_transaction_name()**.\n\nSee https://github.com/newrelic/rpm/blob/master/CHANGELOG
515
+ post_install_message: ! "\n# New Relic Ruby Agent Release Notes #\n\n## v3.6.2 ##\n\n*
516
+ Sequel support\n\n The Ruby agent now supports Sequel, a database toolkit for Ruby.
517
+ This\n includes capturing SQL calls and model operations in transaction traces,
518
+ and\n recording slow SQL calls. See https://newrelic.com/docs/ruby/sequel-instrumentation\n
519
+ \ for full details.\n\n* Fix for over-counted Net::HTTP calls\n\n Under some circumstances,
520
+ calls into Net::HTTP were being counted twice in\n metrics and transaction traces.
521
+ This has been fixed.\n\n* Missing traced errors for Resque applications\n\n Traced
522
+ errors weren't displaying for some Resque workers, although the errors\n were factored
523
+ into the overall count graphs. This has been fixed, and traced\n errors should
524
+ be available again after upgrading the agent.\n\nSee https://github.com/newrelic/rpm/blob/master/CHANGELOG
534
525
  for a full list of\nchanges.\n"
535
526
  rdoc_options:
536
527
  - --line-numbers
metadata.gz.sig CHANGED
Binary file