traceview 3.4.0 → 3.4.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d3029be0337827c7de7eca2889e8f3aa3732dcbc
4
- data.tar.gz: c0ba1fa22930d6dfa53c26e8353060dbcaa766a2
3
+ metadata.gz: 1bda294e0067e87b9af61f29fcbcbba2067fd303
4
+ data.tar.gz: eb61919fb53e67280672a1eb802b4c1ecf755b02
5
5
  SHA512:
6
- metadata.gz: da0fcc463baf1ca59741a56ebd153a79a535715fdc9afae715f0eea852066a5f0f1a724594ecbf962c85500746ac7202bfb60608ee6088aea544b8ac1af31a6b
7
- data.tar.gz: d2f690d069e77c88ec1bd9e9beef10eb190607ea6eba3f65485e132b6f0cb4bd61610295e950c9b0af009c060c7dbf85f406cde92cd72b44381aa72a1644004e
6
+ metadata.gz: 617b228a1328c791c90c69342bb033e45fde13c09a07c882113077251cbc8daaeeda68550aa8be000cf612a230d4e50fc6e603837a733ac1636c0f6b406ed448
7
+ data.tar.gz: b56c282a787c2e1826d4eb87ba37e2ee62ec1f10bdd880860a08eb49301294d97ef6d36b05932f2b28cf55997b965c4894dbaa537804e2d24831e47ce7a48ebb
data/.travis.yml CHANGED
@@ -35,14 +35,6 @@ matrix:
35
35
  - rvm: 1.8.7
36
36
  gemfile: gemfiles/frameworks.gemfile
37
37
 
38
- allow_failures:
39
- - rvm: jruby-9.0.4.0
40
- gemfile: gemfiles/rails32.gemfile
41
-
42
- - rvm: jruby-9.0.4.0
43
- gemfile: gemfiles/rails42.gemfile
44
-
45
-
46
38
  # Attempt Travis/Cassandra fix re: https://github.com/travis-ci/travis-ci/issues/1484
47
39
  # Updated Cassandra: https://github.com/travis-ci/travis-ci/issues/1650
48
40
  before_install:
data/CHANGELOG.md CHANGED
@@ -4,6 +4,20 @@ https://github.com/appneta/oboe-ruby/releases
4
4
 
5
5
  Dates in this file are in the format MM/DD/YYYY.
6
6
 
7
+ # traceview 3.4.1
8
+
9
+ This patch release includes the following fixes:
10
+
11
+ * Instrumentation updates to support Grape version 0.14: #153
12
+ * Fix Rack layer AVW header handling and analysis: #154
13
+ * Sidekiq workers are now auto instrumented: #155
14
+ * Fix ActiveRecord reporting invalid SQL Flavor: #156
15
+
16
+ Pushed to Rubygems:
17
+
18
+ https://rubygems.org/gems/traceview/versions/3.4.1
19
+ https://rubygems.org/gems/traceview/versions/3.4.1-java
20
+
7
21
  # traceview 3.4.0
8
22
 
9
23
  This minor release includes the following features & fixes:
@@ -10,18 +10,6 @@ group :development, :test do
10
10
  gem 'bson'
11
11
  end
12
12
 
13
- group :development do
14
- gem 'ruby-debug', :platforms => [ :mri_18, :jruby ]
15
- gem 'debugger', :platform => :mri_19
16
- gem 'byebug', :platforms => [ :mri_20, :mri_21, :mri_22 ]
17
- if RUBY_VERSION > '1.8.7'
18
- gem 'pry'
19
- gem 'pry-byebug', :platforms => [ :mri_20, :mri_21, :mri_22 ]
20
- else
21
- gem 'pry', '0.9.12.4'
22
- end
23
- end
24
-
25
13
  if defined?(JRUBY_VERSION)
26
14
  gem 'sinatra', :require => false
27
15
  gem 'activerecord-jdbc-adapter'
@@ -14,26 +14,21 @@ group :development, :test do
14
14
  end
15
15
  end
16
16
 
17
- group :development do
18
- gem 'ruby-debug', :platforms => [ :mri_18, :jruby ]
19
- gem 'debugger', :platform => :mri_19
20
- gem 'byebug', :platforms => [ :mri_20, :mri_21, :mri_22 ]
21
- if RUBY_VERSION > '1.8.7'
22
- gem 'pry'
23
- gem 'pry-byebug', :platforms => [ :mri_20, :mri_21, :mri_22 ]
24
- else
25
- gem 'pry', '0.9.12.4'
26
- end
27
- end
28
-
29
17
  if defined?(JRUBY_VERSION)
