oboe 2.7.1.7 → 2.7.2.fuchs1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (58) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +5 -0
  3. data/Gemfile +2 -0
  4. data/README.md +3 -3
  5. data/ext/oboe_metal/extconf.rb +11 -11
  6. data/lib/joboe_metal.rb +36 -42
  7. data/lib/oboe.rb +29 -26
  8. data/lib/oboe/api.rb +4 -0
  9. data/lib/oboe/api/layerinit.rb +7 -67
  10. data/lib/oboe/api/logging.rb +50 -28
  11. data/lib/oboe/api/memcache.rb +7 -5
  12. data/lib/oboe/api/profiling.rb +4 -4
  13. data/lib/oboe/api/tracing.rb +6 -5
  14. data/lib/oboe/api/util.rb +13 -9
  15. data/lib/oboe/base.rb +55 -16
  16. data/lib/oboe/config.rb +17 -15
  17. data/lib/oboe/frameworks/padrino.rb +0 -2
  18. data/lib/oboe/frameworks/padrino/templates.rb +5 -6
  19. data/lib/oboe/frameworks/rails.rb +0 -1
  20. data/lib/oboe/frameworks/rails/inst/action_controller.rb +4 -5
  21. data/lib/oboe/frameworks/rails/inst/action_view.rb +4 -4
  22. data/lib/oboe/frameworks/rails/inst/action_view_2x.rb +4 -4
  23. data/lib/oboe/frameworks/rails/inst/action_view_30.rb +2 -2
  24. data/lib/oboe/frameworks/rails/inst/active_record.rb +5 -5
  25. data/lib/oboe/frameworks/rails/inst/connection_adapters/mysql.rb +6 -6
  26. data/lib/oboe/frameworks/rails/inst/connection_adapters/mysql2.rb +3 -3
  27. data/lib/oboe/frameworks/rails/inst/connection_adapters/oracle.rb +1 -1
  28. data/lib/oboe/frameworks/rails/inst/connection_adapters/postgresql.rb +3 -3
  29. data/lib/oboe/frameworks/rails/inst/connection_adapters/utils.rb +18 -19
  30. data/lib/oboe/frameworks/sinatra.rb +4 -5
  31. data/lib/oboe/inst/cassandra.rb +17 -19
  32. data/lib/oboe/inst/dalli.rb +5 -5
  33. data/lib/oboe/inst/em-http-request.rb +13 -13
  34. data/lib/oboe/inst/faraday.rb +71 -0
  35. data/lib/oboe/inst/http.rb +4 -4
  36. data/lib/oboe/inst/memcache.rb +7 -10
  37. data/lib/oboe/inst/memcached.rb +7 -9
  38. data/lib/oboe/inst/mongo.rb +26 -28
  39. data/lib/oboe/inst/moped.rb +23 -24
  40. data/lib/oboe/inst/rack.rb +10 -11
  41. data/lib/oboe/inst/redis.rb +18 -20
  42. data/lib/oboe/inst/resque.rb +8 -9
  43. data/lib/oboe/instrumentation.rb +3 -0
  44. data/lib/oboe/loading.rb +19 -23
  45. data/lib/{method_profiling.rb → oboe/method_profiling.rb} +22 -8
  46. data/lib/oboe/ruby.rb +23 -3
  47. data/lib/oboe/support.rb +94 -0
  48. data/lib/oboe/thread_local.rb +9 -1
  49. data/lib/oboe/util.rb +90 -18
  50. data/lib/oboe/version.rb +5 -2
  51. data/lib/oboe/xtrace.rb +20 -24
  52. data/lib/oboe_metal.rb +16 -13
  53. data/lib/rails/generators/oboe/templates/oboe_initializer.rb +2 -0
  54. data/test/instrumentation/faraday_test.rb +142 -0
  55. data/test/instrumentation/moped_test.rb +2 -0
  56. data/test/minitest_helper.rb +0 -1
  57. data/test/support/config_test.rb +3 -1
  58. metadata +10 -5
@@ -24,17 +24,17 @@ module Oboe
24
24
  report_kvs['AJAX'] = true if req.xhr?
25
25
  report_kvs['ClientIP'] = req.ip
26
26
 
27
- report_kvs['X-TV-Meta'] = env['HTTP_X_TV_META'] if env.has_key?('HTTP_X_TV_META')
27
+ report_kvs['X-TV-Meta'] = env['HTTP_X_TV_META'] if env.key?('HTTP_X_TV_META')
28
28
 
