traceview 3.0.3-java → 3.0.4-java

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: 43b520d89cefd876fc9a2f8b313545ef95080ab2
4
- data.tar.gz: 3ae2c83c67989a07a31ce5f5beb459363fa5ed98
3
+ metadata.gz: 5d7b1e15c3cb6b5b4ef34bd1b5861f4a771e4d8f
4
+ data.tar.gz: 65fdda8e86ddf934c454eb518274f20c0541eb45
5
5
  SHA512:
6
- metadata.gz: 4e14dd246f3df28b8878effde4fab9e7df22329d252cc49271c06171ec71c67715db47a542301617396ba6bebc7c282106d1428e41f9967c5a9ef1eb265a6165
7
- data.tar.gz: 9f149841a799d04c72cd12c65d87c608057f383932a0c47f46779e42254bfc25b217eb4cc6dc04c2e4d3df2b31d66429fdf7b4b0b18976dfcc85a3d6d424f036
6
+ metadata.gz: 355c101e8ae6f25c1d23bdd405f1ab983daa57a091eaa3193e37677047dce5fbd15e1e442bffd23e4966fba211318b8cd0daa05359bdba84dcd161945007db13
7
+ data.tar.gz: d36d61c09d859c317362772510d8a6a0e2fb9d22164f58d7cdd5615c5423367a669c3a37209b1e312bb7e8b02a4aef6d74798e0207bb34e069612ac1a364a136
data/.gitignore CHANGED
@@ -9,3 +9,4 @@ ext/oboe_metal/Makefile
9
9
  ext/oboe_metal/mkmf.log
10
10
  ext/oboe_metal/oboe_metal.so
11
11
  ext/oboe_metal/oboe_wrap.o
12
+ log/
data/CHANGELOG.md CHANGED
@@ -4,6 +4,31 @@ 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.0.4
8
+
9
+ This patch release includes the following fixes:
10
+
11
+ * Rails generator broken after gem rename: #128
12
+ * Allow custom params for logging exceptions: #130 (thanks @sliuu !)
13
+ * SQL Sanitize missing integers for ActiveRecord adapters: #131
14
+
15
+ Pushed to Rubygems:
16
+
17
+ https://rubygems.org/gems/traceview/versions/3.0.4
18
+ https://rubygems.org/gems/traceview/versions/3.0.4-java
19
+
20
+ # traceview 3.0.3
21
+
22
+ This patch release includes the following fixes:
23
+
24
+ * Fix missing Controller/Action reporting for Rails 4 and add Rails test coverage: #123
25
+ * Fix Moped update default parameter: #127 (thanks to @maxjacobson, @lifegiver, @abmcdubb and @mradmacher!)
26
+
27
+ Pushed to Rubygems:
28
+
29
+ https://rubygems.org/gems/traceview/versions/3.0.3
30
+ https://rubygems.org/gems/traceview/versions/3.0.3-java
31
+
7
32
  # traceview 3.0.2
8
33
 
9
34
  This patch release includes the following fixes:
data/Gemfile CHANGED
@@ -3,7 +3,7 @@ source 'https://rubygems.org'
3
3
  group :development, :test do
4
4
  gem 'rake'
5
5
  gem 'minitest'
6
- gem 'minitest-reporters'
6
+ gem 'minitest-reporters', '< 1.0.18'
7
7
  gem 'minitest-debugger', :require => false
8
8
  gem 'rack-test'
9
9
  gem 'puma'
@@ -3,7 +3,7 @@ source "https://rubygems.org"
3
3
  group :development, :test do
4
4
  gem 'rake'
5
5
  gem 'minitest'
6
- gem 'minitest-reporters'
6
+ gem 'minitest-reporters', '< 1.0.18'
7
7
  gem 'minitest-debugger', :require => false
8
8
  gem 'rack-test'
9
9
  gem 'puma'
@@ -13,7 +13,7 @@ end
13
13
  group :development, :test do
14
14
  gem 'rake'