30
18
  gem 'sinatra', :require => false
31
19
  else
32
20
  gem 'sinatra'
33
21
  end
34
22
 
35
- gem "grape", "< 0.14"
36
- gem "padrino", '< 0.13'
23
+ gem "grape"
24
+
25
+ if defined?(JRUBY_VERSION)
26
+ # Limit padrino gem under JRuby as version 0.13.0 throws
27
+ # a bundler load error
28
+ gem "padrino", '< 0.13.0'
29
+ else
30
+ gem 'padrino'
31
+ end
37
32
 
38
33
  gemspec :path => File.expand_path(File.dirname(__FILE__) + '/../')
39
34
  # vim:syntax=ruby
@@ -24,18 +24,6 @@ group :development, :test do
24
24
  end
25
25
  end
26
26
 
27
- group :development do
28
- gem 'ruby-debug', :platforms => [ :mri_18, :jruby ]
29
- gem 'debugger', :platform => :mri_19
30
- gem 'byebug', :platforms => [ :mri_20, :mri_21, :mri_22 ]
31
- if RUBY_VERSION > '1.8.7'
32
- gem 'pry'
33
- gem 'pry-byebug', :platforms => [ :mri_20, :mri_21, :mri_22 ]
34
- else
35
- gem 'pry', '0.9.12.4'
36
- end
37
- end
38
-
39
27
  if defined?(JRUBY_VERSION)
40
28
  gem 'sinatra', :require => false
41
29
  else
@@ -27,18 +27,6 @@ group :development, :test do
27
27
  end
28
28
  end
29
29
 
30
- group :development do
31
- gem 'ruby-debug', :platforms => [ :mri_18, :jruby ]
32
- gem 'debugger', :platform => :mri_19
33
- gem 'byebug', :platforms => [ :mri_20, :mri_21, :mri_22 ]
34
- if RUBY_VERSION > '1.8.7'
35
- gem 'pry'
36
- gem 'pry-byebug', :platforms => [ :mri_20, :mri_21, :mri_22 ]
37
- else
38
- gem 'pry', '0.9.12.4'
39
- end
40
- end
41
-
42
30
  if defined?(JRUBY_VERSION)
43
31
  gem 'sinatra', :require => false
44
32
  else
@@ -27,18 +27,6 @@ group :development, :test do
27
27
  end
28
28
  end
29
29
 
30
- group :development do
31
- gem 'ruby-debug', :platforms => [ :mri_18, :jruby ]
32
- gem 'debugger', :platform => :mri_19
33
- gem 'byebug', :platforms => [ :mri_20, :mri_21, :mri_22 ]
34
- if RUBY_VERSION > '1.8.7'
35
- gem 'pry'
36
- gem 'pry-byebug', :platforms => [ :mri_20, :mri_21, :mri_22 ]
37
- else
38
- gem 'pry', '0.9.12.4'
39
- end
40
- end
41
-
42
30
  if defined?(JRUBY_VERSION)
43
31
  gem 'sinatra', :require => false
44
32
  gem 'activerecord-jdbc-adapter'
@@ -27,18 +27,6 @@ group :development, :test do
27
27
  end
28
28
  end
29
29
 
30
- group :development do
31
- gem 'ruby-debug', :platforms => [ :mri_18, :jruby ]
32
- gem 'debugger', :platform => :mri_19
33
- gem 'byebug', :platforms => [ :mri_20, :mri_21, :mri_22 ]
34
- if RUBY_VERSION > '1.8.7'
35
- gem 'pry'
36
- gem 'pry-byebug', :platforms => [ :mri_20, :mri_21, :mri_22 ]
37
- else
38
- gem 'pry', '0.9.12.4'
39
- end
40
- end
41
-
42
30
  if defined?(JRUBY_VERSION)
43
31
  gem 'sinatra', :require => false
44
32
  gem 'activerecord-jdbc-adapter'
@@ -27,18 +27,6 @@ group :development, :test do
27
27
  end
28
28
  end
29
29
 
30
- group :development do
31
- gem 'ruby-debug', :platforms => [ :mri_18, :jruby ]
32
- gem 'debugger', :platform => :mri_19
33
- gem 'byebug', :platforms => [ :mri_20, :mri_21, :mri_22 ]
34
- if RUBY_VERSION > '1.8.7'
35
- gem 'pry'
36
- gem 'pry-byebug', :platforms => [ :mri_20, :mri_21, :mri_22 ]
37
- else
38
- gem 'pry', '0.9.12.4'
39
- end
40
- end
41
-
42
30
  if defined?(JRUBY_VERSION)
