traceview 3.0.2-java → 3.0.3-java

Sign up to get free protection for your applications and to get access to all the features.
Files changed (67) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +39 -14
  3. data/Gemfile +4 -62
  4. data/Rakefile +23 -8
  5. data/gemfiles/frameworks.gemfile +40 -0
  6. data/gemfiles/libraries.gemfile +78 -0
  7. data/gemfiles/rails23.gemfile +47 -0
  8. data/gemfiles/rails30.gemfile +47 -0
  9. data/gemfiles/rails31.gemfile +47 -0
  10. data/gemfiles/rails32.gemfile +47 -0
  11. data/gemfiles/rails40.gemfile +35 -0
  12. data/gemfiles/rails41.gemfile +35 -0
  13. data/gemfiles/rails42.gemfile +35 -0
  14. data/lib/traceview/api/logging.rb +84 -38
  15. data/lib/traceview/frameworks/rails/inst/action_controller.rb +1 -1
  16. data/lib/traceview/inst/moped.rb +2 -2
  17. data/lib/traceview/util.rb +30 -34
  18. data/lib/traceview/version.rb +1 -1
  19. data/test/frameworks/apps/grape_nested.rb +3 -0
  20. data/test/frameworks/apps/grape_simple.rb +3 -0
  21. data/test/frameworks/apps/sinatra_simple.rb +3 -0
  22. data/test/frameworks/grape_test.rb +8 -4
  23. data/test/frameworks/padrino_test.rb +6 -2
  24. data/test/frameworks/rails2x_test.rb +3 -0
  25. data/test/frameworks/rails3x_test.rb +91 -0
  26. data/test/frameworks/rails4x_test.rb +89 -0
  27. data/test/frameworks/sinatra_test.rb +3 -0
  28. data/test/instrumentation/cassandra_test.rb +11 -4
  29. data/test/instrumentation/dalli_test.rb +3 -0
  30. data/test/instrumentation/em_http_request_test.rb +3 -0
  31. data/test/instrumentation/excon_test.rb +3 -0
  32. data/test/instrumentation/faraday_test.rb +3 -0
  33. data/test/instrumentation/http_test.rb +3 -0
  34. data/test/instrumentation/httpclient_test.rb +3 -0
  35. data/test/instrumentation/memcache_test.rb +9 -0
  36. data/test/instrumentation/memcached_test.rb +3 -0
  37. data/test/instrumentation/mongo_test.rb +14 -3
  38. data/test/instrumentation/moped_test.rb +29 -6
  39. data/test/instrumentation/rack_test.rb +3 -0
  40. data/test/instrumentation/redis_hashes_test.rb +187 -184
  41. data/test/instrumentation/redis_keys_test.rb +223 -220
  42. data/test/instrumentation/redis_lists_test.rb +225 -225
  43. data/test/instrumentation/redis_misc_test.rb +123 -120
  44. data/test/instrumentation/redis_sets_test.rb +216 -213
  45. data/test/instrumentation/redis_sortedsets_test.rb +245 -242
  46. data/test/instrumentation/redis_strings_test.rb +242 -238
  47. data/test/instrumentation/resque_test.rb +3 -0
  48. data/test/instrumentation/rest-client_test.rb +3 -0
  49. data/test/instrumentation/sequel_mysql2_test.rb +4 -1
  50. data/test/instrumentation/sequel_mysql_test.rb +4 -1
  51. data/test/instrumentation/sequel_pg_test.rb +4 -1
  52. data/test/minitest_helper.rb +25 -8
  53. data/test/profiling/method_test.rb +3 -0
  54. data/test/servers/rackapp_8101.rb +1 -1
  55. data/test/servers/rails2x_8140.rb +2 -2
  56. data/test/servers/rails3x_8140.rb +78 -0
  57. data/test/servers/rails4x_8140.rb +78 -0
  58. data/test/support/backcompat_test.rb +3 -0
  59. data/test/support/config_test.rb +3 -0
  60. data/test/support/dnt_test.rb +3 -0
  61. data/test/support/liboboe_settings_test.rb +3 -0
  62. data/test/support/tvalias_test.rb +3 -0
  63. data/test/support/xtrace_test.rb +3 -0
  64. metadata +19 -5
  65. data/Appraisals +0 -10
  66. data/gemfiles/mongo.gemfile +0 -33
  67. data/gemfiles/moped.gemfile +0 -33