29
29
  # Report any request queue'ing headers. Report as 'Request-Start' or the summed Queue-Time
30
- report_kvs['Request-Start'] = env['HTTP_X_REQUEST_START'] if env.has_key?('HTTP_X_REQUEST_START')
31
- report_kvs['Request-Start'] = env['HTTP_X_QUEUE_START'] if env.has_key?('HTTP_X_QUEUE_START')
32
- report_kvs['Queue-Time'] = env['HTTP_X_QUEUE_TIME'] if env.has_key?('HTTP_X_QUEUE_TIME')
30
+ report_kvs['Request-Start'] = env['HTTP_X_REQUEST_START'] if env.key?('HTTP_X_REQUEST_START')
31
+ report_kvs['Request-Start'] = env['HTTP_X_QUEUE_START'] if env.key?('HTTP_X_QUEUE_START')
32
+ report_kvs['Queue-Time'] = env['HTTP_X_QUEUE_TIME'] if env.key?('HTTP_X_QUEUE_TIME')
33
33
 
34
- report_kvs['Forwarded-For'] = env['HTTP_X_FORWARDED_FOR'] if env.has_key?('HTTP_X_FORWARDED_FOR')
35
- report_kvs['Forwarded-Host'] = env['HTTP_X_FORWARDED_HOST'] if env.has_key?('HTTP_X_FORWARDED_HOST')
36
- report_kvs['Forwarded-Proto'] = env['HTTP_X_FORWARDED_PROTO'] if env.has_key?('HTTP_X_FORWARDED_PROTO')
37
- report_kvs['Forwarded-Port'] = env['HTTP_X_FORWARDED_PORT'] if env.has_key?('HTTP_X_FORWARDED_PORT')
34
+ report_kvs['Forwarded-For'] = env['HTTP_X_FORWARDED_FOR'] if env.key?('HTTP_X_FORWARDED_FOR')
35
+ report_kvs['Forwarded-Host'] = env['HTTP_X_FORWARDED_HOST'] if env.key?('HTTP_X_FORWARDED_HOST')
36
+ report_kvs['Forwarded-Proto'] = env['HTTP_X_FORWARDED_PROTO'] if env.key?('HTTP_X_FORWARDED_PROTO')
37
+ report_kvs['Forwarded-Port'] = env['HTTP_X_FORWARDED_PORT'] if env.key?('HTTP_X_FORWARDED_PORT')
38
38
 
39
39
  report_kvs['Ruby.Oboe.Version'] = ::Oboe::Version::STRING
40
40
  rescue StandardError => e
@@ -64,7 +64,7 @@ module Oboe
64
64
 
65
65
  if Oboe.tracing?
66
66
  report_kvs = collect(req, env)
67
- Oboe::API.log(nil, 'info', report_kvs.merge!({ :Status => status }))
67
+ Oboe::API.log(nil, 'info', report_kvs.merge!(:Status => status))
68
68
  end
69
69
 
70
70
  [status, headers, response]
@@ -73,9 +73,8 @@ module Oboe
73
73
  xtrace = e.instance_variable_get(:@xtrace)
74
74
  raise
75
75
  ensure
76
- result[1]['X-Trace'] = xtrace if result and Oboe::XTrace.valid?(xtrace)
76
+ result[1]['X-Trace'] = xtrace if result && Oboe::XTrace.valid?(xtrace)
77
77
  return result
78
78
  end
79
79
  end
80
80
  end
81
-
@@ -6,9 +6,9 @@ module Oboe
6
6
  module Redis
7
7
  module Client
8
8
  # The operations listed in this constant skip collecting KVKey
9
- NO_KEY_OPS = [ :keys, :randomkey, :scan, :sdiff, :sdiffstore, :sinter,
10
- :sinterstore, :smove, :sunion, :sunionstore, :zinterstore,
11
- :zunionstore, :publish, :select, :eval, :evalsha, :script ]
9
+ NO_KEY_OPS = [:keys, :randomkey, :scan, :sdiff, :sdiffstore, :sinter,
10
+ :sinterstore, :smove, :sunion, :sunionstore, :zinterstore,
11
+ :zunionstore, :publish, :select, :eval, :evalsha, :script]
12
12
 
13
13
  # Instead of a giant switch statement, we use a hash constant to map out what
14
14
  # KVs need to be collected for each of the many many Redis operations
