traceview 3.2.1-java → 3.3.0-java
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +2 -2
- data/CHANGELOG.md +26 -0
- data/README.md +4 -10
- data/Rakefile +6 -3
- data/gemfiles/libraries.gemfile +2 -1
- data/gemfiles/rails23.gemfile +5 -0
- data/gemfiles/rails30.gemfile +5 -0
- data/gemfiles/rails31.gemfile +5 -0
- data/gemfiles/rails32.gemfile +5 -0
- data/lib/joboe_metal.rb +79 -66
- data/lib/oboe_metal.rb +67 -54
- data/lib/traceview.rb +2 -0
- data/lib/traceview/api/layerinit.rb +7 -5
- data/lib/traceview/api/logging.rb +8 -1
- data/lib/traceview/config.rb +7 -2
- data/lib/traceview/inst/sidekiq-client.rb +54 -0
- data/lib/traceview/inst/sidekiq-worker.rb +61 -0
- data/lib/traceview/test.rb +20 -0
- data/lib/traceview/util.rb +1 -0
- data/lib/traceview/version.rb +2 -2
- data/test/instrumentation/curb_test.rb +1 -1
- data/test/instrumentation/sidekiq-client_test.rb +131 -0
- data/test/instrumentation/sidekiq-worker_test.rb +180 -0
- data/test/jobs/db_worker_job.rb +29 -0
- data/test/jobs/error_worker_job.rb +10 -0
- data/test/jobs/remote_call_worker_job.rb +20 -0
- data/test/minitest_helper.rb +4 -1
- data/test/reporter/reporter_test.rb +14 -0
- data/test/servers/sidekiq.rb +35 -0
- data/test/servers/sidekiq.yml +7 -0
- data/test/servers/sidekiq_initializer.rb +22 -0
- data/test/support/config_test.rb +5 -1
- data/test/support/liboboe_settings_test.rb +1 -0
- metadata +23 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6dc0bc3e553473e4db7f6306c77eeb01c38d65d0
|
4
|
+
data.tar.gz: 1353599fd945e2a408c8a5966285a30a4b1a848a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cf9adedff95cb25d0c0ee9a702c64204b37bd395a479d31206263f871897a27ec0a2da34f9fb11295a5e9495e6103b889509cf4d52261ba8d1478c5261d75bd7
|
7
|
+
data.tar.gz: 4d710f1c782b5f520cad33049d1835df03dc023912506f67a1f3a25beedf284b27113e43e9ab9fe12407cdc9f43b11714768ebc6d89195dbe1d4c286a4b2a2e5
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -4,6 +4,32 @@ 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.3.0
|
8
|
+
|
9
|
+
This patch release includes the following fixes:
|
10
|
+
|
11
|
+
* New [Sidekiq](http://sidekiq.org/) instrumentation: #138, #139
|
12
|
+
* Require `Set` before referencing it: #143
|
13
|
+
* Add `:action_blacklist` deprecation warning: #137
|
14
|
+
* Add a way to restart the reporter via `TraceView::Reporter.restart`: #140
|
15
|
+
|
16
|
+
Pushed to Rubygems:
|
17
|
+
|
18
|
+
https://rubygems.org/gems/traceview/versions/3.3.0
|
19
|
+
https://rubygems.org/gems/traceview/versions/3.3.0-java
|
20
|
+
|
21
|
+
# traceview 3.2.1
|
22
|
+
|
23
|
+
This minor release adds the following:
|
24
|
+
|
25
|
+
* New and improved method profiling: #135
|
26
|
+
* Fix URL Query config: #136
|
27
|
+
|
28
|
+
Pushed to Rubygems:
|
29
|
+
|
30
|
+
https://rubygems.org/gems/traceview/versions/3.2.1
|
31
|
+
https://rubygems.org/gems/traceview/versions/3.2.1-java
|
32
|
+
|
7
33
|
# traceview 3.2.0
|
8
34
|
|
9
35
|
This minor release adds the following:
|
data/README.md
CHANGED
@@ -9,9 +9,11 @@ It has the ability to report performance metrics on an array of libraries, datab
|
|
9
9
|
It requires a [TraceView](http://www.appneta.com/products/traceview/) account to view metrics. Get yours, [it's free](http://www.appneta.com/products/traceview-free-account/).
|
10
10
|
|
11
11
|
[![Gem Version](https://badge.fury.io/rb/traceview.png)](http://badge.fury.io/rb/traceview)
|
12
|
-
[![Build Status](https://travis-ci.org/appneta/
|
12
|
+
[![Build Status](https://travis-ci.org/appneta/ruby-traceview.png?branch=master)](https://travis-ci.org/appneta/ruby-traceview)
|
13
13
|
[![Code Climate](https://codeclimate.com/github/appneta/oboe-ruby.png)](https://codeclimate.com/github/appneta/oboe-ruby)
|
14
14
|
|
15
|
+
_Note: The repository name has been changed to ruby-traceview. Please update your github remotes with `git remote set-url origin git@github.com:appneta/ruby-traceview.git`._
|
16
|
+
|
15
17
|
# Installation
|
16
18
|
|
17
19
|
The traceview gem is [available on Rubygems](https://rubygems.org/gems/traceview) and can be installed with:
|
@@ -26,8 +28,6 @@ or added to _the end_ of your bundle Gemfile and running `bundle install`:
|
|
26
28
|
gem 'traceview'
|
27
29
|
```
|
28
30
|
|
29
|
-
On Heroku? Use the `oboe-heroku` gem instead. It wraps some additional functionality specialized for Heroku.
|
30
|
-
|
31
31
|
# Running
|
32
32
|
|
33
33
|
## Rails
|
@@ -36,7 +36,7 @@ On Heroku? Use the `oboe-heroku` gem instead. It wraps some additional functio
|
|
36
36
|
|
37
37
|
No special steps are needed to instrument Ruby on Rails. Once part of the bundle, the traceview gem will automatically detect Rails and instrument on stack initialization.
|
38
38
|
|
39
|
-
*Note:
|
39
|
+
*Note: You will still need to decide on your `tracing_mode` depending on whether you are running with an instrumented Apache or nginx in front of your Rails stack. See below for more details.*
|
40
40
|
|
41
41
|
### The Install Generator
|
42
42
|
|
@@ -71,8 +71,6 @@ TraceView::Config[:tracing_mode] = 'through'
|
|
71
71
|
# TraceView.logger = Sinatra.logger
|
72
72
|
```
|
73
73
|
|
74
|
-
Note: If you're on Heroku, you don't need to set `tracing_mode` - it will be automatically configured.
|
75
|
-
|
76
74
|
Make sure that the traceview gem is loaded _after_ Sinatra either by listing `gem 'traceview'` after Sinatra in your Gemfile or calling the `require 'traceview'` directive after Sinatra is loaded.
|
77
75
|
|
78
76
|
With this, the traceview gem will automatically detect Sinatra on boot and instrument key components.
|
@@ -96,8 +94,6 @@ Padrino.before_load do
|
|
96
94
|
end
|
97
95
|
```
|
98
96
|
|
99
|
-
Note: If you're on Heroku, you don't need to set `tracing_mode` - it will be automatically configured.
|
100
|
-
|
101
97
|
## Grape
|
102
98
|
|
103
99
|
![Grape](http://www.appneta.com/images/logos/frameworks/grape.png)
|
@@ -122,8 +118,6 @@ You can instrument your Grape application by adding the following code to your `
|
|
122
118
|
end
|
123
119
|
```
|
124
120
|
|
125
|
-
Note: If you're on Heroku, you don't need to set `tracing_mode` - it will be automatically configured.
|
126
|
-
|
127
121
|
Make sure that the traceview gem is loaded _after_ Grape either by listing `gem 'traceview'` after Grape in your Gemfile or calling the `require 'traceview'` directive after Grape is loaded.
|
128
122
|
|
129
123
|
You must explicitly tell your Grape application to use TraceView::Rack for tracing to occur.
|
data/Rakefile
CHANGED
@@ -5,6 +5,8 @@ require 'bundler/setup'
|
|
5
5
|
require 'rake/testtask'
|
6
6
|
|
7
7
|
Rake::TestTask.new do |t|
|
8
|
+
t.verbose = true
|
9
|
+
t.ruby_opts = []
|
8
10
|
t.libs << "test"
|
9
11
|
|
10
12
|
# Since we support so many libraries and frameworks, tests
|
@@ -25,12 +27,11 @@ Rake::TestTask.new do |t|
|
|
25
27
|
t.test_files = FileList['test/frameworks/sinatra*_test.rb']
|
26
28
|
when /libraries/
|
27
29
|
t.test_files = FileList['test/support/*_test.rb'] +
|
30
|
+
FileList['test/reporter/*_test.rb'] +
|
28
31
|
FileList['test/instrumentation/*_test.rb'] +
|
29
32
|
FileList['test/profiling/*_test.rb']
|
30
33
|
end
|
31
34
|
|
32
|
-
t.verbose = true
|
33
|
-
t.ruby_opts = []
|
34
35
|
# t.ruby_opts << ['-w']
|
35
36
|
if defined?(JRUBY_VERSION)
|
36
37
|
t.ruby_opts << ["-J-javaagent:/usr/local/tracelytics/tracelyticsagent.jar"]
|
@@ -97,8 +98,8 @@ task :distclean do
|
|
97
98
|
mkmf_log = File.expand_path('ext/oboe_metal/mkmf.log')
|
98
99
|
|
99
100
|
if File.exists? mkmf_log
|
100
|
-
Dir.chdir ext_dir
|
101
101
|
File.delete symlink if File.exist? symlink
|
102
|
+
Dir.chdir ext_dir
|
102
103
|
sh '/usr/bin/env make distclean'
|
103
104
|
|
104
105
|
Dir.chdir pwd
|
@@ -114,9 +115,11 @@ desc "Rebuild the gem's c extension"
|
|
114
115
|
task :recompile => [ :distclean, :compile ]
|
115
116
|
|
116
117
|
task :console do
|
118
|
+
require 'traceview/test'
|
117
119
|
ENV['TRACEVIEW_GEM_VERBOSE'] = 'true'
|
118
120
|
Bundler.require(:default, :development)
|
119
121
|
TraceView::Config[:tracing_mode] = :always
|
122
|
+
TV::Test.load_extras
|
120
123
|
ARGV.clear
|
121
124
|
Pry.start
|
122
125
|
end
|
data/gemfiles/libraries.gemfile
CHANGED
@@ -44,7 +44,7 @@ else
|
|
44
44
|
end
|
45
45
|
|
46
46
|
gem 'cassandra'
|
47
|
-
gem 'curb'
|
47
|
+
gem 'curb' unless defined?(JRUBY_VERSION)
|
48
48
|
gem 'dalli'
|
49
49
|
gem 'excon'
|
50
50
|
gem 'faraday'
|
@@ -54,6 +54,7 @@ gem 'mongo'
|
|
54
54
|
gem 'redis'
|
55
55
|
gem 'resque'
|
56
56
|
gem 'sequel'
|
57
|
+
gem "sidekiq" if RUBY_VERSION >= '2.0'
|
57
58
|
gem 'typhoeus'
|
58
59
|
|
59
60
|
# Database adapter gems needed by sequel
|
data/gemfiles/rails23.gemfile
CHANGED
data/gemfiles/rails30.gemfile
CHANGED
data/gemfiles/rails31.gemfile
CHANGED
data/gemfiles/rails32.gemfile
CHANGED
data/lib/joboe_metal.rb
CHANGED
@@ -44,83 +44,96 @@ module Oboe_metal
|
|
44
44
|
end
|
45
45
|
|
46
46
|
module Reporter
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
47
|
+
class << self
|
48
|
+
##
|
49
|
+
# start
|
50
|
+
#
|
51
|
+
# Start the TraceView Reporter
|
52
|
+
#
|
53
|
+
def start
|
54
|
+
return unless TraceView.loaded
|
55
|
+
|
56
|
+
if ENV.key?('TRACEVIEW_GEM_TEST')
|
57
|
+
TraceView.reporter = Java::ComTracelyticsJoboe::TestReporter.new
|
58
|
+
else
|
59
|
+
TraceView.reporter = Java::ComTracelyticsJoboe::ReporterFactory.getInstance.buildUdpReporter
|
60
|
+
end
|
58
61
|
|
62
|
+
begin
|
63
|
+
# Import the tracing mode and sample rate settings
|
64
|
+
# from the Java agent (user configured in
|
65
|
+
# /usr/local/tracelytics/javaagent.json when under JRuby)
|
66
|
+
cfg = LayerUtil.getLocalSampleRate(nil, nil)
|
67
|
+
|
68
|
+
if cfg.hasSampleStartFlag
|
69
|
+
TraceView::Config.tracing_mode = 'always'
|
70
|
+
elsif cfg.hasSampleThroughFlag
|
71
|
+
TraceView::Config.tracing_mode = 'through'
|
72
|
+
else
|
73
|
+
TraceView::Config.tracing_mode = 'never'
|
74
|
+
end
|
59
75
|
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
if cfg.hasSampleStartFlag
|
67
|
-
TraceView::Config.tracing_mode = 'always'
|
68
|
-
elsif cfg.hasSampleThroughFlag
|
69
|
-
TraceView::Config.tracing_mode = 'through'
|
70
|
-
else
|
71
|
-
TraceView::Config.tracing_mode = 'never'
|
76
|
+
TraceView.sample_rate = cfg.getSampleRate
|
77
|
+
TraceView::Config.sample_rate = cfg.sampleRate
|
78
|
+
TraceView::Config.sample_source = cfg.sampleRateSourceValue
|
79
|
+
rescue => e
|
80
|
+
TraceView.logger.debug "[traceview/debug] Couldn't retrieve/acces joboe sampleRateCfg"
|
81
|
+
TraceView.logger.debug "[traceview/debug] #{e.message}"
|
72
82
|
end
|
73
83
|
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
TraceView.logger.debug "[traceview/debug] #{e.message}"
|
84
|
+
# Only report __Init from here if we are not instrumenting a framework.
|
85
|
+
# Otherwise, frameworks will handle reporting __Init after full initialization
|
86
|
+
unless defined?(::Rails) || defined?(::Sinatra) || defined?(::Padrino) || defined?(::Grape)
|
87
|
+
TraceView::API.report_init unless ENV.key?('TRACEVIEW_GEM_TEST')
|
88
|
+
end
|
80
89
|
end
|
81
90
|
|
82
|
-
|
83
|
-
#
|
84
|
-
|
85
|
-
|
91
|
+
##
|
92
|
+
# restart
|
93
|
+
#
|
94
|
+
# This is a nil method for TraceView under Java. It is maintained only
|
95
|
+
# for compability across interfaces.
|
96
|
+
#
|
97
|
+
def restart
|
98
|
+
TraceView.logger.warn "[traceview/reporter] Reporter.restart isn't supported under JRuby"
|
86
99
|
end
|
87
|
-
end
|
88
100
|
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
101
|
+
##
|
102
|
+
# clear_all_traces
|
103
|
+
#
|
104
|
+
# Truncates the trace output file to zero
|
105
|
+
#
|
106
|
+
def clear_all_traces
|
107
|
+
TraceView.reporter.reset if TraceView.loaded
|
108
|
+
end
|
97
109
|
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
110
|
+
##
|
111
|
+
# get_all_traces
|
112
|
+
#
|
113
|
+
# Retrieves all traces written to the trace file
|
114
|
+
#
|
115
|
+
def get_all_traces
|
116
|
+
return [] unless TraceView.loaded
|
117
|
+
|
118
|
+
# Joboe TestReporter returns a Java::ComTracelyticsExtEbson::DefaultDocument
|
119
|
+
# document for traces which doesn't correctly support things like has_key? which
|
120
|
+
# raises an unhandled exception on non-existent key (duh). Here we convert
|
121
|
+
# the Java::ComTracelyticsExtEbson::DefaultDocument doc to a pure array of Ruby
|
122
|
+
# hashes
|
123
|
+
traces = []
|
124
|
+
TraceView.reporter.getSentEventsAsBsonDocument.to_a.each do |e|
|
125
|
+
t = {}
|
126
|
+
e.each_pair { |k, v|
|
127
|
+
t[k] = v
|
128
|
+
}
|
129
|
+
traces << t
|
130
|
+
end
|
131
|
+
traces
|
118
132
|
end
|
119
|
-
traces
|
120
|
-
end
|
121
133
|
|
122
|
-
|
123
|
-
|
134
|
+
def sendReport(evt)
|
135
|
+
evt.report(TraceView.reporter)
|
136
|
+
end
|
124
137
|
end
|
125
138
|
end
|
126
139
|
end
|
data/lib/oboe_metal.rb
CHANGED
@@ -11,70 +11,81 @@ module TraceView
|
|
11
11
|
include Oboe_metal
|
12
12
|
|
13
13
|
class Reporter
|
14
|
-
|
15
|
-
# Initialize the TraceView Context, reporter and report the initialization
|
16
|
-
#
|
17
|
-
def self.start
|
18
|
-
return unless TraceView.loaded
|
14
|
+
class << self
|
19
15
|
|
20
|
-
|
21
|
-
|
16
|
+
##
|
17
|
+
# start
|
18
|
+
#
|
19
|
+
# Start the TraceView Reporter
|
20
|
+
#
|
21
|
+
def start
|
22
|
+
return unless TraceView.loaded
|
22
23
|
|
23
|
-
|
24
|
-
|
25
|
-
else
|
26
|
-
TraceView.reporter = TraceView::UdpReporter.new(TraceView::Config[:reporter_host], TraceView::Config[:reporter_port])
|
27
|
-
end
|
24
|
+
begin
|
25
|
+
Oboe_metal::Context.init
|
28
26
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
27
|
+
if ENV.key?('TRACEVIEW_GEM_TEST')
|
28
|
+
TraceView.reporter = TraceView::FileReporter.new('/tmp/trace_output.bson')
|
29
|
+
else
|
30
|
+
TraceView.reporter = TraceView::UdpReporter.new(TraceView::Config[:reporter_host], TraceView::Config[:reporter_port])
|
31
|
+
end
|
34
32
|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
33
|
+
# Only report __Init from here if we are not instrumenting a framework.
|
34
|
+
# Otherwise, frameworks will handle reporting __Init after full initialization
|
35
|
+
unless defined?(::Rails) || defined?(::Sinatra) || defined?(::Padrino) || defined?(::Grape)
|
36
|
+
TraceView::API.report_init
|
37
|
+
end
|
40
38
|
|
41
|
-
|
42
|
-
|
43
|
-
|
39
|
+
rescue => e
|
40
|
+
$stderr.puts e.message
|
41
|
+
raise
|
42
|
+
end
|
43
|
+
end
|
44
|
+
alias :restart :start
|
45
|
+
|
46
|
+
##
|
47
|
+
# sendReport
|
48
|
+
#
|
49
|
+
# Send the report for the given event
|
50
|
+
#
|
51
|
+
def sendReport(evt)
|
52
|
+
TraceView.reporter.sendReport(evt)
|
53
|
+
end
|
44
54
|
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
55
|
+
##
|
56
|
+
# clear_all_traces
|
57
|
+
#
|
58
|
+
# Truncates the trace output file to zero
|
59
|
+
#
|
60
|
+
def clear_all_traces
|
61
|
+
File.truncate($trace_file, 0)
|
62
|
+
end
|
53
63
|
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
64
|
+
##
|
65
|
+
# get_all_traces
|
66
|
+
#
|
67
|
+
# Retrieves all traces written to the trace file
|
68
|
+
#
|
69
|
+
def get_all_traces
|
70
|
+
io = File.open($trace_file, 'r')
|
71
|
+
contents = io.readlines(nil)
|
62
72
|
|
63
|
-
|
73
|
+
return contents if contents.empty?
|
64
74
|
|
65
|
-
|
75
|
+
s = StringIO.new(contents[0])
|
66
76
|
|
67
|
-
|
77
|
+
traces = []
|
68
78
|
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
79
|
+
until s.eof?
|
80
|
+
if ::BSON.respond_to? :read_bson_document
|
81
|
+
traces << BSON.read_bson_document(s)
|
82
|
+
else
|
83
|
+
traces << BSON::Document.from_bson(s)
|
84
|
+
end
|
74
85
|
end
|
75
|
-
end
|
76
86
|
|
77
|
-
|
87
|
+
traces
|
88
|
+
end
|
78
89
|
end
|
79
90
|
end
|
80
91
|
|
@@ -90,9 +101,9 @@ module TraceView
|
|
90
101
|
return false unless TraceView.always? && TraceView.loaded
|
91
102
|
|
92
103
|
# Assure defaults since SWIG enforces Strings
|
93
|
-
layer = opts[:layer] ? opts[:layer].strip : ''
|
94
|
-
xtrace = opts[:xtrace] ? opts[:xtrace].strip : ''
|
95
|
-
tv_meta = opts['X-TV-Meta'] ? opts['X-TV-Meta'].strip : ''
|
104
|
+
layer = opts[:layer] ? opts[:layer].to_s.strip : ''
|
105
|
+
xtrace = opts[:xtrace] ? opts[:xtrace].to_s.strip : ''
|
106
|
+
tv_meta = opts['X-TV-Meta'] ? opts['X-TV-Meta'].to_s.strip : ''
|
96
107
|
|
97
108
|
rv = TraceView::Context.sampleRequest(layer, xtrace, tv_meta)
|
98
109
|
|
@@ -100,6 +111,8 @@ module TraceView
|
|
100
111
|
if ENV.key?('TRACEVIEW_GEM_TEST')
|
101
112
|
# When in test, always trace and don't clear
|
102
113
|
# the stored sample rate/source
|
114
|
+
TraceView.sample_rate ||= -1
|
115
|
+
TraceView.sample_source ||= -1
|
103
116
|
true
|
104
117
|
else
|
105
118
|
TraceView.sample_rate = -1
|