@@ -8,7 +8,7 @@ module TraceView
8
8
  module Version
9
9
  MAJOR = 3
10
10
  MINOR = 0
11
- PATCH = 2
11
+ PATCH = 3
12
12
  BUILD = nil
13
13
 
14
14
  STRING = [MAJOR, MINOR, PATCH, BUILD].compact.join('.')
@@ -1,3 +1,6 @@
1
+ # Copyright (c) 2015 AppNeta, Inc.
2
+ # All rights reserved.
3
+
1
4
  require 'grape'
2
5
 
3
6
  class Wrapper < Grape::API
@@ -1,3 +1,6 @@
1
+ # Copyright (c) 2015 AppNeta, Inc.
2
+ # All rights reserved.
3
+
1
4
  require 'grape'
2
5
 
3
6
  class GrapeSimple < Grape::API
@@ -1,3 +1,6 @@
1
+ # Copyright (c) 2015 AppNeta, Inc.
2
+ # All rights reserved.
3
+
1
4
  require 'sinatra'
2
5
 
3
6
  class SinatraSimple < Sinatra::Base
@@ -1,5 +1,9 @@
1
- if RUBY_VERSION >= '1.9.3'
2
- require 'minitest_helper'
1
+ # Copyright (c) 2015 AppNeta, Inc.
2
+ # All rights reserved.
3
+
4
+ require 'minitest_helper'
5
+
6
+ if RUBY_VERSION >= '1.9.3' and defined?(::Grape)
3
7
  require File.expand_path(File.dirname(__FILE__) + '/apps/grape_simple')
4
8
  require File.expand_path(File.dirname(__FILE__) + '/apps/grape_nested')
5
9
 
@@ -92,8 +96,8 @@ if RUBY_VERSION >= '1.9.3'
92
96
  @app = GrapeSimple
93
97
 
94
98
  begin
95
- r = get "/break"
96
- rescue Exception => e
99
+ get "/break"
100
+ rescue Exception
97
101
  # Do not handle/raise this error so
98
102
  # we can continue to test
99
103
  end
@@ -1,5 +1,9 @@
1
- if RUBY_VERSION >= '1.9.3'
2
- require "minitest_helper"
1
+ # Copyright (c) 2015 AppNeta, Inc.
2
+ # All rights reserved.
3
+
4
+ require "minitest_helper"
5
+
6
+ if RUBY_VERSION >= '1.9.3' and defined?(::Padrino)
3
7
  require File.expand_path(File.dirname(__FILE__) + '/apps/padrino_simple')
4
8
 
5
9
  describe Padrino do
@@ -1,3 +1,6 @@
1
+ # Copyright (c) 2015 AppNeta, Inc.
2
+ # All rights reserved.
3
+
1
4
  require "minitest_helper"
2
5
 
3
6
  if defined?(::Rails)
