oboe 2.7.1.7-java → 2.7.2.2-java
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.
- checksums.yaml +4 -4
- data/.rubocop.yml +5 -0
- data/Gemfile +2 -0
- data/README.md +3 -3
- data/ext/oboe_metal/extconf.rb +11 -11
- data/lib/joboe_metal.rb +36 -42
- data/lib/oboe.rb +29 -27
- data/lib/oboe/api.rb +4 -0
- data/lib/oboe/api/layerinit.rb +9 -6
- data/lib/oboe/api/logging.rb +50 -28
- data/lib/oboe/api/memcache.rb +7 -5
- data/lib/oboe/api/profiling.rb +4 -4
- data/lib/oboe/api/tracing.rb +6 -5
- data/lib/oboe/api/util.rb +13 -9
- data/lib/oboe/base.rb +50 -15
- data/lib/oboe/config.rb +17 -15
- data/lib/oboe/frameworks/padrino.rb +0 -2
- data/lib/oboe/frameworks/padrino/templates.rb +5 -6
- data/lib/oboe/frameworks/rails.rb +0 -1
- data/lib/oboe/frameworks/rails/inst/action_controller.rb +4 -5
- data/lib/oboe/frameworks/rails/inst/action_view.rb +4 -4
- data/lib/oboe/frameworks/rails/inst/action_view_2x.rb +4 -4
- data/lib/oboe/frameworks/rails/inst/action_view_30.rb +2 -2
- data/lib/oboe/frameworks/rails/inst/active_record.rb +5 -5
- data/lib/oboe/frameworks/rails/inst/connection_adapters/mysql.rb +6 -6
- data/lib/oboe/frameworks/rails/inst/connection_adapters/mysql2.rb +3 -3
- data/lib/oboe/frameworks/rails/inst/connection_adapters/oracle.rb +1 -1
- data/lib/oboe/frameworks/rails/inst/connection_adapters/postgresql.rb +3 -3
- data/lib/oboe/frameworks/rails/inst/connection_adapters/utils.rb +18 -19
- data/lib/oboe/frameworks/sinatra.rb +4 -5
- data/lib/oboe/inst/cassandra.rb +17 -19
- data/lib/oboe/inst/dalli.rb +5 -5
- data/lib/oboe/inst/em-http-request.rb +13 -13
- data/lib/oboe/inst/faraday.rb +71 -0
- data/lib/oboe/inst/http.rb +4 -4
- data/lib/oboe/inst/memcache.rb +7 -10
- data/lib/oboe/inst/memcached.rb +7 -9
- data/lib/oboe/inst/mongo.rb +26 -28
- data/lib/oboe/inst/moped.rb +23 -24
- data/lib/oboe/inst/rack.rb +10 -11
- data/lib/oboe/inst/redis.rb +18 -20
- data/lib/oboe/inst/resque.rb +8 -9
- data/lib/oboe/instrumentation.rb +3 -0
- data/lib/oboe/loading.rb +19 -23
- data/lib/{method_profiling.rb → oboe/method_profiling.rb} +22 -8
- data/lib/oboe/ruby.rb +23 -3
- data/lib/oboe/thread_local.rb +9 -1
- data/lib/oboe/util.rb +15 -19
- data/lib/oboe/version.rb +5 -2
- data/lib/oboe/xtrace.rb +20 -24
- data/lib/oboe_metal.rb +16 -13
- data/lib/rails/generators/oboe/templates/oboe_initializer.rb +2 -0
- data/test/instrumentation/faraday_test.rb +142 -0
- data/test/instrumentation/moped_test.rb +2 -0
- data/test/minitest_helper.rb +0 -1
- data/test/support/config_test.rb +3 -1
- metadata +7 -3
data/lib/oboe/inst/rack.rb
CHANGED
@@ -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.
|
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.
|
31
|
-
report_kvs['Request-Start'] = env['HTTP_X_QUEUE_START'] if env.
|
32
|
-
report_kvs['Queue-Time'] = env['HTTP_X_QUEUE_TIME'] if env.
|
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.
|
35
|
-
report_kvs['Forwarded-Host'] = env['HTTP_X_FORWARDED_HOST'] if env.
|
36
|
-
report_kvs['Forwarded-Proto'] = env['HTTP_X_FORWARDED_PROTO'] if env.
|
37
|
-
report_kvs['Forwarded-Port'] = env['HTTP_X_FORWARDED_PORT'] if env.
|
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!(
|
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
|
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
|
-
|
data/lib/oboe/inst/redis.rb
CHANGED
@@ -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 = [
|
10
|
-
|
11
|
-
|
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?
|
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.
|
102
|
-
kvs[:px] = options[:px] if options.
|
103
|
-
kvs[:nx] = options[:nx] if options.
|
104
|
-
kvs[:xx] = options[:xx] if options.
|
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] +
|
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] ==
|
126
|
+
if command[1] == 'load'
|
127
127
|
if command[1].length > 1024
|
128
|
-
kvs[:Script] = command[2][0..1023] +
|
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(
|
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)
|
269
|
-
Oboe.logger.info
|
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
|
data/lib/oboe/inst/resque.rb
CHANGED
@@ -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(
|
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?
|
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(
|
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)
|
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
|
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
|
-
[
|
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
|
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
|
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
|
data/lib/oboe/instrumentation.rb
CHANGED
data/lib/oboe/loading.rb
CHANGED
@@ -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
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
else
|
51
|
-
|
52
|
-
|
53
|
-
|
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
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
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?
|
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
|
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,
|
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
|
19
|
-
info =
|
20
|
-
|
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
|
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
|
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
|
data/lib/oboe/ruby.rb
CHANGED
@@ -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
|
-
|
7
|
-
|
8
|
-
|
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
|
data/lib/oboe/thread_local.rb
CHANGED
@@ -2,6 +2,14 @@
|
|
2
2
|
# All rights reserved.
|
3
3
|
|
4
4
|
module Oboe
|
5
|
+
##
|
6
|
+
# Provides thread local storage for Oboe.
|
7
|
+
#
|
8
|
+
# Example usage:
|
9
|
+
# module OboeBase
|
10
|
+
# extend ::Oboe::ThreadLocal
|
11
|
+
# thread_local :layer_op
|
12
|
+
# end
|
5
13
|
module ThreadLocal
|
6
14
|
def thread_local(name)
|
7
15
|
key = "__#{self}_#{name}__".intern
|
@@ -10,7 +18,7 @@ module Oboe
|
|
10
18
|
Thread.current[key]
|
11
19
|
end
|
12
20
|
|
13
|
-
define_method(name.to_s +
|
21
|
+
define_method(name.to_s + '=') do |value|
|
14
22
|
Thread.current[key] = value
|
15
23
|
end
|
16
24
|
end
|
data/lib/oboe/util.rb
CHANGED
@@ -2,6 +2,9 @@
|
|
2
2
|
# All rights reserved.
|
3
3
|
|
4
4
|
module Oboe
|
5
|
+
##
|
6
|
+
# Provides utility methods for use while in the business
|
7
|
+
# of instrumenting code
|
5
8
|
module Util
|
6
9
|
class << self
|
7
10
|
def contextual_name(cls)
|
@@ -11,10 +14,9 @@ module Oboe
|
|
11
14
|
# ::ActiveRecord::ConnectionAdapters::AbstractMysqlAdapter.to_s.split(/::/).last
|
12
15
|
# => "AbstractMysqlAdapter"
|
13
16
|
#
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
end
|
17
|
+
cls.to_s.split(/::/).last
|
18
|
+
rescue
|
19
|
+
cls
|
18
20
|
end
|
19
21
|
|
20
22
|
##
|
@@ -23,10 +25,10 @@ module Oboe
|
|
23
25
|
# Centralized utility method to alias a method on an arbitrary
|
24
26
|
# class or module.
|
25
27
|
#
|
26
|
-
def method_alias(cls, method, name=nil)
|
28
|
+
def method_alias(cls, method, name = nil)
|
27
29
|
name ||= contextual_name(cls)
|
28
30
|
|
29
|
-
if cls.method_defined?
|
31
|
+
if cls.method_defined?(method.to_sym) || cls.private_method_defined?(method.to_sym)
|
30
32
|
|
31
33
|
# Strip '!' or '?' from method if present
|
32
34
|
safe_method_name = method.to_s.chop if method.to_s =~ /\?$|\!$/
|
@@ -36,8 +38,8 @@ module Oboe
|
|
36
38
|
with_oboe = "#{safe_method_name}_with_oboe"
|
37
39
|
|
38
40
|
# Only alias if we haven't done so already
|
39
|
-
unless cls.method_defined?
|
40
|
-
cls.private_method_defined?
|
41
|
+
unless cls.method_defined?(without_oboe.to_sym) ||
|
42
|
+
cls.private_method_defined?(without_oboe.to_sym)
|
41
43
|
|
42
44
|
cls.class_eval do
|
43
45
|
alias_method without_oboe, "#{method}"
|
@@ -54,7 +56,7 @@ module Oboe
|
|
54
56
|
# Centralized utility method to alias a class method on an arbitrary
|
55
57
|
# class or module
|
56
58
|
#
|
57
|
-
def class_method_alias(cls, method, name=nil)
|
59
|
+
def class_method_alias(cls, method, name = nil)
|
58
60
|
name ||= contextual_name(cls)
|
59
61
|
|
60
62
|
if cls.singleton_methods.include? method.to_sym
|
@@ -81,9 +83,7 @@ module Oboe
|
|
81
83
|
# Centralized utility method to send an extend call for an
|
82
84
|
# arbitrary class
|
83
85
|
def send_extend(target_cls, cls)
|
84
|
-
if defined?(target_cls)
|
85
|
-
target_cls.send(:extend, cls)
|
86
|
-
end
|
86
|
+
target_cls.send(:extend, cls) if defined?(target_cls)
|
87
87
|
end
|
88
88
|
|
89
89
|
##
|
@@ -92,9 +92,7 @@ module Oboe
|
|
92
92
|
# Centralized utility method to send a include call for an
|
93
93
|
# arbitrary class
|
94
94
|
def send_include(target_cls, cls)
|
95
|
-
if defined?(target_cls)
|
96
|
-
target_cls.send(:include, cls)
|
97
|
-
end
|
95
|
+
target_cls.send(:include, cls) if defined?(target_cls)
|
98
96
|
end
|
99
97
|
|
100
98
|
##
|
@@ -104,7 +102,7 @@ module Oboe
|
|
104
102
|
# solely on filename)
|
105
103
|
#
|
106
104
|
def static_asset?(path)
|
107
|
-
|
105
|
+
(path =~ /\.(jpg|jpeg|gif|png|ico|css|zip|tgz|gz|rar|bz2|pdf|txt|tar|wav|bmp|rtf|js|flv|swf|ttf|woff|svg|less)$/i)
|
108
106
|
end
|
109
107
|
|
110
108
|
##
|
@@ -112,7 +110,7 @@ module Oboe
|
|
112
110
|
#
|
113
111
|
# Even to my surprise, 'prettify' is a real word:
|
114
112
|
# transitive v. To make pretty or prettier, especially in a superficial or insubstantial way.
|
115
|
-
# from The American Heritage
|
113
|
+
# from The American Heritage Dictionary of the English Language, 4th Edition
|
116
114
|
#
|
117
115
|
# This method makes things 'purty' for reporting.
|
118
116
|
def prettify(x)
|
@@ -122,8 +120,6 @@ module Oboe
|
|
122
120
|
x.to_s
|
123
121
|
end
|
124
122
|
end
|
125
|
-
|
126
123
|
end
|
127
124
|
end
|
128
125
|
end
|
129
|
-
|