traceview 3.2.1 → 3.3.0

Sign up to get free protection for your applications and to get access to all the features.
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
@@ -11,11 +11,13 @@ module TraceView
11
11
  # layer.
12
12
  #
13
13
  def report_init(layer = 'rack')
14
- # Don't send __Init in development or test
15
- return if %w(development test).include? ENV['RACK_ENV']
16
-
17
- # Don't send __Init if the c-extension hasn't loaded
18
- return unless TraceView.loaded
14
+ # Don't send __Init in development, test or if the gem
15
+ # isn't fully loaded (e.g. missing c-extension)
16
+ if %w(development test).include? ENV['RACK_ENV'] ||
17
+ ENV.key?('TRACEVIEW_GEM_TEST') ||
18
+ !TraceView.loaded
19
+ return
20
+ end
19
21
 
20
22
  platform_info = TraceView::Util.build_init_report
21
23
 
@@ -1,6 +1,13 @@
1
1
  # Copyright (c) 2013 AppNeta, Inc.
2
2
  # All rights reserved.
3
3
 
4
+ # Make sure Set is loaded if possible.
5
+ begin
6
+ require 'set'
7
+ rescue LoadError
8
+ class Set; end
9
+ end
10
+
4
11
  module TraceView
5
12
  module API
6
13
  ##
@@ -105,7 +112,7 @@ module TraceView
105
112
  # sample rate and sample source
106
113
  opts[:SampleRate] = TraceView.sample_rate
107
114
  opts[:SampleSource] = TraceView.sample_source
108
- opts[:TraceOrigin] = :always_sampled
115
+ opts[:TraceOrigin] = :always_sampled
109
116
 
110
117
  log_event(layer, 'entry', TraceView::Context.startTrace, opts)
111
118
  end
@@ -14,8 +14,8 @@ module TraceView
14
14
  @@instrumentation = [:action_controller, :action_view, :active_record,
15
15
  :cassandra, :curb, :dalli, :em_http_request, :excon, :faraday,
16
16
  :grape, :httpclient, :nethttp, :memcached, :memcache, :mongo,
17
- :moped, :rack, :redis, :resque, :rest_client, :sequel,
18
- :typhoeus]
17
+ :moped, :rack, :redis, :resque, :rest_client, :sequel, :sidekiqclient,
18
+ :sidekiqworker, :typhoeus]
19
19
 
20
20
  # Subgrouping of instrumentation
21
21
  @@http_clients = [:curb, :excon, :em_http_request, :faraday, :httpclient, :nethttp, :rest_client, :typhoeus]
@@ -60,6 +60,8 @@ module TraceView
60
60
  TraceView::Config[:resque][:collect_backtraces] = true
61
61
  TraceView::Config[:rest_client][:collect_backtraces] = false
62
62
  TraceView::Config[:sequel][:collect_backtraces] = true
63
+ TraceView::Config[:sidekiqclient][:collect_backtraces] = false
64
+ TraceView::Config[:sidekiqworker][:collect_backtraces] = false
63
65
  TraceView::Config[:typhoeus][:collect_backtraces] = false
64
66
 
65
67
  # Special instrument specific flags
@@ -214,6 +216,9 @@ module TraceView
214
216
  @@config[key.to_sym] = value.to_i
215
217
  TraceView.set_sample_rate(value) if TraceView.loaded
216
218
 
219
+ elsif key == :action_blacklist
220
+ TraceView.logger.warn "[traceview/deprecation] :action_blacklist will be deprecated in a future version."
221
+
217
222
  elsif key == :include_url_query_params
218
223
  # Obey the global flag and update all of the per instrumentation
219
224
  # <tt>:log_args</tt> values.
@@ -0,0 +1,54 @@
1
+ module TraceView
2
+ class SidekiqClient
3
+ def collect_kvs(args)
4
+ begin
5
+ # Attempt to collect up pertinent info. If we hit something unexpected,
6
+ # keep calm and instrument on.
7
+
8
+ report_kvs = {}
9
+ worker_class, msg, queue, _ = args
10
+
11
+ report_kvs[:Spec] = :msgclient
12
+ report_kvs[:Flavor] = :sidekiq
13
+ report_kvs[:Queue] = queue
14
+ report_kvs[:Retry] = msg['retry']
15
+ report_kvs[:JobName] = worker_class
16
+ report_kvs[:MsgID] = msg['jid']
17
+ report_kvs[:Args] = msg['args'].to_s[0..1024] if TV::Config[:sidekiqclient][:log_args]
18
+ report_kvs[:Backtrace] = TV::API.backtrace if TV::Config[:sidekiqclient][:collect_backtraces]
19
+ rescue => e
20
+ TraceView.logger.warn "[traceview/sidekiq] Non-fatal error capturing KVs: #{e.message}"
21
+ end
22
+ report_kvs
23
+ end
24
+
25
+ def call(*args)
26
+ # args: 0: worker_class, 1: msg, 2: queue, 3: redis_pool
27
+
28
+ result = nil
29
+ report_kvs = collect_kvs(args)
30
+
31
+ TraceView::API.log_entry('sidekiq-client', report_kvs)
32
+ args[1]['X-Trace'] = TraceView::Context.toString if TraceView.tracing?
33
+
34
+ result = yield
35
+
36
+ report_kvs = { :JobID => result["jid"] }
37
+ result
38
+ rescue => e
39
+ TraceView::API.log_exception('sidekiq-client', e, report_kvs)
40
+ raise
41
+ ensure
42
+ TraceView::API.log_exit('sidekiq-client', report_kvs)
43
+ end
44
+ end
45
+ end
46
+
47
+ if defined?(::Sidekiq) && RUBY_VERSION >= '2.0' && TraceView::Config[:sidekiqclient][:enabled]
48
+ ::Sidekiq.configure_client do |config|
49
+ config.client_middleware do |chain|
50
+ ::TraceView.logger.info '[traceview/loading] Adding Sidekiq client middleware' if TraceView::Config[:verbose]
51
+ chain.add ::TraceView::SidekiqClient
52
+ end
53
+ end
54
+ end