@@ -0,0 +1,91 @@
1
+ # Copyright (c) 2015 AppNeta, Inc.
2
+ # All rights reserved.
3
+
4
+ require "minitest_helper"
5
+
6
+ if defined?(::Rails)
7
+
8
+ describe "Rails" do
9
+ before do
10
+ clear_all_traces
11
+ end
12
+
13
+ it "should trace a request to a rails stack" do
14
+
15
+ uri = URI.parse('http://127.0.0.1:8140/hello/world')
16
+ r = Net::HTTP.get_response(uri)
17
+
18
+ traces = get_all_traces
19
+
20
+ traces.count.must_equal 8
21
+ valid_edges?(traces).must_equal true
22
+ validate_outer_layers(traces, 'rack')
23
+
24
+ traces[0]['Layer'].must_equal "rack"
25
+ traces[0]['Label'].must_equal "entry"
26
+ traces[0]['URL'].must_equal "/hello/world"
27
+
28
+ traces[1]['Layer'].must_equal "rack"
29
+ traces[1]['Label'].must_equal "info"
30
+
31
+ traces[2]['Layer'].must_equal "rails"
32
+ traces[2]['Label'].must_equal "entry"
33
+
34
+ traces[3]['Label'].must_equal "info"
35
+ traces[3]['Controller'].must_equal "HelloController"
36
+ traces[3]['Action'].must_equal "world"
37
+
38
+ traces[4]['Layer'].must_equal "actionview"
39
+ traces[4]['Label'].must_equal "entry"
40
+
41
+ traces[5]['Layer'].must_equal "actionview"
42
+ traces[5]['Label'].must_equal "exit"
43
+
44
+ traces[6]['Layer'].must_equal "rails"
45
+ traces[6]['Label'].must_equal "exit"
46
+
47
+ traces[7]['Layer'].must_equal "rack"
48
+ traces[7]['Label'].must_equal "exit"
49
+
50
+ # Validate the existence of the response header
51
+ r.header.key?('X-Trace').must_equal true
52
+ r.header['X-Trace'].must_equal traces[7]['X-Trace']
53
+ end
54
+
55
+ it "should trace a request to a rails metal stack" do
56
+
57
+ uri = URI.parse('http://127.0.0.1:8140/hello/metal')
58
+ r = Net::HTTP.get_response(uri)
59
+
60
+ traces = get_all_traces
61
+
62
+ traces.count.must_equal 5
63
+ valid_edges?(traces).must_equal true
64
+ validate_outer_layers(traces, 'rack')
65
+
66
+ traces[0]['Layer'].must_equal "rack"
67
+ traces[0]['Label'].must_equal "entry"
68
+ traces[0]['URL'].must_equal "/hello/metal"
69
+
70
+ traces[1]['Layer'].must_equal "rack"
71
+ traces[1]['Label'].must_equal "info"
72
+
73
+ traces[2]['Label'].must_equal "profile_entry"
74
+ traces[2]['Language'].must_equal "ruby"
75
+ traces[2]['ProfileName'].must_equal "world"
76
+ traces[2]['FunctionName'].must_equal "world"
77
+ traces[2]['Class'].must_equal "FerroController"
78
+
79
+ traces[3]['Label'].must_equal "profile_exit"
80
+ traces[3]['Language'].must_equal "ruby"
81
+ traces[3]['ProfileName'].must_equal "world"
82
+
83
+ traces[4]['Layer'].must_equal "rack"
84
+ traces[4]['Label'].must_equal "exit"
85
+
86
+ # Validate the existence of the response header
87
+ r.header.key?('X-Trace').must_equal true
88
+ r.header['X-Trace'].must_equal traces[4]['X-Trace']
89
+ end
90
+ end
91
+ end
@@ -0,0 +1,89 @@
1
+ # Copyright (c) 2015 AppNeta, Inc.
2
+ # All rights reserved.
3
+
4
+ require "minitest_helper"
5
+
6
+ if defined?(::Rails)
7
+
8
+ describe "Rails" do
9
+ before do
10
+ clear_all_traces
11
+ end
12
+
13
+ it "should trace a request to a rails stack" do
14
+
15
+ uri = URI.parse('http://127.0.0.1:8140/hello/world')
16
+ r = Net::HTTP.get_response(uri)
17
+
18
+ traces = get_all_traces
19
+
20
+ traces.count.must_equal 7
21
+ valid_edges?(traces).must_equal true
22
+ validate_outer_layers(traces, 'rack')
23
+
24
+ traces[0]['Layer'].must_equal "rack"
25
+ traces[0]['Label'].must_equal "entry"
26
+ traces[0]['URL'].must_equal "/hello/world"
27
+
28
+ traces[1]['Layer'].must_equal "rack"
29
+ traces[1]['Label'].must_equal "info"
30
+
31
+ traces[2]['Layer'].must_equal "rails"
32
+ traces[2]['Label'].must_equal "entry"
33
+ traces[2]['Controller'].must_equal "HelloController"
34
+ traces[2]['Action'].must_equal "world"
35
+
36
+ traces[3]['Layer'].must_equal "actionview"
37
+ traces[3]['Label'].must_equal "entry"
38
+
39
+ traces[4]['Layer'].must_equal "actionview"
40
+ traces[4]['Label'].must_equal "exit"
41
+
42
+ traces[5]['Layer'].must_equal "rails"
43
+ traces[5]['Label'].must_equal "exit"
44
+
45
+ traces[6]['Layer'].must_equal "rack"
46
+ traces[6]['Label'].must_equal "exit"
47
+
48
+ # Validate the existence of the response header
49
+ r.header.key?('X-Trace').must_equal true
50
+ r.header['X-Trace'].must_equal traces[6]['X-Trace']
51
+ end
52
+
53
+ it "should trace a request to a rails metal stack" do
54
+
55
+ uri = URI.parse('http://127.0.0.1:8140/hello/metal')
56
+ r = Net::HTTP.get_response(uri)
57
+
58
+ traces = get_all_traces
59
+
60
+ traces.count.must_equal 5
61
+ valid_edges?(traces).must_equal true
62
+ validate_outer_layers(traces, 'rack')
63
+
64
+ traces[0]['Layer'].must_equal "rack"
65
+ traces[0]['Label'].must_equal "entry"
66
+ traces[0]['URL'].must_equal "/hello/metal"
67
+
68
+ traces[1]['Layer'].must_equal "rack"
69
+ traces[1]['Label'].must_equal "info"
70
+
71
+ traces[2]['Label'].must_equal "profile_entry"
72
+ traces[2]['Language'].must_equal "ruby"
73
+ traces[2]['ProfileName'].must_equal "world"
74
+ traces[2]['FunctionName'].must_equal "world"
75
+ traces[2]['Class'].must_equal "FerroController"
76
+
77
+ traces[3]['Label'].must_equal "profile_exit"
78
+ traces[3]['Language'].must_equal "ruby"
79
+ traces[3]['ProfileName'].must_equal "world"
80
+
81
+ traces[4]['Layer'].must_equal "rack"
82
+ traces[4]['Label'].must_equal "exit"
83
+
84
+ # Validate the existence of the response header
85
+ r.header.key?('X-Trace').must_equal true
86
+ r.header['X-Trace'].must_equal traces[4]['X-Trace']
87
+ end
88
+ end
89
+ end
@@ -1,3 +1,6 @@
1
+ # Copyright (c) 2015 AppNeta, Inc.
2
+ # All rights reserved.
3
+
1
4
  require "minitest_helper"