43
31
  gem 'sinatra', :require => false
44
32
  gem 'activerecord-jdbc-adapter'
@@ -10,18 +10,6 @@ group :development, :test do
10
10
  gem 'bson'
11
11
  end
12
12
 
13
- group :development do
14
- gem 'ruby-debug', :platforms => [ :mri_18, :jruby ]
15
- gem 'debugger', :platform => :mri_19
16
- gem 'byebug', :platforms => [ :mri_20, :mri_21, :mri_22 ]
17
- if RUBY_VERSION > '1.8.7'
18
- gem 'pry'
19
- gem 'pry-byebug', :platforms => [ :mri_20, :mri_21, :mri_22 ]
20
- else
21
- gem 'pry', '0.9.12.4'
22
- end
23
- end
24
-
25
13
  if defined?(JRUBY_VERSION)
26
14
  gem 'sinatra', :require => false
27
15
  gem 'activerecord-jdbc-adapter'
@@ -10,18 +10,6 @@ group :development, :test do
10
10
  gem 'bson'
11
11
  end
12
12
 
13
- group :development do
14
- gem 'ruby-debug', :platforms => [ :mri_18, :jruby ]
15
- gem 'debugger', :platform => :mri_19
16
- gem 'byebug', :platforms => [ :mri_20, :mri_21, :mri_22 ]
17
- if RUBY_VERSION > '1.8.7'
18
- gem 'pry'
19
- gem 'pry-byebug', :platforms => [ :mri_20, :mri_21, :mri_22 ]
20
- else
21
- gem 'pry', '0.9.12.4'
22
- end
23
- end
24
-
25
13
  if defined?(JRUBY_VERSION)
26
14
  gem 'sinatra', :require => false
27
15
  gem 'activerecord-jdbc-adapter'
@@ -10,18 +10,6 @@ group :development, :test do
10
10
  gem 'bson'
11
11
  end
12
12
 
13
- group :development do
14
- gem 'ruby-debug', :platforms => [ :mri_18, :jruby ]
15
- gem 'debugger', :platform => :mri_19
16
- gem 'byebug', :platforms => [ :mri_20, :mri_21, :mri_22 ]
17
- if RUBY_VERSION > '1.8.7'
18
- gem 'pry'
19
- gem 'pry-byebug', :platforms => [ :mri_20, :mri_21, :mri_22 ]
20
- else
21
- gem 'pry', '0.9.12.4'
22
- end
23
- end
24
-
25
13
  if defined?(JRUBY_VERSION)
26
14
  gem 'sinatra', :require => false
27
15
  gem 'activerecord-jdbc-adapter'
data/lib/joboe_metal.rb CHANGED
@@ -145,9 +145,13 @@ module TraceView
145
145
  class << self
146
146
  def sample?(opts = {})
147
147
  begin
148
- return false unless TraceView.always? && TraceView.loaded
148
+ # Return false if no-op mode
149
+ return false if !TraceView.loaded
149
150
 
150
- return true if ENV.key?('TRACEVIEW_GEM_TEST')
151
+ # Return false if never or through mode without AVW flag
152
+ return false if TraceView.never? || (TraceView.through? && !opts.key?('X-TV-Meta'))
153
+
154
+ return true if ENV.key?('TRACEVIEW_GEM_TEST') && !opts.key?('X-TV-Meta')
151
155
 
152
156
  # Validation to make Joboe happy. Assure that we have the KVs and that they
153
157
  # are not empty strings.
data/lib/oboe_metal.rb CHANGED
@@ -98,7 +98,11 @@ module TraceView
98
98
  class << self
99
99
  def sample?(opts = {})
100
100
  begin
101
- return false unless TraceView.always? && TraceView.loaded
101
+ # Return false if no-op mode
102
+ return false if !TraceView.loaded
103
+
104
+ # Return false if never or through mode without AVW flag
105
+ return false if TraceView.never? || (TraceView.through? && !opts.key?('X-TV-Meta'))
102
106
 
103
107
  # Assure defaults since SWIG enforces Strings
104
108
  layer = opts[:layer] ? opts[:layer].to_s.strip : ''
@@ -125,7 +125,12 @@ module TraceView
125
125
  # sample rate and sample source
126
126
  opts[:SampleRate] = TraceView.sample_rate
127
127
  opts[:SampleSource] = TraceView.sample_source
128
- opts[:TraceOrigin] = :always_sampled
128
+
129
+ if TraceView.through? && opts.key?('X-TV-Meta')
130
+ opts[:TraceOrigin] = :avw_sampled
131
+ else
132
+ opts[:TraceOrigin] = :always_sampled
133
+ end
129
134
 
