traceview 3.7.1-java → 3.8.0-java
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +11 -0
- data/Rakefile +8 -1
- data/gemfiles/libraries.gemfile +2 -2
- data/lib/traceview/config.rb +3 -2
- data/lib/traceview/frameworks/rails/inst/action_controller.rb +10 -1
- data/lib/traceview/frameworks/rails/inst/action_controller5_api.rb +39 -0
- data/lib/traceview/version.rb +2 -2
- data/test/frameworks/rails5x_api_test.rb +103 -0
- data/test/minitest_helper.rb +1 -0
- data/test/servers/rails5x_api_8150.rb +109 -0
- data/test/support/config_test.rb +3 -1
- metadata +7 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f4d03a81db14cf1d1d87072595b17b276f4a75ca
|
4
|
+
data.tar.gz: 0a39d1f719757bcbaa69d682149b74554617f1d6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2eb44522175d7525e733e3d65dc08b2fbb0f09a87b321fbc09c093c2fb4ed851b0832709d7d70040747ed3b8207cf8c2f8d4f5ec08dd88f7edd19ca49c6f6226
|
7
|
+
data.tar.gz: b2f4b76f5be26a0c63799dc7db46a98406b0276fa0f20bee867f5e3787275cd8cf98e7d9779fbd344cb4beb9990c88450c6358ec8fbfe8e91b675ab332596151
|
data/CHANGELOG.md
CHANGED
@@ -4,6 +4,17 @@ 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.8.0
|
8
|
+
|
9
|
+
This minor release includes the following new feature:
|
10
|
+
|
11
|
+
* New instrumentation for Rails API based controllers: #166
|
12
|
+
|
13
|
+
Pushed to Rubygems:
|
14
|
+
|
15
|
+
https://rubygems.org/gems/traceview/versions/3.8.0
|
16
|
+
https://rubygems.org/gems/traceview/versions/3.8.0-java
|
17
|
+
|
7
18
|
# traceview 3.7.1
|
8
19
|
|
9
20
|
This patch release includes the following fixes:
|
data/Rakefile
CHANGED
@@ -25,7 +25,14 @@ Rake::TestTask.new do |t|
|
|
25
25
|
when /rails/
|
26
26
|
# Pre-load rails to get the major version number
|
27
27
|
require 'rails'
|
28
|
-
|
28
|
+
|
29
|
+
if Rails::VERSION::MAJOR == 5
|
30
|
+
t.test_files = FileList["test/frameworks/rails#{Rails::VERSION::MAJOR}x_test.rb"] +
|
31
|
+
FileList["test/frameworks/rails#{Rails::VERSION::MAJOR}x_api_test.rb"]
|
32
|
+
else
|
33
|
+
t.test_files = FileList["test/frameworks/rails#{Rails::VERSION::MAJOR}x_test.rb"]
|
34
|
+
end
|
35
|
+
|
29
36
|
when /frameworks/
|
30
37
|
t.test_files = FileList['test/frameworks/sinatra*_test.rb'] +
|
31
38
|
FileList['test/frameworks/padrino*_test.rb'] +
|
data/gemfiles/libraries.gemfile
CHANGED
@@ -21,7 +21,7 @@ group :development, :test do
|
|
21
21
|
gem 'puma', '< 3.0'
|
22
22
|
else
|
23
23
|
gem 'rake'
|
24
|
-
gem 'bson', '~>
|
24
|
+
gem 'bson', '~> 4.0'
|
25
25
|
gem 'puma', '< 3.1.0'
|
26
26
|
end
|
27
27
|
end
|
@@ -41,7 +41,7 @@ end
|
|
41
41
|
if RUBY_VERSION < '1.9.3'
|
42
42
|
gem 'mongo', '1.12.5'
|
43
43
|
else
|
44
|
-
gem 'mongo'
|
44
|
+
gem 'mongo'
|
45
45
|
end
|
46
46
|
|
47
47
|
gem 'cassandra'
|
data/lib/traceview/config.rb
CHANGED
@@ -11,8 +11,8 @@ module TraceView
|
|
11
11
|
module Config
|
12
12
|
@@config = {}
|
13
13
|
|
14
|
-
@@instrumentation = [:action_controller, :
|
15
|
-
:bunnyclient, :bunnyconsumer, :cassandra, :curb,
|
14
|
+
@@instrumentation = [:action_controller, :action_controller_api, :action_view,
|
15
|
+
:active_record, :bunnyclient, :bunnyconsumer, :cassandra, :curb,
|
16
16
|
:dalli, :delayed_jobclient, :delayed_jobworker,
|
17
17
|
:em_http_request, :excon, :faraday, :grape,
|
18
18
|
:httpclient, :nethttp, :memcached,
|
@@ -44,6 +44,7 @@ module TraceView
|
|
44
44
|
|
45
45
|
# Set collect_backtraces defaults
|
46
46
|
TraceView::Config[:action_controller][:collect_backtraces] = true
|
47
|
+
TraceView::Config[:action_controller_api][:collect_backtraces] = true
|
47
48
|
TraceView::Config[:active_record][:collect_backtraces] = true
|
48
49
|
TraceView::Config[:bunnyclient][:collect_backtraces] = false
|
49
50
|
TraceView::Config[:bunnyconsumer][:collect_backtraces] = false
|
@@ -72,9 +72,18 @@ module TraceView
|
|
72
72
|
end
|
73
73
|
end
|
74
74
|
|
75
|
+
# ActionController::Base
|
75
76
|
if defined?(ActionController::Base) && TraceView::Config[:action_controller][:enabled]
|
76
|
-
TraceView.logger.info '[traceview/loading] Instrumenting
|
77
|
+
TraceView.logger.info '[traceview/loading] Instrumenting actioncontroller' if TraceView::Config[:verbose]
|
77
78
|
require "traceview/frameworks/rails/inst/action_controller#{Rails::VERSION::MAJOR}"
|
78
79
|
::TraceView::Util.send_include(::ActionController::Base, TraceView::Inst::ActionController)
|
79
80
|
end
|
81
|
+
|
82
|
+
# ActionController::API (Rails 5+)
|
83
|
+
if defined?(ActionController::API) && TraceView::Config[:action_controller_api][:enabled]
|
84
|
+
TraceView.logger.info '[traceview/loading] Instrumenting actioncontroller api' if TraceView::Config[:verbose]
|
85
|
+
require "traceview/frameworks/rails/inst/action_controller#{Rails::VERSION::MAJOR}_api"
|
86
|
+
::TraceView::Util.send_include(::ActionController::API, TraceView::Inst::ActionControllerAPI)
|
87
|
+
end
|
88
|
+
|
80
89
|
# vim:set expandtab:tabstop=2
|
@@ -0,0 +1,39 @@
|
|
1
|
+
# Copyright (c) 2016 AppNeta, Inc.
|
2
|
+
# All rights reserved.
|
3
|
+
|
4
|
+
module TraceView
|
5
|
+
module Inst
|
6
|
+
#
|
7
|
+
# ActionController
|
8
|
+
#
|
9
|
+
# This modules contains the instrumentation code specific
|
10
|
+
# to Rails v5
|
11
|
+
#
|
12
|
+
module ActionControllerAPI
|
13
|
+
include ::TraceView::Inst::RailsBase
|
14
|
+
|
15
|
+
def self.included(base)
|
16
|
+
base.class_eval do
|
17
|
+
alias_method_chain :process_action, :traceview
|
18
|
+
alias_method_chain :render, :traceview
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def process_action_with_traceview(method_name, *args)
|
23
|
+
report_kvs = {
|
24
|
+
:Controller => self.class.name,
|
25
|
+
:Action => self.action_name,
|
26
|
+
}
|
27
|
+
|
28
|
+
TraceView::API.log_entry('rails-api', report_kvs)
|
29
|
+
process_action_without_traceview(method_name, *args)
|
30
|
+
|
31
|
+
rescue Exception => e
|
32
|
+
TraceView::API.log_exception(nil, e) if log_rails_error?(e)
|
33
|
+
raise
|
34
|
+
ensure
|
35
|
+
TraceView::API.log_exit('rails-api')
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
data/lib/traceview/version.rb
CHANGED
@@ -0,0 +1,103 @@
|
|
1
|
+
# Copyright (c) 2015 AppNeta, Inc.
|
2
|
+
# All rights reserved.
|
3
|
+
|
4
|
+
require "minitest_helper"
|
5
|
+
|
6
|
+
if defined?(::Rails)
|
7
|
+
|
8
|
+
describe "Rails5xAPI" do
|
9
|
+
before do
|
10
|
+
clear_all_traces
|
11
|
+
ENV['DBTYPE'] = "postgresql" unless ENV['DBTYPE']
|
12
|
+
end
|
13
|
+
|
14
|
+
it "should trace a request to a rails api stack" do
|
15
|
+
|
16
|
+
uri = URI.parse('http://127.0.0.1:8150/monkey/hello')
|
17
|
+
r = Net::HTTP.get_response(uri)
|
18
|
+
|
19
|
+
traces = get_all_traces
|
20
|
+
|
21
|
+
traces.count.must_equal 7
|
22
|
+
unless defined?(JRUBY_VERSION)
|
23
|
+
# We don't test this under JRuby because the Java instrumentation
|
24
|
+
# for the DB drivers doesn't use our test reporter hence we won't
|
25
|
+
# see all trace events. :-( To be improved.
|
26
|
+
valid_edges?(traces).must_equal true
|
27
|
+
end
|
28
|
+
validate_outer_layers(traces, 'rack')
|
29
|
+
|
30
|
+
traces[0]['Layer'].must_equal "rack"
|
31
|
+
traces[0]['Label'].must_equal "entry"
|
32
|
+
traces[0]['URL'].must_equal "/monkey/hello"
|
33
|
+
|
34
|
+
traces[1]['Layer'].must_equal "rack"
|
35
|
+
traces[1]['Label'].must_equal "info"
|
36
|
+
|
37
|
+
traces[2]['Layer'].must_equal "rails-api"
|
38
|
+
traces[2]['Label'].must_equal "entry"
|
39
|
+
traces[2]['Controller'].must_equal "MonkeyController"
|
40
|
+
traces[2]['Action'].must_equal "hello"
|
41
|
+
|
42
|
+
traces[3]['Layer'].must_equal "actionview"
|
43
|
+
traces[3]['Label'].must_equal "entry"
|
44
|
+
|
45
|
+
traces[4]['Layer'].must_equal "actionview"
|
46
|
+
traces[4]['Label'].must_equal "exit"
|
47
|
+
|
48
|
+
traces[5]['Layer'].must_equal "rails-api"
|
49
|
+
traces[5]['Label'].must_equal "exit"
|
50
|
+
|
51
|
+
traces[6]['Layer'].must_equal "rack"
|
52
|
+
traces[6]['Label'].must_equal "exit"
|
53
|
+
|
54
|
+
# Validate the existence of the response header
|
55
|
+
r.header.key?('X-Trace').must_equal true
|
56
|
+
r.header['X-Trace'].must_equal traces[6]['X-Trace']
|
57
|
+
end
|
58
|
+
|
59
|
+
it "should capture errors" do
|
60
|
+
uri = URI.parse('http://127.0.0.1:8150/monkey/error')
|
61
|
+
r = Net::HTTP.get_response(uri)
|
62
|
+
|
63
|
+
traces = get_all_traces
|
64
|
+
|
65
|
+
traces.count.must_equal 6
|
66
|
+
unless defined?(JRUBY_VERSION)
|
67
|
+
# We don't test this under JRuby because the Java instrumentation
|
68
|
+
# for the DB drivers doesn't use our test reporter hence we won't
|
69
|
+
# see all trace events. :-( To be improved.
|
70
|
+
valid_edges?(traces).must_equal true
|
71
|
+
end
|
72
|
+
validate_outer_layers(traces, 'rack')
|
73
|
+
|
74
|
+
traces[0]['Layer'].must_equal "rack"
|
75
|
+
traces[0]['Label'].must_equal "entry"
|
76
|
+
traces[0]['URL'].must_equal "/monkey/error"
|
77
|
+
|
78
|
+
traces[1]['Layer'].must_equal "rack"
|
79
|
+
traces[1]['Label'].must_equal "info"
|
80
|
+
|
81
|
+
traces[2]['Layer'].must_equal "rails-api"
|
82
|
+
traces[2]['Label'].must_equal "entry"
|
83
|
+
traces[2]['Controller'].must_equal "MonkeyController"
|
84
|
+
traces[2]['Action'].must_equal "error"
|
85
|
+
|
86
|
+
traces[3]['Label'].must_equal "error"
|
87
|
+
traces[3]['ErrorClass'].must_equal "RuntimeError"
|
88
|
+
traces[3]['ErrorMsg'].must_equal "Rails API fake error from controller"
|
89
|
+
traces[3].key?('Backtrace').must_equal true
|
90
|
+
|
91
|
+
traces[4]['Layer'].must_equal "rails-api"
|
92
|
+
traces[4]['Label'].must_equal "exit"
|
93
|
+
|
94
|
+
traces[5]['Layer'].must_equal "rack"
|
95
|
+
traces[5]['Label'].must_equal "exit"
|
96
|
+
|
97
|
+
# Validate the existence of the response header
|
98
|
+
r.header.key?('X-Trace').must_equal true
|
99
|
+
r.header['X-Trace'].must_equal traces[5]['X-Trace']
|
100
|
+
end
|
101
|
+
|
102
|
+
end
|
103
|
+
end
|
data/test/minitest_helper.rb
CHANGED
@@ -0,0 +1,109 @@
|
|
1
|
+
# Taken from: https://www.amberbit.com/blog/2014/2/14/putting-ruby-on-rails-on-a-diet/
|
2
|
+
# Port of https://gist.github.com/josevalim/1942658 to Rails 4
|
3
|
+
# Original author: Jose Valim
|
4
|
+
# Updated by: Peter Giacomo Lombardo
|
5
|
+
#
|
6
|
+
# Run this file with:
|
7
|
+
#
|
8
|
+
# bundle exec RAILS_ENV=production rackup -p 3000 -s thin
|
9
|
+
#
|
10
|
+
# And access:
|
11
|
+
#
|
12
|
+
# http://localhost:3000/hello/world
|
13
|
+
#
|
14
|
+
# The following lines should come as no surprise. Except by
|
15
|
+
# ActionController::Metal, it follows the same structure of
|
16
|
+
# config/application.rb, config/environment.rb and config.ru
|
17
|
+
# existing in any Rails 4 app. Here they are simply in one
|
18
|
+
# file and without the comments.
|
19
|
+
#
|
20
|
+
|
21
|
+
# Set the database. Default is postgresql.
|
22
|
+
if ENV['DBTYPE'] == 'mysql2'
|
23
|
+
TraceView::Test.set_mysql2_env
|
24
|
+
elsif ENV['DBTYPE'] == 'postgresql'
|
25
|
+
TraceView::Test.set_postgresql_env
|
26
|
+
else
|
27
|
+
TV.logger.warn "Unidentified DBTYPE: #{ENV['DBTYPE']}" unless ENV['DBTYPE'] == "postgresql"
|
28
|
+
TV.logger.debug "Defaulting to postgres DB for background Rails server."
|
29
|
+
TraceView::Test.set_postgresql_env
|
30
|
+
end
|
31
|
+
|
32
|
+
require "rails"
|
33
|
+
# Pick the frameworks you want:
|
34
|
+
require "active_model/railtie"
|
35
|
+
require "active_job/railtie"
|
36
|
+
require "active_record/railtie"
|
37
|
+
require "action_controller/railtie"
|
38
|
+
require "action_mailer/railtie"
|
39
|
+
require "action_view/railtie"
|
40
|
+
require "action_cable/engine"
|
41
|
+
# require "sprockets/railtie"
|
42
|
+
require "rails/test_unit/railtie"
|
43
|
+
|
44
|
+
require 'rack/handler/puma'
|
45
|
+
require File.expand_path(File.dirname(__FILE__) + '/../models/widget')
|
46
|
+
|
47
|
+
TraceView.logger.info "[traceview/info] Starting background utility rails app on localhost:8150."
|
48
|
+
|
49
|
+
ActiveRecord::Base.establish_connection(ENV['DATABASE_URL'])
|
50
|
+
|
51
|
+
unless ActiveRecord::Base.connection.table_exists? 'widgets'
|
52
|
+
ActiveRecord::Migration.run(CreateWidgets)
|
53
|
+
end
|
54
|
+
|
55
|
+
module Rails50APIStack
|
56
|
+
class Application < Rails::Application
|
57
|
+
config.api_only = true
|
58
|
+
|
59
|
+
routes.append do
|
60
|
+
get "/monkey/hello" => "monkey#hello"
|
61
|
+
get "/monkey/error" => "monkey#error"
|
62
|
+
end
|
63
|
+
|
64
|
+
# Enable cache classes. Production style.
|
65
|
+
config.cache_classes = true
|
66
|
+
config.eager_load = false
|
67
|
+
|
68
|
+
# uncomment below to display errors
|
69
|
+
# config.consider_all_requests_local = true
|
70
|
+
|
71
|
+
config.active_support.deprecation = :stderr
|
72
|
+
|
73
|
+
# Here you could remove some middlewares, for example
|
74
|
+
# Rack::Lock, ActionDispatch::Flash and ActionDispatch::BestStandardsSupport below.
|
75
|
+
# The remaining stack is printed on rackup (for fun!).
|
76
|
+
# Rails API has config.middleware.api_only! to get
|
77
|
+
# rid of browser related middleware.
|
78
|
+
config.middleware.delete Rack::Lock
|
79
|
+
config.middleware.delete ActionDispatch::Flash
|
80
|
+
|
81
|
+
# We need a secret token for session, cookies, etc.
|
82
|
+
config.secret_token = "48837489qkuweoiuoqwehisuakshdjksadhaisdy78o34y138974xyqp9rmye8yrpiokeuioqwzyoiuxftoyqiuxrhm3iou1hrzmjk"
|
83
|
+
config.secret_key_base = "2049671-96803948"
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
#################################################
|
88
|
+
# Controllers
|
89
|
+
#################################################
|
90
|
+
|
91
|
+
class MonkeyController < ActionController::API
|
92
|
+
def hello
|
93
|
+
#render :json => { :Response => "Hello API!"}.to_json
|
94
|
+
# Work around for Rails beta issue with rendering json
|
95
|
+
render :plain => { :Response => "Hello API!"}.to_json, content_type: 'application/json'
|
96
|
+
end
|
97
|
+
|
98
|
+
def error
|
99
|
+
raise "Rails API fake error from controller"
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
Rails50APIStack::Application.initialize!
|
104
|
+
|
105
|
+
Thread.new do
|
106
|
+
Rack::Handler::Puma.run(Rails50APIStack::Application.to_app, {:Host => '127.0.0.1', :Port => 8150})
|
107
|
+
end
|
108
|
+
|
109
|
+
sleep(2)
|
data/test/support/config_test.rb
CHANGED
@@ -30,9 +30,10 @@ describe "TraceView::Config" do
|
|
30
30
|
instrumentation = TraceView::Config.instrumentation
|
31
31
|
|
32
32
|
# Verify the number of individual instrumentations
|
33
|
-
instrumentation.count.must_equal
|
33
|
+
instrumentation.count.must_equal 30
|
34
34
|
|
35
35
|
TraceView::Config[:action_controller][:enabled].must_equal true
|
36
|
+
TraceView::Config[:action_controller_api][:enabled].must_equal true
|
36
37
|
TraceView::Config[:action_view][:enabled].must_equal true
|
37
38
|
TraceView::Config[:active_record][:enabled].must_equal true
|
38
39
|
TraceView::Config[:bunnyclient][:enabled].must_equal true
|
@@ -63,6 +64,7 @@ describe "TraceView::Config" do
|
|
63
64
|
TraceView::Config[:typhoeus][:enabled].must_equal true
|
64
65
|
|
65
66
|
TraceView::Config[:action_controller][:log_args].must_equal true
|
67
|
+
TraceView::Config[:action_controller_api][:log_args].must_equal true
|
66
68
|
TraceView::Config[:action_view][:log_args].must_equal true
|
67
69
|
TraceView::Config[:active_record][:log_args].must_equal true
|
68
70
|
TraceView::Config[:bunnyclient][:log_args].must_equal true
|
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
|
+
version: 3.8.0
|
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: 2016-
|
12
|
+
date: 2016-04-22 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: json
|
@@ -128,6 +128,7 @@ files:
|
|
128
128
|
- lib/traceview/frameworks/rails/inst/action_controller3.rb
|
129
129
|
- lib/traceview/frameworks/rails/inst/action_controller4.rb
|
130
130
|
- lib/traceview/frameworks/rails/inst/action_controller5.rb
|
131
|
+
- lib/traceview/frameworks/rails/inst/action_controller5_api.rb
|
131
132
|
- lib/traceview/frameworks/rails/inst/action_view.rb
|
132
133
|
- lib/traceview/frameworks/rails/inst/action_view_2x.rb
|
133
134
|
- lib/traceview/frameworks/rails/inst/action_view_30.rb
|
@@ -183,6 +184,7 @@ files:
|
|
183
184
|
- test/frameworks/padrino_test.rb
|
184
185
|
- test/frameworks/rails3x_test.rb
|
185
186
|
- test/frameworks/rails4x_test.rb
|
187
|
+
- test/frameworks/rails5x_api_test.rb
|
186
188
|
- test/frameworks/rails5x_test.rb
|
187
189
|
- test/frameworks/sinatra_test.rb
|
188
190
|
- test/instrumentation/bunny_client_test.rb
|
@@ -239,6 +241,7 @@ files:
|
|
239
241
|
- test/servers/rails3x_8140.rb
|
240
242
|
- test/servers/rails4x_8140.rb
|
241
243
|
- test/servers/rails5x_8140.rb
|
244
|
+
- test/servers/rails5x_api_8150.rb
|
242
245
|
- test/servers/sidekiq.rb
|
243
246
|
- test/servers/sidekiq.yml
|
244
247
|
- test/servers/sidekiq_initializer.rb
|
@@ -285,6 +288,7 @@ test_files:
|
|
285
288
|
- test/servers/rails3x_8140.rb
|
286
289
|
- test/servers/rails5x_8140.rb
|
287
290
|
- test/servers/delayed_job.rb
|
291
|
+
- test/servers/rails5x_api_8150.rb
|
288
292
|
- test/servers/sidekiq.rb
|
289
293
|
- test/servers/rackapp_8101.rb
|
290
294
|
- test/instrumentation/excon_test.rb
|
@@ -330,6 +334,7 @@ test_files:
|
|
330
334
|
- test/frameworks/rails3x_test.rb
|
331
335
|
- test/frameworks/padrino_test.rb
|
332
336
|
- test/frameworks/rails4x_test.rb
|
337
|
+
- test/frameworks/rails5x_api_test.rb
|
333
338
|
- test/frameworks/apps/grape_simple.rb
|
334
339
|
- test/frameworks/apps/sinatra_simple.rb
|
335
340
|
- test/frameworks/apps/padrino_simple.rb
|