2
5
  require File.expand_path(File.dirname(__FILE__) + '/apps/sinatra_simple')
3
6
 
@@ -1,13 +1,20 @@
1
+ # Copyright (c) 2015 AppNeta, Inc.
2
+ # All rights reserved.
3
+
1
4
  require 'minitest_helper'
2
5
 
6
+ unless ENV['TV_CASSANDRA_SERVER']
7
+ ENV['TV_CASSANDRA_SERVER'] = "127.0.0.1:9160"
8
+ end
9
+
3
10
  # The cassandra-rb client doesn't support JRuby
4
11
  # https://github.com/cassandra-rb/cassandra
5
- unless defined?(JRUBY_VERSION)
12
+ if defined?(::Cassandra) and !defined?(JRUBY_VERSION)
6
13
  describe "Cassandra" do
7
14
  before do
8
15
  clear_all_traces
9
16
 
10
- @client = Cassandra.new("system", "127.0.0.1:9160", { :timeout => 10 })
17
+ @client = Cassandra.new("system", ENV['TV_CASSANDRA_SERVER'], { :timeout => 10 })
11
18
  @client.disable_node_auto_discovery!
12
19
 
13
20
  @ks_name = "AppNetaCassandraTest"
@@ -34,8 +41,8 @@ unless defined?(JRUBY_VERSION)
34
41
  @entry_kvs = {
35
42
  'Layer' => 'cassandra',
36
43
  'Label' => 'entry',
37
- 'RemoteHost' => '127.0.0.1',
38
- 'RemotePort' => '9160' }
44
+ 'RemoteHost' => ENV['TV_CASSANDRA_SERVER'].split(':')[0],
45
+ 'RemotePort' => ENV['TV_CASSANDRA_SERVER'].split(':')[1] }
39
46
 
40
47
  @exit_kvs = { 'Layer' => 'cassandra', 'Label' => 'exit' }