@@ -38,7 +38,7 @@ module Oboe
38
38
  :smove => { :source => 1, :destination => 2 },
39
39
  :bitop => { :operation => 1, :destkey => 2 },
40
40
  :hincrbyfloat => { :field => 2, :increment => 3 },
41
- :zremrangebyrank => { :start => 2, :stop => 3 },
41
+ :zremrangebyrank => { :start => 2, :stop => 3 }
42
42
  }
43
43
 
44
44
  # The following operations don't require any special handling. For these,
@@ -78,7 +78,7 @@ module Oboe
78
78
  kvs[:KVOp] = command[0]
79
79
  kvs[:RemoteHost] = @options[:host]
80
80
 
81
- unless NO_KEY_OPS.include? op or (command[1].is_a?(Array) and command[1].count > 1)
81
+ unless NO_KEY_OPS.include?(op) || (command[1].is_a?(Array) && command[1].count > 1)
82
82
  if command[1].is_a?(Array)
83
83
  kvs[:KVKey] = command[1].first
84
84
  else
@@ -98,10 +98,10 @@ module Oboe
98
98
  when :set
99
99
  if command.count > 3
100
100
  options = command[3]
101
- kvs[:ex] = options[:ex] if options.has_key?(:ex)
102
- kvs[:px] = options[:px] if options.has_key?(:px)
103
- kvs[:nx] = options[:nx] if options.has_key?(:nx)
104
- kvs[:xx] = options[:xx] if options.has_key?(:xx)
101
+ kvs[:ex] = options[:ex] if options.key?(:ex)
102
+ kvs[:px] = options[:px] if options.key?(:px)
103
+ kvs[:nx] = options[:nx] if options.key?(:nx)
104
+ kvs[:xx] = options[:xx] if options.key?(:xx)
105
105
  end
106
106
 
107
107
  when :get
@@ -115,7 +115,7 @@ module Oboe
115
115
 
116
116
  when :eval
117
117
  if command[1].length > 1024
118
- kvs[:Script] = command[1][0..1023] + "(...snip...)"
118
+ kvs[:Script] = command[1][0..1023] + '(...snip...)'
119
119
  else
120
120
  kvs[:Script] = command[1]
121
121
  end
@@ -123,9 +123,9 @@ module Oboe
123
123
  when :script
124
124
  kvs[:subcommand] = command[1]
125
125
  kvs[:Backtrace] = Oboe::API.backtrace if Oboe::Config[:redis][:collect_backtraces]
126
- if command[1] == "load"
126
+ if command[1] == 'load'
127
127
  if command[1].length > 1024
128
- kvs[:Script] = command[2][0..1023] + "(...snip...)"
128
+ kvs[:Script] = command[2][0..1023] + '(...snip...)'
129
129
  else
130
130
  kvs[:Script] = command[2]
131
131
  end
@@ -143,12 +143,12 @@ module Oboe
143
143
  else
144
144
  kvs[:KVKeyCount] = command.count - 1
145
145
  end
146
- values = r.select{ |i| i }
146
+ values = r.select { |i| i }
147
147
  kvs[:KVHitCount] = values.count
148
148
 
149
149
  when :hmget
150
150
  kvs[:KVKeyCount] = command.count - 2
151
- values = r.select{ |i| i }
151
+ values = r.select { |i| i }
152
152
  kvs[:KVHitCount] = values.count
153
153
 
154
154
  when :mset, :msetnx
@@ -162,7 +162,7 @@ module Oboe
162
162
 
163
163
  rescue StandardError => e
164
164
  Oboe.logger.debug "Error collecting redis KVs: #{e.message}"
165
- Oboe.logger.debug e.backtrace.join("\n")
165
+ Oboe.logger.debug e.backtrace.join('\n')
166
166
  end
167
167
 
168
168
  kvs
@@ -196,7 +196,7 @@ module Oboe
196
196
  pipeline.commands.each do |c|
197
197
  ops << c.first
198
198
  end
199
- kvs[:KVOps] = ops.join(", ")
199
+ kvs[:KVOps] = ops.join(', ')
200
200
  end
201
201
  rescue StandardError => e
202
202
  Oboe.logger.debug "[oboe/debug] Error extracting pipelined commands: #{e.message}"
@@ -236,8 +236,6 @@ module Oboe
236
236
  #
237
237
  def call_pipeline_with_oboe(pipeline)
238
238
  if Oboe.tracing?