130
135
  log_event(layer, 'entry', TraceView::Context.startTrace, opts)
131
136
  end
@@ -142,7 +142,7 @@ module TraceViewBase
142
142
  # DelayedJob or Sidekiq workers.
143
143
  #
144
144
  def entry_layer?(layer)
145
- %w(delayed_job-worker).include?(layer.to_s)
145
+ %w(delayed_job-worker sidekiq-worker).include?(layer.to_s)
146
146
  end
147
147
 
148
148
  ##
@@ -20,12 +20,17 @@ module TraceView
20
20
  ::TraceView::Util.method_alias(klass, :run, ::Grape::Endpoint)
21
21
  end
22
22
 
23
- def run_with_traceview(env)
23
+ def run_with_traceview(*args)
24
24
  if TraceView.tracing?
25
25
  report_kvs = {}
26
26
 
27
27
  report_kvs[:Controller] = self.class
28
- report_kvs[:Action] = env['PATH_INFO']
28
+
29
+ if args.empty?
30
+ report_kvs[:Action] = env['PATH_INFO']
31
+ else
32
+ report_kvs[:Action] = args[0]['PATH_INFO']
33
+ end
29
34
 
30
35
  # Fall back to the raw tracing API so we can pass KVs
31
36
  # back on exit (a limitation of the TraceView::API.trace
@@ -34,12 +39,12 @@ module TraceView
34
39
  ::TraceView::API.log_entry('grape', {})
35
40
 
36
41
  begin
37
- run_without_traceview(env)
42
+ run_without_traceview(*args)
38
43
  ensure
39
44
  ::TraceView::API.log_exit('grape', report_kvs)
40
45
  end
41
46
  else
42
- run_without_traceview(env)
47
+ run_without_traceview(*args)
43
48
  end
44
49
  end
45
50
  end
@@ -25,12 +25,21 @@ module TraceView
25
25
  if ::Rails::VERSION::MAJOR == 2
26
26
  config = ::Rails.configuration.database_configuration[::Rails.env]
27
27
  else
28
- config = ::Rails.application.config.database_configuration[::Rails.env]
28
+ config = ActiveRecord::Base.connection.instance_variable_get(:@config)
29
29
  end
30
30
 
31
- opts[:Database] = config['database'] if config && config.key?('database')
32
- opts[:RemoteHost] = config['host'] if config && config.key?('host')
33
- opts[:Flavor] = config['adapter'] if config && config.key?('adapter')
31
+ if config
32
+ opts[:Database] = config['database'] if config.key?('database')
33
+ opts[:RemoteHost] = config['host'] if config.key?('host')
34
+ adapter_name = config[:adapter]
35
+
36
+ case adapter_name
37
+ when /mysql/i
38
+ opts[:Flavor] = 'mysql'
39
+ when /postgres/i
40
+ opts[:Flavor] = 'postgresql'
41
+ end
42
+ end
34
43
  rescue StandardError => e
35
44
  TraceView.logger.debug "Exception raised capturing ActiveRecord KVs: #{e.inspect}"
36
45
  TraceView.logger.debug e.backtrace.join('\n')
@@ -27,8 +27,6 @@ module TraceView
27
27
  report_kvs['Query-String'] = ::CGI.unescape(req.query_string) unless req.query_string.empty?
28
28
  end
29
29
 
30
- report_kvs['X-TV-Meta'] = env['HTTP_X_TV_META'] if env.key?('HTTP_X_TV_META')
31
-
32
30
  # Report any request queue'ing headers. Report as 'Request-Start' or the summed Queue-Time
33
31
  report_kvs['Request-Start'] = env['HTTP_X_REQUEST_START'] if env.key?('HTTP_X_REQUEST_START')
34
32
  report_kvs['Request-Start'] = env['HTTP_X_QUEUE_START'] if env.key?('HTTP_X_QUEUE_START')
@@ -73,6 +71,9 @@ module TraceView
73
71
  report_kvs[:URL] = ::CGI.unescape(req.path)
74
72
  end
75
73
 
74
+ # Detect and log AVW headers for sampling analysis
75
+ report_kvs['X-TV-Meta'] = env['HTTP_X_TV_META'] if env.key?('HTTP_X_TV_META')
76
+
76
77
  # Check for and validate X-Trace request header to pick up tracing context
77
78
  xtrace = env.is_a?(Hash) ? env['HTTP_X_TRACE'] : nil
78
79
  xtrace_header = xtrace if xtrace && TraceView::XTrace.valid?(xtrace)
@@ -8,7 +8,7 @@ module TraceView
8
8
  module Version