41
48
  @collect_backtraces = TraceView::Config[:cassandra][:collect_backtraces]
@@ -1,3 +1,6 @@
1
+ # Copyright (c) 2015 AppNeta, Inc.
2
+ # All rights reserved.
3
+
1
4
  require 'minitest_helper'
2
5
 
3
6
  describe "Dalli" do
@@ -1,3 +1,6 @@
1
+ # Copyright (c) 2015 AppNeta, Inc.
2
+ # All rights reserved.
3
+
1
4
  require 'minitest_helper'
2
5
 
3
6
  # Disable this test on JRuby until we can investigate
@@ -1,3 +1,6 @@
1
+ # Copyright (c) 2015 AppNeta, Inc.
2
+ # All rights reserved.
3
+
1
4
  require 'minitest_helper'
2
5
  require 'traceview/inst/rack'
3
6
  require File.expand_path(File.dirname(__FILE__) + '../../frameworks/apps/sinatra_simple')
@@ -1,3 +1,6 @@
1
+ # Copyright (c) 2015 AppNeta, Inc.
2
+ # All rights reserved.
3
+
1
4
  require 'minitest_helper'
2
5
 
3
6
  describe "Faraday" do
@@ -1,3 +1,6 @@
1
+ # Copyright (c) 2015 AppNeta, Inc.
2
+ # All rights reserved.
3
+
1
4
  require 'minitest_helper'
2
5
  require 'net/http'
3
6
 
@@ -1,3 +1,6 @@
1
+ # Copyright (c) 2015 AppNeta, Inc.
2
+ # All rights reserved.
3
+
1
4
  require 'minitest_helper'
2
5
  require 'traceview/inst/rack'
3
6
  require File.expand_path(File.dirname(__FILE__) + '../../frameworks/apps/sinatra_simple')
@@ -1,5 +1,14 @@
1
+ # Copyright (c) 2015 AppNeta, Inc.
2
+ # All rights reserved.
3
+
1
4
  require 'minitest_helper'
5
+
6
+ # FIXME: Since memcache is loaded late, the instrumentation
7
+ # loaded out of order. Here we force inject instrumentation
2
8
  require 'memcache'
9
+ ::MemCache.class_eval do
10
+ include TraceView::Inst::MemCache
11
+ end
3
12
 
4
13
  describe "Memcache" do
5
14
  before do
@@ -1,3 +1,6 @@
1
+ # Copyright (c) 2015 AppNeta, Inc.
2
+ # All rights reserved.
3
+
1
4
  require 'minitest_helper'
2
5
 
3
6
  if RUBY_VERSION < '2.0' and not defined?(JRUBY_VERSION)
@@ -1,10 +1,21 @@
1
+ # Copyright (c) 2015 AppNeta, Inc.
2
+ # All rights reserved.
3
+
1
4
  require 'minitest_helper'
2
5
 
6
+ unless ENV['TV_MONGO_SERVER']
7
+ ENV['TV_MONGO_SERVER'] = "127.0.0.1:27017"
8
+ end
9
+
3
10
  if defined?(::BSON::VERSION) and (BSON::VERSION < "2.0")
4
11
  describe "Mongo" do
5
12
  before do
6
13
  clear_all_traces
7
- @connection = Mongo::Connection.new("localhost", 27017, :slave_ok => true)
14
+
15
+ @mongo_server = ENV['TV_MONGO_SERVER'].split(':')[0]
16
+ @mongo_port = ENV['TV_MONGO_SERVER'].split(':')[1]
17
+
18
+ @connection = Mongo::Connection.new(@mongo_server, @mongo_port, :slave_ok => true)
8
19
  @db = @connection.db("test-#{ENV['RACK_ENV']}")
9
20
 
10
21
  @collections = @db.collection_names
@@ -16,8 +27,8 @@ if defined?(::BSON::VERSION) and (BSON::VERSION < "2.0")
16
27
  'Label' => 'entry',
17
28
  'Flavor' => 'mongodb',
18
29
  'Database' => 'test-test',
19
- 'RemoteHost' => 'localhost',
20
- 'RemotePort' => '27017' }
30
+ 'RemoteHost' => @mongo_server,
31
+ 'RemotePort' => @mongo_port }
21
32
 