239
- report_kvs = {}
240
-
241
239
  # Fall back to the raw tracing API so we can pass KVs
242
240
  # back on exit (a limitation of the Oboe::API.trace
243
241
  # block method) This removes the need for an info
@@ -265,8 +263,8 @@ module Oboe
265
263
  end
266
264
 
267
265
  if Oboe::Config[:redis][:enabled]
268
- if defined?(::Redis) and Gem::Version.new(::Redis::VERSION) >= Gem::Version.new('3.0.0')
269
- Oboe.logger.info "[oboe/loading] Instrumenting redis" if Oboe::Config[:verbose]
266
+ if defined?(::Redis) && Gem::Version.new(::Redis::VERSION) >= Gem::Version.new('3.0.0')
267
+ Oboe.logger.info '[oboe/loading] Instrumenting redis' if Oboe::Config[:verbose]
270
268
  ::Oboe::Util.send_include(::Redis::Client, ::Oboe::Inst::Redis::Client)
271
269
  end
272
270
  end
@@ -7,7 +7,6 @@ require 'json'
7
7
  module Oboe
8
8
  module Inst
9
9
  module Resque
10
-
11
10
  def self.included(base)
12
11
  base.send :extend, ::Resque
13
12
  end
@@ -42,7 +41,7 @@ module Oboe
42
41
  report_kvs = extract_trace_details(:enqueue, klass, args)
43
42
 
44
43
  Oboe::API.trace('resque-client', report_kvs, :enqueue) do
45
- args.push({:parent_trace_id => Oboe::Context.toString}) if Oboe::Config[:resque][:link_workers]
44
+ args.push(:parent_trace_id => Oboe::Context.toString) if Oboe::Config[:resque][:link_workers]
46
45
  enqueue_without_oboe(klass, *args)
47
46
  end
48
47
  else
@@ -51,12 +50,12 @@ module Oboe
51
50
  end
52
51
 
53
52
  def enqueue_to_with_oboe(queue, klass, *args)
54
- if Oboe.tracing? and not Oboe.tracing_layer_op?(:enqueue)
53
+ if Oboe.tracing? && !Oboe.tracing_layer_op?(:enqueue)
55
54
  report_kvs = extract_trace_details(:enqueue_to, klass, args)
56
55
  report_kvs[:Queue] = queue.to_s if queue
57
56
 
58
57
  Oboe::API.trace('resque-client', report_kvs) do
59
- args.push({:parent_trace_id => Oboe::Context.toString}) if Oboe::Config[:resque][:link_workers]
58
+ args.push(:parent_trace_id => Oboe::Context.toString) if Oboe::Config[:resque][:link_workers]
60
59
  enqueue_to_without_oboe(queue, klass, *args)
61
60
  end
62
61
  else
@@ -112,7 +111,7 @@ module Oboe
112
111
  rescue
113
112
  end
114
113
 
115
- if last_arg.is_a?(Hash) and last_arg.has_key?('parent_trace_id')
114
+ if last_arg.is_a?(Hash) && last_arg.key?('parent_trace_id')
116
115
  begin
117
116
  # Since the enqueue was traced, we force trace the actual job execution and reference
118
117
  # the enqueue trace with ParentTraceID
@@ -148,12 +147,12 @@ module Oboe
148
147
  end
149
148
 
150
149
  if defined?(::Resque)
151
- Oboe.logger.info "[oboe/loading] Instrumenting resque" if Oboe::Config[:verbose]
150
+ Oboe.logger.info '[oboe/loading] Instrumenting resque' if Oboe::Config[:verbose]
152
151
 
153
152
  ::Resque.module_eval do
154
153
  include Oboe::Inst::Resque
155
154
 
156
- [ :enqueue, :enqueue_to, :dequeue ].each do |m|
155
+ [:enqueue, :enqueue_to, :dequeue].each do |m|
157
156
  if method_defined?(m)
158
157
  module_eval "alias #{m}_without_oboe #{m}"
159
158
  module_eval "alias #{m} #{m}_with_oboe"
@@ -171,7 +170,7 @@ if defined?(::Resque)
171
170
  alias perform_without_oboe perform
172
171
  alias perform perform_with_oboe
173
172
  elsif Oboe::Config[:verbose]
174
- Oboe.logger.warn "[oboe/loading] Couldn't properly instrument ResqueWorker (perform). Partial traces may occur."
173
+ Oboe.logger.warn '[oboe/loading] Couldn\'t properly instrument ResqueWorker (perform). Partial traces may occur.'
175
174
  end