9
9
  MAJOR = 3
10
10
  MINOR = 4
11
- PATCH = 0
11
+ PATCH = 1
12
12
  BUILD = nil
13
13
 
14
14
  STRING = [MAJOR, MINOR, PATCH, BUILD].compact.join('.')
@@ -9,7 +9,7 @@ PADRINO_ROOT = File.dirname(__FILE__) unless defined? PADRINO_ROOT
9
9
 
10
10
  class SimpleDemo < Padrino::Application
11
11
  set :public_folder, File.dirname(__FILE__)
12
- set :reload, true
12
+ set :reload, false
13
13
  before { true }
14
14
  after { true }
15
15
  error(404) { "404" }
@@ -5,7 +5,7 @@ require "minitest_helper"
5
5
 
6
6
  if defined?(::Rails)
7
7
 
8
- describe "Rails" do
8
+ describe "Rails3x" do
9
9
  before do
10
10
  clear_all_traces
11
11
  end
@@ -97,5 +97,45 @@ if defined?(::Rails)
97
97
  r.header.key?('X-Trace').must_equal true
98
98
  r.header['X-Trace'].must_equal traces[4]['X-Trace']
99
99
  end
100
+
101
+ it "should trace rails db calls" do
102
+ # Skip for JRuby since the java instrumentation
103
+ # handles DB instrumentation for JRuby
104
+ skip if defined?(JRUBY_VERSION)
105
+
106
+ uri = URI.parse('http://127.0.0.1:8140/hello/db')
107
+ r = Net::HTTP.get_response(uri)
108
+
109
+ traces = get_all_traces
110
+
111
+ traces.count.must_equal 12
112
+ valid_edges?(traces).must_equal true
113
+ validate_outer_layers(traces, 'rack')
114
+
115
+ traces[4]['Layer'].must_equal "activerecord"
116
+ traces[4]['Label'].must_equal "entry"
117
+ traces[4]['Flavor'].must_equal "postgresql"
118
+ traces[4]['Query'].must_equal "SELECT \"widgets\".* FROM \"widgets\" "
119
+ traces[4]['Name'].must_equal "Widget Load"
120
+ traces[4].key?('Backtrace').must_equal true
121
+
122
+ traces[5]['Layer'].must_equal "activerecord"
123
+ traces[5]['Label'].must_equal "exit"
124
+
125
+ traces[6]['Layer'].must_equal "activerecord"
126
+ traces[6]['Label'].must_equal "entry"
127
+ traces[6]['Flavor'].must_equal "postgresql"
128
+ traces[6]['Query'].must_equal "INSERT INTO \"widgets\" (\"created_at\", \"description\", \"name\", \"updated_at\") VALUES ($1, $2, $3, $4) RETURNING \"id\""
129
+ traces[6]['Name'].must_equal "SQL"
130
+ traces[6].key?('Backtrace').must_equal true
131
+ traces[6].key?('QueryArgs').must_equal true
132
+
133
+ traces[7]['Layer'].must_equal "activerecord"
134
+ traces[7]['Label'].must_equal "exit"
135
+
136
+ # Validate the existence of the response header
137
+ r.header.key?('X-Trace').must_equal true
138
+ r.header['X-Trace'].must_equal traces[11]['X-Trace']
139
+ end
100
140
  end
101
141
  end
@@ -5,7 +5,7 @@ require "minitest_helper"
5
5
 
6
6
  if defined?(::Rails)
7
7
 
8
- describe "Rails" do
8
+ describe "Rails4x" do
9
9
  before do
10
10
  clear_all_traces
11
11
  end
@@ -55,6 +55,46 @@ if defined?(::Rails)
55
55
  r.header['X-Trace'].must_equal traces[6]['X-Trace']
56
56
  end
57
57
 