22
33
  @exit_kvs = { 'Layer' => 'mongo', 'Label' => 'exit' }
23
34
  @collect_backtraces = TraceView::Config[:mongo][:collect_backtraces]
@@ -1,14 +1,22 @@
1
+ # Copyright (c) 2015 AppNeta, Inc.
2
+ # All rights reserved.
3
+
1
4
  require 'minitest_helper'
2
5
 
6
+ unless ENV['TV_MONGO_SERVER']
7
+ ENV['TV_MONGO_SERVER'] = "127.0.0.1:27017"
8
+ end
9
+
3
10
  if RUBY_VERSION >= '1.9.3'
4
11
  # Moped is tested against MRI 1.9.3, 2.0.0, and JRuby (1.9).
5
12
 
6
13
  describe "Moped" do
7
14
  before do
8
15
  clear_all_traces
9
- @session = Moped::Session.new([ "127.0.0.1:27017" ])
16
+ @session = Moped::Session.new([ ENV['TV_MONGO_SERVER'] ])
10
17
  @session.use :moped_test
11
18
  @users = @session[:users]
19
+ @users.drop
12
20
  @users.insert({ :name => "Syd", :city => "Boston" })
13
21
 
14
22
  # These are standard entry/exit KVs that are passed up with all moped operations
@@ -17,8 +25,8 @@ if RUBY_VERSION >= '1.9.3'
17
25
  'Label' => 'entry',
18
26
  'Flavor' => 'mongodb',
19
27
  'Database' => 'moped_test',
20
- 'RemoteHost' => '127.0.0.1',
21
- 'RemotePort' => 27017 }
28
+ 'RemoteHost' => ENV['TV_MONGO_SERVER'].split(':')[0],
29
+ 'RemotePort' => ENV['TV_MONGO_SERVER'].split(':')[1].to_i }
22
30
 
23
31
  @exit_kvs = { 'Layer' => 'mongo', 'Label' => 'exit' }
24
32
  @collect_backtraces = TraceView::Config[:moped][:collect_backtraces]
@@ -252,10 +260,25 @@ if RUBY_VERSION >= '1.9.3'
252
260
  end
253
261
 
254
262
  it 'should trace find and update' do
263
+ 2.times { @users.insert(:name => "Mary") }
264
+ mary_count = @users.find(:name => "Mary").count
265
+ mary_count.wont_equal 0
266
+
267
+ tool_count = @users.find(:name => "Tool").count
268
+ tool_count.must_equal 0
269
+
255
270
  TraceView::API.start_trace('moped_test', '', {}) do
256
- @users.find(:name => "Mary").update({:name => "Tool"}, [:multi])
271
+ old_attrs = { :name => "Mary" }
272
+ new_attrs = { :name => "Tool" }
273
+ @users.find(old_attrs).update({ '$set' => new_attrs }, { :multi => true })
257
274
  end
258
275
 
276
+ new_tool_count = @users.find(:name => "Tool").count
277
+ new_tool_count.must_equal mary_count
278
+
279
+ new_mary_count = @users.find(:name => "Mary").count
280
+ new_mary_count.must_equal 0
281
+
259
282
  traces = get_all_traces
260
283
 
261
284
  traces.count.must_equal 6
@@ -270,8 +293,8 @@ if RUBY_VERSION >= '1.9.3'
270
293
 
271
294
  validate_event_keys(traces[3], @entry_kvs)
272
295
  traces[3]['QueryOp'].must_equal "update"
273
- traces[3]['Update_Document'].must_equal "{\"name\":\"Tool\"}"
274
- traces[3]['Flags'].must_equal "[:multi]"
296
+ traces[3]['Update_Document'].must_equal "{\"$set\":{\"name\":\"Tool\"}}"
297
+ traces[3]['Flags'].must_equal "{:multi=>true}"
275
298
  traces[3]['Collection'].must_equal "users"
276
299
  traces[3].has_key?('Backtrace').must_equal TraceView::Config[:moped][:collect_backtraces]
277
300
  validate_event_keys(traces[4], @exit_kvs)