176
175
  end
177
176
  end
@@ -184,7 +183,7 @@ if defined?(::Resque)
184
183
  alias fail_without_oboe fail
185
184
  alias fail fail_with_oboe
186
185
  elsif Oboe::Config[:verbose]
187
- Oboe.logger.warn "[oboe/loading] Couldn't properly instrument ResqueWorker (fail). Partial traces may occur."
186
+ Oboe.logger.warn '[oboe/loading] Couldn\'t properly instrument ResqueWorker (fail). Partial traces may occur.'
188
187
  end
189
188
  end
190
189
  end
@@ -2,6 +2,9 @@
2
2
  # All rights reserved.
3
3
 
4
4
  module Oboe
5
+ ##
6
+ # The Inst module holds all of the instrumentation extensions for various
7
+ # libraries suchs as Redis, Dalli and Resque.
5
8
  module Inst
6
9
  def self.load_instrumentation
7
10
  # Load the general instrumentation
@@ -42,30 +42,28 @@ module Oboe
42
42
  # or environment variable) and calculate internal RUM ID
43
43
  #
44
44
  def self.load_access_key
45
- begin
46
- if ENV.has_key?('TRACEVIEW_CUUID')
47
- # Preferably get access key from environment (e.g. Heroku)
48
- Oboe::Config[:access_key] = ENV['TRACEVIEW_CUUID']
49
- Oboe::Config[:rum_id] = Oboe::Util::Base64URL.encode(Digest::SHA1.digest("RUM" + Oboe::Config[:access_key]))
50
- else
51
- # ..else read from system-wide configuration file
52
- if Oboe::Config.access_key.empty?
53
- config_file = '/etc/tracelytics.conf'
54
- return unless File.exists?(config_file)
45
+ if ENV.key?('TRACEVIEW_CUUID')
46
+ # Preferably get access key from environment (e.g. Heroku)
47
+ Oboe::Config[:access_key] = ENV['TRACEVIEW_CUUID']
48
+ Oboe::Config[:rum_id] = Oboe::Util::Base64URL.encode(Digest::SHA1.digest('RUM' + Oboe::Config[:access_key]))
49
+ else
50
+ # ..else read from system-wide configuration file
51
+ if Oboe::Config.access_key.empty?
52
+ config_file = '/etc/tracelytics.conf'
53
+ return unless File.exist?(config_file)
55
54
 
56
- File.open(config_file).each do |line|
57
- if line =~ /^tracelyzer.access_key=/ or line =~ /^access_key/
58
- bits = line.split(/=/)
59
- Oboe::Config[:access_key] = bits[1].strip
60
- Oboe::Config[:rum_id] = Oboe::Util::Base64URL.encode(Digest::SHA1.digest("RUM" + Oboe::Config[:access_key]))
61
- break
62
- end
55
+ File.open(config_file).each do |line|
56
+ if line =~ /^tracelyzer.access_key=/ || line =~ /^access_key/
57
+ bits = line.split(/=/)
58
+ Oboe::Config[:access_key] = bits[1].strip
59
+ Oboe::Config[:rum_id] = Oboe::Util::Base64URL.encode(Digest::SHA1.digest('RUM' + Oboe::Config[:access_key]))
60
+ break
63
61
  end
64
62
  end
65
63
  end
66
- rescue StandardError => e
67
- Oboe.logger.error "Trouble obtaining access_key and rum_id: #{e.inspect}"
68
64
  end
65
+ rescue StandardError => e
66
+ Oboe.logger.error "Trouble obtaining access_key and rum_id: #{e.inspect}"
69
67
  end
70
68
 
71
69
  ##
@@ -81,7 +79,7 @@ module Oboe
81
79
  begin
82
80
  Oboe::API.extend_with_tracing
83
81
  rescue LoadError => e
84
- Oboe.logger.fatal "[oboe/error] Couldn't load oboe api."
82
+ Oboe.logger.fatal "[oboe/error] Couldn't load oboe api: #{e.message}"
85
83
  end
86
84
  end
87
85
  end
@@ -91,8 +89,6 @@ Oboe::Loading.require_api
91
89
 
92
90
  # Auto-start the Reporter unless we running Unicorn on Heroku
93
91
  # In that case, we start the reporters after fork