58
+ it "should trace rails db calls" do
59
+ # Skip for JRuby since the java instrumentation
60
+ # handles DB instrumentation for JRuby
61
+ skip if defined?(JRUBY_VERSION)
62
+
63
+ uri = URI.parse('http://127.0.0.1:8140/hello/db')
64
+ r = Net::HTTP.get_response(uri)
65
+
66
+ traces = get_all_traces
67
+
68
+ traces.count.must_equal 11
69
+ valid_edges?(traces).must_equal true
70
+ validate_outer_layers(traces, 'rack')
71
+
72
+ traces[3]['Layer'].must_equal "activerecord"
73
+ traces[3]['Label'].must_equal "entry"
74
+ traces[3]['Flavor'].must_equal "postgresql"
75
+ traces[3]['Query'].must_equal "SELECT \"widgets\".* FROM \"widgets\" ORDER BY \"widgets\".\"id\" ASC LIMIT 1"
76
+ traces[3]['Name'].must_equal "Widget Load"
77
+ traces[3].key?('Backtrace').must_equal true
78
+
79
+ traces[4]['Layer'].must_equal "activerecord"
80
+ traces[4]['Label'].must_equal "exit"
81
+
82
+ traces[5]['Layer'].must_equal "activerecord"
83
+ traces[5]['Label'].must_equal "entry"
84
+ traces[5]['Flavor'].must_equal "postgresql"
85
+ traces[5]['Query'].must_equal "INSERT INTO \"widgets\" (\"name\", \"description\", \"created_at\", \"updated_at\") VALUES ($1, $2, $3, $4) RETURNING \"id\""
86
+ traces[5]['Name'].must_equal "SQL"
87
+ traces[5].key?('Backtrace').must_equal true
88
+ traces[5].key?('QueryArgs').must_equal true
89
+
90
+ traces[6]['Layer'].must_equal "activerecord"
91
+ traces[6]['Label'].must_equal "exit"
92
+
93
+ # Validate the existence of the response header
94
+ r.header.key?('X-Trace').must_equal true
95
+ r.header['X-Trace'].must_equal traces[10]['X-Trace']
96
+ end
97
+
58
98
  it "should trace a request to a rails metal stack" do
59
99
 
60
100
  uri = URI.parse('http://127.0.0.1:8140/hello/metal')
@@ -1,19 +1,24 @@
1
- class Widget < ActiveRecord::Base
2
- def do_work(*args)
3
- Widget.first
4
- end
1
+ # Somehow the Padrino::Reloader v14 is detecting and loading
2
+ # this file when it shouldn't. Block it from loading for
3
+ # Padrino for now.
4
+ unless defined?(Padrino)
5
+ class Widget < ActiveRecord::Base
6
+ def do_work(*args)
7
+ Widget.first
8
+ end
5
9
 
6
- def do_error(*args)
7
- raise "FakeTestError"
10
+ def do_error(*args)
11
+ raise "FakeTestError"
12
+ end
8
13
  end
9
- end
10
14
 
11
- class CreateWidgets < ActiveRecord::Migration
12
- def change
13
- create_table :widgets do |t|
14
- t.string :name
15
- t.text :description
16
- t.timestamps
15
+ class CreateWidgets < ActiveRecord::Migration
16
+ def change
17
+ create_table :widgets do |t|
18
+ t.string :name
19
+ t.text :description
20
+ t.timestamps
21
+ end
17
22
  end
18
23
  end
19
24
  end
@@ -39,6 +39,7 @@ class Rails32MetalStack < Rails::Application
39
39
  routes.append do
40
40
  get "/hello/world" => "hello#world"
41
41
  get "/hello/metal" => "ferro#world"
42
+ get "/hello/db" => "hello#db"
42
43
  end
43
44
 
44
45
  # Enable cache classes. Production style.
@@ -72,6 +73,13 @@ class HelloController < ActionController::Base
72
73
  def world
73
74
  render :text => "Hello world!"
74
75
  end
76
+
77
+ def db
78
+ Widget.all.first
79
+ w = Widget.new(:name => 'blah', :description => 'This is an amazing widget.')
80
+ w.save
81
+ render :text => "Hello database!"
82
+ end
75
83
  end
76
84
 
77
85
  class FerroController < ActionController::Metal
@@ -40,6 +40,7 @@ class Rails40MetalStack < Rails::Application
40
40
  routes.append do
41
41
  get "/hello/world" => "hello#world"
42
42
  get "/hello/metal" => "ferro#world"
43
+ get "/hello/db" => "hello#db"
43
44
  end
44
45
 
45
46
  # Enable cache classes. Production style.
@@ -73,6 +74,13 @@ class HelloController < ActionController::Base
73
74
  def world
74
75
  render :text => "Hello world!"
75
76
  end
77
+
78
+ def db
79
+ Widget.all.first
80
+ w = Widget.new(:name => 'blah', :description => 'This is an amazing widget.')
81
+ w.save
82
+ render :text => "Hello database!"
83
+ end
76
84
  end
77
85
 
78
86
  class FerroController < ActionController::Metal
@@ -14,6 +14,7 @@ class AutoTraceTest < Minitest::Test
14
14
 
15
15
  def test_entry_layers
16
16
  TraceView.entry_layer?('delayed_job-worker').must_equal true
17
+ TraceView.entry_layer?('sidekiq-worker').must_equal true
17
18
  TraceView.entry_layer?('asdf-worker').must_equal false
