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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 96c087aab94a58d443be7e150a674f72cffbf110
4
- data.tar.gz: 08616ab412adefe991cc489aecb9c960c64dc8db
3
+ metadata.gz: 6dc0bc3e553473e4db7f6306c77eeb01c38d65d0
4
+ data.tar.gz: 1353599fd945e2a408c8a5966285a30a4b1a848a
5
5
  SHA512:
6
- metadata.gz: 8f950a8ad1c44cf89064f94c4eb17b26020a74e2c1156af6e4cb8cfc1c80612e0e96aefb4576bcff8ffab3908e0358a0c2d3edd0338c69cc2fd44215e6b0100d
7
- data.tar.gz: 311bb5d286c6eef95149a6807f81334117a727ab1d440c773442c6d7c6ce6e8e647bfad93742b2ac1e227245b6d2aba988533d279404eabbf9482c9c91b66690
6
+ metadata.gz: cf9adedff95cb25d0c0ee9a702c64204b37bd395a479d31206263f871897a27ec0a2da34f9fb11295a5e9495e6103b889509cf4d52261ba8d1478c5261d75bd7
7
+ data.tar.gz: 4d710f1c782b5f520cad33049d1835df03dc023912506f67a1f3a25beedf284b27113e43e9ab9fe12407cdc9f43b11714768ebc6d89195dbe1d4c286a4b2a2e5
data/.travis.yml CHANGED
@@ -6,8 +6,8 @@ cache:
6
6
  - vendor/bundle
7
7
 
8
8
  rvm:
9
- - 2.2.2
10
- - 2.1.6
9
+ - 2.2.3
10
+ - 2.1.7
11
11
  - 2.0.0
12
12
  - 1.9.3