94
- unless Oboe.heroku? and Oboe.forking_webserver?
95
- Oboe.logger.debug "[oboe/debug] starting Reporter from oboe gem"
92
+ unless Oboe.heroku? && Oboe.forking_webserver?
96
93
  Oboe::Reporter.start
97
94
  end
98
-
@@ -1,23 +1,37 @@
1
1
  # Copyright (c) 2013 AppNeta, Inc.
2
2
  # All rights reserved.
3
3
 
4
+ ##
5
+ # Provides the methods necessary for method profiling. Profiling
6
+ # results are sent to the TraceView dashboard.
7
+ #
8
+ # Example usage:
9
+ # class MyApp
10
+ # include OboeMethodProfiling
11
+ #
12
+ # def process_request()
13
+ # # The hard work
14
+ # end
15
+ #
16
+ # # call syntax: profile_method <method>, <profile_name>
17
+ # profile_method :process_request, 'request_processor'
18
+ # end
4
19
  module OboeMethodProfiling
5
- def self.included klass
20
+ def self.included(klass)
6
21
  klass.extend ClassMethods
7
22
  end
8
23
 
9
24
  module ClassMethods
10
- def profile_method(method_name, profile_name, store_args=false, store_return=false, profile=false)
25
+ def profile_method(method_name, profile_name, store_args = false, store_return = false, *_)
11
26
  begin
12
27
  # this only gets file and line where profiling is turned on, presumably
13
28
  # right after the function definition. ruby 1.9 and 2.0 has nice introspection (Method.source_location)
14
29
  # but its appears no such luck for ruby 1.8
15
- version = RbConfig::CONFIG['ruby_version']
16
30
  file = ''
17
31
  line = ''
18
- if version and (version.match(/^1.9/) or version.match(/^2.0/))
19
- info = self.instance_method(method_name).source_location
20
- if !info.nil?
32
+ if RUBY_VERSION >= '1.9'
33
+ info = instance_method(method_name).source_location
34
+ unless info.nil?
21
35
  file = info[0].to_s
22
36
  line = info[1].to_s
23
37
  end
@@ -54,7 +68,7 @@ module OboeMethodProfiling
54
68
  Oboe::API.log(nil, 'profile_exit', exit_kvs)
55
69
  ret
56
70
  end"
57
- rescue Exception => e
71
+ rescue => e
58
72
  Oboe.logger.warn "[oboe/warn] profile_method: #{e.inspect}"
59
73
  end
60
74
 
@@ -62,7 +76,7 @@ module OboeMethodProfiling
62
76
  class_eval code, __FILE__, __LINE__
63
77
  alias_method "_oboe_orig_#{method_name}", method_name
64
78
  alias_method method_name, "_oboe_profiled_#{method_name}"
65
- rescue Exception => e
79
+ rescue => e
66
80
  Oboe.logger.warn "[oboe/warn] Fatal error profiling method (#{method_name}): #{e.inspect}" if Oboe::Config[:verbose]
67
81
  end
68
82
  end
@@ -2,10 +2,30 @@
2
2
  # All rights reserved.
3
3
 
4
4
  module Oboe
5
+ ##
6
+ # This module provides a method to manually initialize the
7
+ # Ruby instrumentation. Normally this is done by detecting
8
+ # frameworks at load time and inserting initialization hooks.
5
9
  module Ruby
6
- def self.initialize
7
- Oboe::Loading.load_access_key
8
- Oboe::Inst.load_instrumentation
10
+ class << self
11
+ def initialize
12
+ load
13
+ end
14
+
15
+ ##
16
+ # The core method to load Ruby instrumentation. Call this
17
+ # from raw Ruby scripts or in Ruby applications where a
18
+ # supported framework isn't being used. Supported frameworks
19
+ # will instead be detected at load time and initialization is
20
+ # automatic.
21
+ def load
22
+ Oboe::Loading.load_access_key
23
+ Oboe::Inst.load_instrumentation
24
+ end
9
25
  end
10
26
  end
11
27
  end