18
19
  end
19
20
 
@@ -22,7 +23,7 @@ class AutoTraceTest < Minitest::Test
22
23
  TraceView.entry_layer?(:asdfworker).must_equal false
23
24
  end
24
25
 
25
- def test_trace_when_default_tm
26
+ def test_trace_when_default_tm_dj
26
27
  TraceView::Config[:tracing_mode] = :through
27
28
 
28
29
  TV::API.start_trace('delayed_job-worker') do
@@ -30,11 +31,23 @@ class AutoTraceTest < Minitest::Test
30
31
  end
31
32
  end
32
33
 
34
+ def test_trace_when_default_tm_sidekiq
35
+ TraceView::Config[:tracing_mode] = :through
36
+
37
+ TV::API.start_trace('sidekiq-worker') do
38
+ TraceView.tracing?.must_equal true
39
+ end
40
+ end
41
+
33
42
  def test_dont_trace_when_never
34
43
  TraceView::Config[:tracing_mode] = :never
35
44
 
36
45
  TV::API.start_trace('delayed_job-worker') do
37
46
  TraceView.tracing?.must_equal false
38
47
  end
48
+
49
+ TV::API.start_trace('asdf') do
50
+ TraceView.tracing?.must_equal false
51
+ end
39
52
  end
40
53
  end
@@ -0,0 +1,76 @@
1
+ # Copyright (c) 2015 AppNeta, Inc.
2
+ # All rights reserved.
3
+
4
+ require 'minitest_helper'
5
+ require 'rack/test'
6
+ require 'rack/lobster'
7
+ require 'traceview/inst/rack'
8
+
9
+ class AVWTraceTest < Minitest::Test
10
+ include Rack::Test::Methods
11
+
12
+ def app
13
+ @app = Rack::Builder.new {
14
+ use Rack::CommonLogger
15
+ use Rack::ShowExceptions
16
+ use TraceView::Rack
17
+ map "/lobster" do
18
+ use Rack::Lint
19
+ run Rack::Lobster.new
20
+ end
21
+ }
22
+ end
23
+
24
+ def setup
25
+ clear_all_traces
26
+ @tm = TraceView::Config[:tracing_mode]
27
+ end
28
+
29
+ def teardown
30
+ TraceView::Config[:tracing_mode] = @tm
31
+ end
32
+
33
+ def test_avw_collection_with_through
34
+ # Skip under JRuby/Joboe for now. Due to Java instrumentation
35
+ # variation that is being investigated in TVI-2348
36
+ skip if defined?(JRUBY_VERSION)
37
+
38
+ TV::Config[:tracing_mode] = :through
39
+ header('X-TV-Meta', 'abcdefghijklmnopqrstuvwxyz')
40
+
41
+ get "/lobster"
42
+
43
+ traces = get_all_traces
44
+
45
+ traces.count.must_equal 3
46
+ traces[0]['TraceOrigin'].must_equal "avw_sampled"
47
+ validate_outer_layers(traces, 'rack')
48
+ end
49
+
50
+ def test_avw_collection_with_always
51
+ # Skip under JRuby/Joboe for now. Due to Java instrumentation
52
+ # variation that is being investigated in TVI-2348
53
+ skip if defined?(JRUBY_VERSION)
54
+
55
+ TV::Config[:tracing_mode] = :always
56
+ header('X-TV-Meta', 'abcdefghijklmnopqrstuvwxyz')
57
+
58
+ get "/lobster"
59
+
60
+ traces = get_all_traces
61
+
62
+ traces.count.must_equal 3
63
+ traces[0]['TraceOrigin'].must_equal "always_sampled"
64
+ validate_outer_layers(traces, 'rack')
65
+ end
66
+
67
+ def test_avw_collection_with_never
68
+ TV::Config[:tracing_mode] = :never
69
+ header('X-TV-Meta', 'abcdefghijklmnopqrstuvwxyz')
70
+
71
+ get "/lobster"
72
+
73
+ traces = get_all_traces
74
+ traces.count.must_equal 0
75
+ end
76
+ end
data/traceview.gemspec CHANGED
@@ -23,7 +23,22 @@ Gem::Specification.new do |s|
23
23
 
24
24
  s.add_runtime_dependency('json', '>= 0')
25
25
  s.add_runtime_dependency('bson', '< 4.0')