15
15
  gem 'minitest'
16
- gem 'minitest-reporters'
16
+ gem 'minitest-reporters', '< 1.0.18'
17
17
  gem 'minitest-debugger', :require => false
18
18
  gem 'rack-test'
19
19
  gem 'puma'
@@ -11,7 +11,7 @@ end
11
11
  group :development, :test do
12
12
  gem 'rake'
13
13
  gem 'minitest'
14
- gem 'minitest-reporters'
14
+ gem 'minitest-reporters', '< 1.0.18'
15
15
  gem 'minitest-debugger', :require => false
16
16
  gem 'rack-test'
17
17
  gem 'puma'
@@ -11,7 +11,7 @@ end
11
11
  group :development, :test do
12
12
  gem 'rake'
13
13
  gem 'minitest'
14
- gem 'minitest-reporters'
14
+ gem 'minitest-reporters', '< 1.0.18'
15
15
  gem 'minitest-debugger', :require => false
16
16
  gem 'rack-test'
17
17
  gem 'puma'
@@ -11,7 +11,7 @@ end
11
11
  group :development, :test do
12
12
  gem 'rake'
13
13
  gem 'minitest'
14
- gem 'minitest-reporters'
14
+ gem 'minitest-reporters', '< 1.0.18'
15
15
  gem 'minitest-debugger', :require => false
16
16
  gem 'rack-test'
17
17
  gem 'puma'
@@ -11,7 +11,7 @@ end
11
11
  group :development, :test do
12
12
  gem 'rake'
13
13
  gem 'minitest'
14
- gem 'minitest-reporters'
14
+ gem 'minitest-reporters', '< 1.0.18'
15
15
  gem 'minitest-debugger', :require => false
16
16
  gem 'rack-test'
17
17
  gem 'puma'
@@ -3,7 +3,7 @@ source "https://rubygems.org"
3
3
  group :development, :test do
4
4
  gem 'rake'
5
5
  gem 'minitest'
6
- gem 'minitest-reporters'
6
+ gem 'minitest-reporters', '< 1.0.18'
7
7
  gem 'minitest-debugger', :require => false
8
8
  gem 'rack-test'
9
9
  gem 'puma'
@@ -3,7 +3,7 @@ source "https://rubygems.org"
3
3
  group :development, :test do
4
4
  gem 'rake'
5
5
  gem 'minitest'
6
- gem 'minitest-reporters'
6
+ gem 'minitest-reporters', '< 1.0.18'
7
7
  gem 'minitest-debugger', :require => false
8
8
  gem 'rack-test'
9
9
  gem 'puma'
@@ -3,7 +3,7 @@ source "https://rubygems.org"
3
3
  group :development, :test do
4
4
  gem 'rake'
5
5
  gem 'minitest'
6
- gem 'minitest-reporters'
6
+ gem 'minitest-reporters', '< 1.0.18'
7
7
  gem 'minitest-debugger', :require => false
8
8
  gem 'rack-test'
9
9
  gem 'puma'
@@ -6,6 +6,8 @@ module TraceView
6
6
  source_root File.join(File.dirname(__FILE__), 'templates')
7
7
  desc "Copies a TraceView gem initializer file to your application."
8
8
 
9
+ @namespace = "traceview:install"
10
+
9
11
  def copy_initializer
10
12
  # Set defaults
11
13
  @tracing_mode = 'through'
@@ -36,23 +36,24 @@ module TraceView
36
36
  #
37
37
  # * +layer+ - The layer the reported event belongs to
38
38
  # * +exn+ - The exception to report
39
+ # * +kvs+ - Custom params if you want to log extra information
39
40
  #
40
41
  # ==== Example
41
42
  #
42
43
  # begin
43
44
  # my_iffy_method
44
45
  # rescue Exception => e
45
- # TraceView::API.log_exception('rails', e)
46
+ # TraceView::API.log_exception('rails', e, { user: user_id })
46
47
  # raise
47
48
  # end