28
+
29
+ if Oboe.loaded and !Oboe.framework?
30
+ ::Oboe::Ruby.load
31
+ end
@@ -0,0 +1,94 @@
1
+ # Copyright (c) 2014 AppNeta, Inc.
2
+ # All rights reserved.
3
+
4
+ module Oboe
5
+ ##
6
+ # This module is used to debug problematic setups and/or environments.
7
+ # Depending on the environment, output may be to stdout or the framework
8
+ # log file (e.g. log/production.log)
9
+
10
+ ##
11
+ # yesno
12
+ #
13
+ # Utility method to translate value/nil to "yes"/"no" strings
14
+ def self.yesno(x)
15
+ x ? "yes" : "no"
16
+ end
17
+
18
+ def self.support_report
19
+ Oboe.logger.warn "********************************************************"
20
+ Oboe.logger.warn "* BEGIN TraceView Support Report"
21
+ Oboe.logger.warn "* Please email the output of this report to traceviewsupport@appneta.com"
22
+ Oboe.logger.warn "********************************************************"
23
+ Oboe.logger.warn "Ruby: #{RUBY_DESCRIPTION}"
24
+ Oboe.logger.warn "$0: #{$0}"
25
+ Oboe.logger.warn "$1: #{$1}" unless $1.nil?
26
+ Oboe.logger.warn "$2: #{$2}" unless $2.nil?
27
+ Oboe.logger.warn "$3: #{$3}" unless $3.nil?
28
+ Oboe.logger.warn "$4: #{$4}" unless $4.nil?
29
+ Oboe.logger.warn "Oboe.loaded == #{Oboe.loaded}"
30
+
31
+ using_jruby = defined?(JRUBY_VERSION)
32
+ Oboe.logger.warn "Using JRuby?: #{yesno(using_jruby)}"
33
+ if using_jruby
34
+ Oboe.logger.warn "Joboe Agent Status: #{Java::ComTracelyticsAgent::Agent.getStatus}"
35
+ end
36
+
37
+ on_heroku = Oboe.heroku?
38
+ Oboe.logger.warn "On Heroku?: #{yesno(on_heroku)}"
39
+ if on_heroku
40
+ Oboe.logger.warn "TRACEVIEW_URL: #{ENV['TRACEVIEW_URL']}"
41
+ end
42
+
43
+ Oboe.logger.warn "Oboe::Ruby defined?: #{yesno(defined?(Oboe::Ruby))}"
44
+ Oboe.logger.warn "Oboe.reporter: #{Oboe.reporter}"
45
+
46
+ Oboe.logger.warn "********************************************************"
47
+ Oboe.logger.warn "* Frameworks"
48
+ Oboe.logger.warn "********************************************************"
49
+
50
+ using_rails = defined?(::Rails)
51
+ Oboe.logger.warn "Using Rails?: #{yesno(using_rails)}"
52
+ if using_rails
53
+ Oboe.logger.warn "Oboe::Rails loaded?: #{yesno(defined?(::Oboe::Rails))}"
54
+ end
55
+
56
+ using_sinatra = defined?(::Sinatra)
57
+ Oboe.logger.warn "Using Sinatra?: #{yesno(using_sinatra)}"
58
+
59
+ using_padrino = defined?(::Padrino)
60
+ Oboe.logger.warn "Using Padrino?: #{yesno(using_padrino)}"
61
+
62
+ using_grape = defined?(::Grape)
63
+ Oboe.logger.warn "Using Grape?: #{yesno(using_grape)}"
64
+
65
+ Oboe.logger.warn "********************************************************"
66
+ Oboe.logger.warn "* TraceView Libraries"
67
+ Oboe.logger.warn "********************************************************"
68
+ files = Dir.glob('/usr/lib/liboboe*')
69
+ if files.empty?
70
+ Oboe.logger.warn "Error: No liboboe libs!"
71
+ else
72
+ files.each { |f|
73
+ Oboe.logger.warn f
74
+ }
75
+ end
76
+
77
+ Oboe.logger.warn "********************************************************"
78
+ Oboe.logger.warn "* Raw __Init KVs"
79
+ Oboe.logger.warn "********************************************************"
80
+ platform_info = Oboe::Util.build_report
81
+ platform_info.each { |k,v|
82
+ Oboe.logger.warn "#{k}: #{v}"
83
+ }
84
+
85
+ Oboe.logger.warn "********************************************************"
86
+ Oboe.logger.warn "* END TraceView Support Report"
87
+ Oboe.logger.warn "* Support Email: traceviewsupport@appneta.com"
88
+ Oboe.logger.warn "* Support Portal: https://support.tv.appneta.com"
89
+ Oboe.logger.warn "* Freenode IRC: #appneta"
90
+ Oboe.logger.warn "* Github: https://github.com/appneta/oboe-ruby"
91
+ Oboe.logger.warn "********************************************************"
92
+ nil
93
+ end
94
+ end