26
- s.add_development_dependency('rake', '>= 0')
26
+
27
+ # Development dependencies used in gem development & testing
28
+ s.add_development_dependency('rake', '>= 0.9.0')
29
+
30
+ case RUBY_VERSION
31
+ when /^1\.8/
32
+ s.add_development_dependency('ruby-debug', '>= 0.10.1')
33
+ s.add_development_dependency('pry', '>= 0.9.12.4')
34
+ when /^1\.9/
35
+ s.add_development_dependency('debugger', '>= 1.6.7')
36
+ s.add_development_dependency('pry', '>= 0.10.0')
37
+ when /^2\./
38
+ s.add_development_dependency('byebug', '>= 8.0.0')
39
+ s.add_development_dependency('pry', '>= 0.10.0')
40
+ s.add_development_dependency('pry-byebug', '>= 3.0.0')
41
+ end
27
42
 
28
43
  s.required_ruby_version = '>= 1.8.6'
29
44
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: traceview
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.4.0
4
+ version: 3.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Peter Giacomo Lombardo
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-12-29 00:00:00.000000000 Z
12
+ date: 2016-01-05 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: json
@@ -45,14 +45,56 @@ dependencies:
45
45
  requirements:
46
46
  - - ">="
47
47
  - !ruby/object:Gem::Version
48
- version: '0'
48
+ version: 0.9.0
49
49
  type: :development
50
50
  prerelease: false
51
51
  version_requirements: !ruby/object:Gem::Requirement
52
52
  requirements:
53
53
  - - ">="
54
54
  - !ruby/object:Gem::Version
55
- version: '0'
55
+ version: 0.9.0
56
+ - !ruby/object:Gem::Dependency
57
+ name: byebug
58
+ requirement: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - ">="
61
+ - !ruby/object:Gem::Version
62
+ version: 8.0.0
63
+ type: :development
64
+ prerelease: false
65
+ version_requirements: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - ">="
68
+ - !ruby/object:Gem::Version
69
+ version: 8.0.0
70
+ - !ruby/object:Gem::Dependency
71
+ name: pry
72
+ requirement: !ruby/object:Gem::Requirement
73
+ requirements:
74
+ - - ">="
75
+ - !ruby/object:Gem::Version
76
+ version: 0.10.0
77
+ type: :development
78
+ prerelease: false
79
+ version_requirements: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - ">="
82
+ - !ruby/object:Gem::Version
83
+ version: 0.10.0
84
+ - !ruby/object:Gem::Dependency
85
+ name: pry-byebug
86
+ requirement: !ruby/object:Gem::Requirement
87
+ requirements:
88
+ - - ">="
89
+ - !ruby/object:Gem::Version
90
+ version: 3.0.0
91
+ type: :development
92
+ prerelease: false
93
+ version_requirements: !ruby/object:Gem::Requirement
94
+ requirements:
95
+ - - ">="
96
+ - !ruby/object:Gem::Version
97
+ version: 3.0.0
56
98
  description: The TraceView gem provides performance instrumentation for MRI Ruby,
57
99
  JRuby and related frameworks.
58
100
  email: traceviewsupport@appneta.com
@@ -229,7 +271,8 @@ files:
229
271
  - test/servers/sidekiq.rb
230
272
  - test/servers/sidekiq.yml
231
273
  - test/servers/sidekiq_initializer.rb
232
- - test/support/auto_tracing.rb
274
+ - test/support/auto_tracing_test.rb
275
+ - test/support/avw_handling_test.rb
233
276
  - test/support/backcompat_test.rb
234
277
  - test/support/config_test.rb
235
278
  - test/support/dnt_test.rb
@@ -259,7 +302,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
259
302
  version: '0'
260
303
  requirements: []
261
304
  rubyforge_project:
262
- rubygems_version: 2.4.5.1
305
+ rubygems_version: 2.5.1
263
306
  signing_key:
264
307
  specification_version: 4
265
308
  summary: AppNeta TraceView performance instrumentation gem for Ruby
@@ -315,13 +358,14 @@ test_files:
315
358
  - test/queues/delayed_job-client_test.rb
316
359
  - test/support/config_test.rb
317
360
  - test/support/noop_test.rb
318
- - test/support/auto_tracing.rb
319
361
  - test/support/dnt_test.rb
320
362
  - test/support/sql_sanitize_test.rb
363
+ - test/support/avw_handling_test.rb
321
364
  - test/support/tvalias_test.rb
322
365
  - test/support/liboboe_settings_test.rb
323
366
  - test/support/backcompat_test.rb
324
367
  - test/support/xtrace_test.rb
368
+ - test/support/auto_tracing_test.rb
325
369
  - test/minitest_helper.rb
326
370
  - test/jobs/sidekiq/remote_call_worker_job.rb
327
371
  - test/jobs/sidekiq/error_worker_job.rb