48
49
  #
49
50
  # Returns nothing.
50
- def log_exception(layer, exn)
51
+ def log_exception(layer, exn, kvs = {})
51
52
  return if !TraceView.loaded || exn.instance_variable_get(:@oboe_logged)
52
53
 
53
- kvs = { :ErrorClass => exn.class.name,
54
- :ErrorMsg => exn.message,
55
- :Backtrace => exn.backtrace.join("\r\n") }
54
+ kvs.merge!(:ErrorClass => exn.class.name,
55
+ :ErrorMsg => exn.message,
56
+ :Backtrace => exn.backtrace.join("\r\n"))
56
57
 
57
58
  exn.instance_variable_set(:@oboe_logged, true)
58
59
  log(layer, 'error', kvs)
@@ -70,7 +71,7 @@ module TraceView
70
71
  #
71
72
  # ==== Example
72
73
  #
73
- # Oboe::API.log_start(:layer_name, nil, { :id => @user.id })
74
+ # TraceView::API.log_start(:layer_name, nil, { :id => @user.id })
74
75
  #
75
76
  def log_start(layer, xtrace = nil, opts = {})
76
77
  return if !TraceView.loaded || TraceView.never? ||
@@ -120,7 +121,7 @@ module TraceView
120
121
  #
121
122
  # ==== Example
122
123
  #
123
- # Oboe::API.log_end(:layer_name, { :id => @user.id })
124
+ # TraceView::API.log_end(:layer_name, { :id => @user.id })
124
125
  #
125
126
  # Returns an xtrace metadata string
126
127
  def log_end(layer, opts = {})
@@ -145,7 +146,7 @@ module TraceView
145
146
  #
146
147
  # ==== Example
147
148
  #
148
- # Oboe::API.log_entry(:layer_name, { :id => @user.id })
149
+ # TraceView::API.log_entry(:layer_name, { :id => @user.id })
149
150
  #
150
151
  # Returns an xtrace metadata string
151
152
  def log_entry(layer, kvs = {}, op = nil)
@@ -167,7 +168,7 @@ module TraceView
167
168
  #
168
169
  # ==== Example
169
170
  #
170
- # Oboe::API.log_info(:layer_name, { :id => @user.id })
171
+ # TraceView::API.log_info(:layer_name, { :id => @user.id })
171
172
  #
172
173
  # Returns an xtrace metadata string
173
174
  def log_info(layer, kvs = {})
@@ -189,7 +190,7 @@ module TraceView
189
190
  #
190
191
  # ==== Example
191
192
  #
192
- # Oboe::API.log_exit(:layer_name, { :id => @user.id })
193
+ # TraceView::API.log_exit(:layer_name, { :id => @user.id })
193
194
  #
194
195
  # Returns an xtrace metadata string
195
196
  def log_exit(layer, kvs = {}, op = nil)
@@ -212,11 +213,11 @@ module TraceView
212
213
  # ==== Example
213
214
  #
214
215
  # entry = TraceView::Context.createEvent
215
- # Oboe::API.log_event(:layer_name, 'entry', entry_event, { :id => @user.id })
216
+ # TraceView::API.log_event(:layer_name, 'entry', entry_event, { :id => @user.id })
216
217
  #
217
218
  # exit_event = TraceView::Context.createEvent
218
219
  # exit_event.addEdge(entry.getMetadata)
219
- # Oboe::API.log_event(:layer_name, 'exit', exit_event, { :id => @user.id })
220
+ # TraceView::API.log_event(:layer_name, 'exit', exit_event, { :id => @user.id })
220
221
  #
221
222
  def log_event(layer, label, event, opts = {})
222
223
  if TraceView.loaded
data/lib/traceview/api.rb CHANGED
@@ -5,7 +5,7 @@ module TraceView
5
5
  ##
6
6
  # This module implements the TraceView tracing API.
7
7
  # See: https://github.com/appneta/oboe-ruby#the-tracing-api