13
13
  - 1.8.7
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/oboe-ruby.png?branch=master)](https://travis-ci.org/appneta/oboe-ruby)
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: Unless you are Heroku, 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.*
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
@@ -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
@@ -8,6 +8,11 @@ if RUBY_VERSION < '1.9.3'
8
8
  gem 'activesupport', '< 4.0'
9
9
  end
10
10
 
11
+ if RUBY_VERSION < '2.0.0'
12
+ # rack-cache dropped support for Ruby 1.9
13
+ gem 'rack-cache', '1.2'
14
+ end
15
+
11
16
  group :development, :test do
12
17
  gem 'rake'
13
18
  gem 'minitest'
@@ -8,6 +8,11 @@ if RUBY_VERSION < '1.9.3'
8
8
  gem 'activesupport', '< 4.0'
9
9
  end
10
10
 
11
+ if RUBY_VERSION < '2.0.0'
12
+ # rack-cache dropped support for Ruby 1.9
13
+ gem 'rack-cache', '1.2'
14
+ end
15
+
11
16
  group :development, :test do
12
17
  gem 'rake'
13
18
  gem 'minitest'
@@ -8,6 +8,11 @@ if RUBY_VERSION < '1.9.3'
8
8
  gem 'activesupport', '< 4.0'
9
9
  end
10
10
 
11
+ if RUBY_VERSION < '2.0.0'
12
+ # rack-cache dropped support for Ruby 1.9
13
+ gem 'rack-cache', '1.2'
14
+ end
15
+
11
16
  group :development, :test do
12
17
  gem 'rake'
13
18
  gem 'minitest'
@@ -8,6 +8,11 @@ if RUBY_VERSION < '1.9.3'
8
8
  gem 'activesupport', '< 4.0'
9
9
  end
10
10
 
11
+ if RUBY_VERSION < '2.0.0'
12
+ # rack-cache dropped support for Ruby 1.9
13
+ gem 'rack-cache', '1.2'
14
+ end
15
+
11
16
  group :development, :test do
12
17
  gem 'rake'
13
18
  gem 'minitest'
data/lib/joboe_metal.rb CHANGED
@@ -44,83 +44,96 @@ module Oboe_metal
44
44
  end
45
45
 
46
46
  module Reporter
47
- ##
48
- # Initialize the TraceView Context, reporter and report the initialization
49
- #
50
- def self.start
51
- return unless TraceView.loaded
52
-
53
- if ENV.key?('TRACEVIEW_GEM_TEST')
54
- TraceView.reporter = Java::ComTracelyticsJoboe::TestReporter.new
55
- else
56
- TraceView.reporter = Java::ComTracelyticsJoboe::ReporterFactory.getInstance.buildUdpReporter
57
- end
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
- begin
61
- # Import the tracing mode and sample rate settings
62
- # from the Java agent (user configured in
63
- # /usr/local/tracelytics/javaagent.json when under JRuby)
64
- cfg = LayerUtil.getLocalSampleRate(nil, nil)
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
- TraceView.sample_rate = cfg.getSampleRate
75
- TraceView::Config.sample_rate = cfg.sampleRate
76
- TraceView::Config.sample_source = cfg.sampleRateSourceValue
77
- rescue => e
78
- TraceView.logger.debug "[traceview/debug] Couldn't retrieve/acces joboe sampleRateCfg"
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
- # Only report __Init from here if we are not instrumenting a framework.
83
- # Otherwise, frameworks will handle reporting __Init after full initialization
84
- unless defined?(::Rails) || defined?(::Sinatra) || defined?(::Padrino) || defined?(::Grape)
85
- TraceView::API.report_init unless ENV.key?('TRACEVIEW_GEM_TEST')
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
- # clear_all_traces
91
- #
92
- # Truncates the trace output file to zero
93
- #
94
- def self.clear_all_traces
95
- TraceView.reporter.reset if TraceView.loaded
96
- end
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
- # get_all_traces
100
- #
101
- # Retrieves all traces written to the trace file
102
- #
103
- def self.get_all_traces
104
- return [] unless TraceView.loaded
105
-
106
- # Joboe TestReporter returns a Java::ComTracelyticsExtEbson::DefaultDocument
107
- # document for traces which doesn't correctly support things like has_key? which
108
- # raises an unhandled exception on non-existent key (duh). Here we convert
109
- # the Java::ComTracelyticsExtEbson::DefaultDocument doc to a pure array of Ruby
110
- # hashes
111
- traces = []
112
- TraceView.reporter.getSentEventsAsBsonDocument.to_a.each do |e|
113
- t = {}
114
- e.each_pair { |k, v|
115
- t[k] = v
116
- }
117
- traces << t
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
- def self.sendReport(evt)
123
- evt.report(TraceView.reporter)
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
- begin
21
- Oboe_metal::Context.init
16
+ ##
17
+ # start
18
+ #
19
+ # Start the TraceView Reporter
20
+ #
21
+ def start
22
+ return unless TraceView.loaded
22
23
 
23
- if ENV.key?('TRACEVIEW_GEM_TEST')
24
- TraceView.reporter = TraceView::FileReporter.new('/tmp/trace_output.bson')
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
- # Only report __Init from here if we are not instrumenting a framework.
30
- # Otherwise, frameworks will handle reporting __Init after full initialization
31
- unless defined?(::Rails) || defined?(::Sinatra) || defined?(::Padrino) || defined?(::Grape)
32
- TraceView::API.report_init unless ENV.key?('TRACEVIEW_GEM_TEST')
33
- end
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
- rescue => e
36
- $stderr.puts e.message
37
- raise
38
- end
39
- end
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
- def self.sendReport(evt)
42
- TraceView.reporter.sendReport(evt)
43
- end
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
- # clear_all_traces
47
- #
48
- # Truncates the trace output file to zero
49
- #
50
- def self.clear_all_traces
51
- File.truncate($trace_file, 0)
52
- end
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
- # get_all_traces
56
- #
57
- # Retrieves all traces written to the trace file
58
- #
59
- def self.get_all_traces
60
- io = File.open($trace_file, 'r')
61
- contents = io.readlines(nil)
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
- return contents if contents.empty?
73
+ return contents if contents.empty?
64
74
 
65
- s = StringIO.new(contents[0])
75
+ s = StringIO.new(contents[0])
66
76
 
67
- traces = []
77
+ traces = []
68
78
 
69
- until s.eof?
70
- if ::BSON.respond_to? :read_bson_document
71
- traces << BSON.read_bson_document(s)
72
- else
73
- traces << BSON::Document.from_bson(s)
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
- traces
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