8
- # and/or: http://rdoc.info/gems/oboe/Oboe/API/Tracing
8
+ # and/or: http://rdoc.info/gems/traceview/TraceView/API/Tracing
9
9
  module API
10
10
  def self.extend_with_tracing
11
11
  extend TraceView::API::Logging
@@ -108,6 +108,10 @@ module TraceView
108
108
  # avoid collecting and reporting query literals to TraceView.
109
109
  @@config[:sanitize_sql] = false
110
110
 
111
+ # The regular expression used to sanitize SQL.
112
+ @@config[:sanitize_sql_regexp] = '(\'[\s\S][^\']*\'|\d*\.\d+|\d+|NULL)'
113
+ @@config[:sanitize_sql_opts] = Regexp::IGNORECASE
114
+
111
115
  # Do Not Trace
112
116
  # These two values allow you to configure specific URL patterns to
113
117
  # never be traced. By default, this is set to common static file
@@ -12,7 +12,7 @@ module TraceView
12
12
  begin
13
13
  if TraceView::Config[:sanitize_sql]
14
14
  # Sanitize SQL and don't report binds
15
- opts[:Query] = sql.gsub(/\'[\s\S][^\']*\'/, '?')
15
+ opts[:Query] = TraceView::Util.sanitize_sql(sql)
16
16
  else
17
17
  # Report raw SQL and any binds if they exist
18
18
  opts[:Query] = sql.to_s
@@ -12,7 +12,7 @@ module TraceView
12
12
  if sql.is_a?(Symbol)
13
13
  kvs[:Query] = sql
14
14
  else
15
- kvs[:Query] = sql.gsub(/('[\s\S][^\']*\'|\d*\.\d*)/, '?')
15
+ kvs[:Query] = TraceView::Util.sanitize_sql(sql)
16
16
  end
17
17
  else
18
18
  # Report raw SQL and any binds if they exist
@@ -153,12 +153,30 @@ module TraceView
153
153
  return result.sort.join('&')
154
154
  end
155
155
 
156
+ ##
157
+ # sanitize_sql
158
+ #
159
+ # Used to remove query literals from SQL. Used by all
160
+ # DB adapter instrumentation.
161
+ #
162
+ # The regular expression passed to String.gsub is configurable
163
+ # via TraceView::Config[:sanitize_sql_regexp] and
164
+ # TraceView::Config[:sanitize_sql_opts].
165
+ #
166
+ def sanitize_sql(sql)
167
+ return sql unless TraceView::Config[:sanitize_sql]
168
+
169
+ regexp = Regexp.new(TraceView::Config[:sanitize_sql_regexp], TraceView::Config[:sanitize_sql_opts])
170
+ sql.gsub(regexp, '?')
171
+ end
172
+
156
173
  ##
157
174
  # build_init_report
158
175
  #
159
176
  # Internal: Build a hash of KVs that reports on the status of the
160
177
  # running environment. This is used on stack boot in __Init reporting
161
178
  # and for TraceView.support_report.
179
+ #
162
180
  def build_init_report
163
181
  platform_info = { '__Init' => 1 }
164
182
 
@@ -8,7 +8,7 @@ module TraceView
8
8
  module Version
9
9
  MAJOR = 3
10
10
  MINOR = 0
11
- PATCH = 3
11
+ PATCH = 4
12
12
  BUILD = nil
13
13
 
14
14
  STRING = [MAJOR, MINOR, PATCH, BUILD].compact.join('.')
@@ -0,0 +1,55 @@
1
+ # Copyright (c) 2015 AppNeta, Inc.
2
+ # All rights reserved.
3
+
4
+ require 'minitest_helper'
5
+
6
+ class SQLSanitizeTest < Minitest::Test
7
+ def test_sanitize_sql1
8
+ TraceView::Config[:sanitize_sql] = true
9
+
10
+ sql = "INSERT INTO `queries` (`asdf_id`, `asdf_prices`, `created_at`, `updated_at`, `blue_pill`, `yearly_tax`, `rate`, `steam_id`, `red_pill`, `dimitri`, `origin`) VALUES (19231, 3, 'cat', 'dog', 111.0, 126.0, 116.0, 79.0, 72.0, 73.0, ?, 1, 3, 229.284, ?, ?, 100, ?, 0, 3, 1, ?, NULL, NULL, ?, 4, ?)"
11
+ result = TraceView::Util.sanitize_sql(sql)
12
+ result.must_equal "INSERT INTO `queries` (`asdf_id`, `asdf_prices`, `created_at`, `updated_at`, `blue_pill`, `yearly_tax`, `rate`, `steam_id`, `red_pill`, `dimitri`, `origin`) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"
13
+
14
+ TraceView::Config[:sanitize_sql] = false
15
+ end
16
+
17
+ def test_sanitize_sql2
18
+ TraceView::Config[:sanitize_sql] = true
19
+
20
+ sql = "SELECT \"game_types\".* FROM \"game_types\" WHERE \"game_types\".\"game_id\" IN (1162)"
21
+ result = TraceView::Util.sanitize_sql(sql)
22
+ result.must_equal "SELECT \"game_types\".* FROM \"game_types\" WHERE \"game_types\".\"game_id\" IN (?)"
23
+
24
+ TraceView::Config[:sanitize_sql] = false
25
+ end
26
+
27
+ def test_sanitize_sql3
28
+ TraceView::Config[:sanitize_sql] = true
29
+
30
+ sql = "SELECT \"comments\".* FROM \"comments\" WHERE \"comments\".\"commentable_id\" = 2798 AND \"comments\".\"commentable_type\" = 'Video' AND \"comments\".\"parent_id\" IS NULL ORDER BY comments.created_at DESC"
31
+ result = TraceView::Util.sanitize_sql(sql)
32
+ result.must_equal "SELECT \"comments\".* FROM \"comments\" WHERE \"comments\".\"commentable_id\" = ? AND \"comments\".\"commentable_type\" = ? AND \"comments\".\"parent_id\" IS ? ORDER BY comments.created_at DESC"
33
+
34
+ TraceView::Config[:sanitize_sql] = false
35
+ end
36
+
37
+ def test_sanitize_sql4
38
+ TraceView::Config[:sanitize_sql] = true
39
+
40
+ sql = "SELECT `assets`.* FROM `assets` WHERE `assets`.`type` IN ('Picture') AND (updated_at >= '2015-07-08 19:22:00') AND (updated_at <= '2015-07-08 19:23:00') LIMIT 31 OFFSET 0"
41
+ result = TraceView::Util.sanitize_sql(sql)
42
+ result.must_equal "SELECT `assets`.* FROM `assets` WHERE `assets`.`type` IN (?) AND (updated_at >= ?) AND (updated_at <= ?) LIMIT ? OFFSET ?"
43
+
44
+ TraceView::Config[:sanitize_sql] = false
45
+ end
46
+
47
+ def test_dont_sanitize
48
+ TraceView::Config[:sanitize_sql] = false
49
+
50
+ sql = "SELECT `assets`.* FROM `assets` WHERE `assets`.`type` IN ('Picture') AND (updated_at >= '2015-07-08 19:22:00') AND (updated_at <= '2015-07-08 19:23:00') LIMIT 31 OFFSET 0"
51
+ result = TraceView::Util.sanitize_sql(sql)
52
+ result.must_equal "SELECT `assets`.* FROM `assets` WHERE `assets`.`type` IN ('Picture') AND (updated_at >= '2015-07-08 19:22:00') AND (updated_at <= '2015-07-08 19:23:00') LIMIT 31 OFFSET 0"
53
+ end
54
+ end
55
+
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.0.3
4
+ version: 3.0.4
5
5
  platform: java
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-06-26 00:00:00.000000000 Z
12
+ date: 2015-07-08 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: json
@@ -152,7 +152,6 @@ files:
152
152
  - test/frameworks/apps/sinatra_simple.rb
153
153
  - test/frameworks/grape_test.rb
154
154
  - test/frameworks/padrino_test.rb
155
- - test/frameworks/rails2x_test.rb
156
155
  - test/frameworks/rails3x_test.rb
157
156
  - test/frameworks/rails4x_test.rb
158
157
  - test/frameworks/sinatra_test.rb
@@ -184,13 +183,13 @@ files:
184
183
  - test/minitest_helper.rb
185
184
  - test/profiling/method_test.rb
186
185
  - test/servers/rackapp_8101.rb
187
- - test/servers/rails2x_8140.rb
188
186
  - test/servers/rails3x_8140.rb
189
187
  - test/servers/rails4x_8140.rb
190
188
  - test/support/backcompat_test.rb
191
189
  - test/support/config_test.rb
192
190
  - test/support/dnt_test.rb
193
191
  - test/support/liboboe_settings_test.rb
192
+ - test/support/sql_sanitize_test.rb
194
193
  - test/support/tvalias_test.rb
195
194
  - test/support/xtrace_test.rb
196
195
  - traceview.gemspec
@@ -222,7 +221,6 @@ test_files:
222
221
  - test/minitest_helper.rb
223
222
  - test/servers/rails4x_8140.rb
224
223
  - test/servers/rails3x_8140.rb
225
- - test/servers/rails2x_8140.rb
226
224
  - test/servers/rackapp_8101.rb
227
225
  - test/instrumentation/excon_test.rb
228
226
  - test/instrumentation/sequel_pg_test.rb
@@ -254,7 +252,6 @@ test_files:
254
252
  - test/frameworks/grape_test.rb
255
253
  - test/frameworks/rails3x_test.rb
256
254
  - test/frameworks/padrino_test.rb
257
- - test/frameworks/rails2x_test.rb
258
255
  - test/frameworks/rails4x_test.rb
259
256
  - test/frameworks/apps/grape_simple.rb
260
257
  - test/frameworks/apps/sinatra_simple.rb
@@ -262,6 +259,7 @@ test_files:
262
259
  - test/frameworks/apps/grape_nested.rb
263
260
  - test/support/config_test.rb
264
261
  - test/support/dnt_test.rb
262
+ - test/support/sql_sanitize_test.rb
265
263
  - test/support/tvalias_test.rb
266
264
  - test/support/liboboe_settings_test.rb
267
265
  - test/support/backcompat_test.rb
@@ -1,91 +0,0 @@
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
@@ -1,171 +0,0 @@
1
- # Copyright (c) 2015 AppNeta, Inc.
2
- # All rights reserved.
3
-
4
- RAILS_ROOT = "#{File.dirname(__FILE__)}/.." unless defined?(RAILS_ROOT)
5
-
6
- require 'actionpack'
7
- require 'actionpack'
8
-
9
- module Rails
10
- class << self
11
- def boot!
12
- unless booted?
13
- preinitialize
14
- pick_boot.run
15
- end
16
- end
17
-
18
- def booted?
19
- defined? Rails::Initializer
20
- end
21
-
22
- def pick_boot
23
- (vendor_rails? ? VendorBoot : GemBoot).new
24
- end
25
-
26
- def vendor_rails?
27
- File.exist?("#{RAILS_ROOT}/vendor/rails")
28
- end
29
-
30
- def preinitialize
31
- load(preinitializer_path) if File.exist?(preinitializer_path)
32
- end
33
-
34
- def preinitializer_path
35
- "#{RAILS_ROOT}/config/preinitializer.rb"
36
- end
37
- end
38
-
39
- class Boot
40
- def run
41
- load_initializer
42
- Rails::Initializer.run(:set_load_path)
43
- end
44
- end
45
-
46
- class VendorBoot < Boot
47
- def load_initializer
48
- require "#{RAILS_ROOT}/vendor/rails/railties/lib/initializer"
49
- Rails::Initializer.run(:install_gem_spec_stubs)
50
- Rails::GemDependency.add_frozen_gem_path
51
- end
52
- end
53
-
54
- class GemBoot < Boot
55
- def load_initializer
56
- self.class.load_rubygems
57
- load_rails_gem
58
- require 'initializer'
59
- end
60
-
61
- def load_rails_gem
62
- if version = self.class.gem_version
63
- gem 'rails', version
64
- else
65
- gem 'rails'
66
- end
67
- rescue Gem::LoadError => load_error
68
- if load_error.message =~ /Could not find RubyGem rails/
69
- STDERR.puts %(Missing the Rails #{version} gem. Please `gem install -v=#{version} rails`, update your RAILS_GEM_VERSION setting in config/environment.rb for the Rails version you do have installed, or comment out RAILS_GEM_VERSION to use the latest version installed.)
70
- exit 1
71
- else
72
- raise
73
- end
74
- end
75
-
76
- class << self
77
- def rubygems_version
78
- Gem::RubyGemsVersion rescue nil
79
- end
80
-
81
- def gem_version
82
- if defined? RAILS_GEM_VERSION
83
- RAILS_GEM_VERSION
84
- elsif ENV.include?('RAILS_GEM_VERSION')
85
- ENV['RAILS_GEM_VERSION']
86
- else
87
- parse_gem_version(read_environment_rb)
88
- end
89
- end
90
-
91
- def load_rubygems
92
- min_version = '1.3.2'
93
- require 'rubygems'
94
- unless rubygems_version >= min_version
95
- $stderr.puts %Q(Rails requires RubyGems >= #{min_version} (you have #{rubygems_version}). Please `gem update --system` and try again.)
96
- exit 1
97
- end
98
-
99
- rescue LoadError
100
- $stderr.puts %Q(Rails requires RubyGems >= #{min_version}. Please install RubyGems and try again: http://rubygems.rubyforge.org)
101
- exit 1
102
- end
103
-
104
- def parse_gem_version(text)
105
- $1 if text =~ /^[^#]*RAILS_GEM_VERSION\s*=\s*["']([!~<>=]*\s*[\d.]+)["']/
106
- end
107
-
108
- private
109
- def read_environment_rb
110
- File.read("#{RAILS_ROOT}/config/environment.rb")
111
- end
112
- end
113
- end
114
- end
115
-
116
- class Rails::Boot
117
- def run
118
- load_initializer
119
-
120
- Rails::Initializer.class_eval do
121
- def load_gems
122
- @bundler_loaded ||= Bundler.require :default, Rails.env
123
- Oboe::Config[:verbose] = true
124
- end
125
- end
126
-
127
- Rails::Initializer.run(:set_load_path)
128
- end
129
- end
130
-
131
- TraceView.logger.info "[traceview/info] Starting background utility rails app on localhost:8140."
132
-
133
- ActionController::Routing::Routes.draw do |map|
134
- map.connect '/hello/metal', :controller => 'ferro', :action => 'world'
135
- map.connect ':controller/:action/:id'
136
- map.connect ':controller/:action/:id.:format'
137
- end
138
-
139
- Rails::Initializer.run do |config|
140
- config.log_level = :debug
141
- end
142
-
143
- #################################################
144
- # Controllers
145
- #################################################
146
-
147
- class HelloController < ActionController::Base
148
- def world
149
- render :text => "Hello world!"
150
- end
151
- end
152
-
153
- class FerroController < ActionController::Metal
154
- include AbstractController::Rendering
155
-
156
- def world
157
- render :text => "Hello world!"
158
- end
159
-
160
- include TraceViewMethodProfiling
161
- profile_method :world, 'world'
162
- end
163
-
164
- #Thread.new do
165
- #Rack::Handler::Puma.run(Rails23Stack.to_app, {:Host => '127.0.0.1', :Port => 8140})
166
- # All that for this:
167
- Rails.boot!
168
-
169
- #end
170
-
171
- sleep(2)