oboe 1.3.9.1 → 1.4.0.2
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.
- data/lib/joboe_metal.rb +0 -35
- data/lib/oboe/api/logging.rb +3 -3
- data/lib/oboe/api/memcache.rb +1 -1
- data/lib/oboe/api/tracing.rb +1 -1
- data/lib/oboe/config.rb +102 -27
- data/lib/oboe/frameworks/rails.rb +13 -13
- data/lib/oboe/frameworks/rails/inst/action_controller.rb +18 -9
- data/lib/oboe/frameworks/rails/inst/action_view.rb +4 -3
- data/lib/oboe/frameworks/rails/inst/active_record.rb +60 -56
- data/lib/oboe/inst/cassandra.rb +20 -19
- data/lib/oboe/inst/dalli.rb +37 -3
- data/lib/oboe/inst/http.rb +1 -1
- data/lib/oboe/inst/memcache.rb +96 -27
- data/lib/oboe/inst/memcached.rb +78 -19
- data/lib/oboe/inst/mongo.rb +157 -160
- data/lib/oboe/inst/moped.rb +294 -292
- data/lib/oboe/inst/resque.rb +192 -0
- data/lib/oboe/loading.rb +1 -1
- data/lib/oboe/version.rb +3 -3
- data/lib/oboe_metal.rb +0 -39
- data/lib/rails/generators/oboe/templates/oboe_initializer.rb +32 -0
- metadata +7 -6
data/lib/oboe/inst/cassandra.rb
CHANGED
@@ -43,7 +43,7 @@ module Oboe
|
|
43
43
|
end
|
44
44
|
|
45
45
|
def insert_with_oboe(column_family, key, hash, options = {})
|
46
|
-
if Oboe
|
46
|
+
if Oboe.tracing?
|
47
47
|
report_kvs = extract_trace_details(:insert, column_family, key, hash, options)
|
48
48
|
|
49
49
|
Oboe::API.trace('cassandra', report_kvs) do
|
@@ -57,7 +57,7 @@ module Oboe
|
|
57
57
|
def remove_with_oboe(column_family, key, *columns_and_options)
|
58
58
|
args = [column_family, key] + columns_and_options
|
59
59
|
|
60
|
-
if Oboe
|
60
|
+
if Oboe.tracing?
|
61
61
|
report_kvs = extract_trace_details(:remove, column_family, key, columns_and_options)
|
62
62
|
|
63
63
|
Oboe::API.trace('cassandra', report_kvs) do
|
@@ -71,7 +71,7 @@ module Oboe
|
|
71
71
|
def count_columns_with_oboe(column_family, key, *columns_and_options)
|
72
72
|
args = [column_family, key] + columns_and_options
|
73
73
|
|
74
|
-
if Oboe
|
74
|
+
if Oboe.tracing?
|
75
75
|
report_kvs = extract_trace_details(:count_columns, column_family, key, columns_and_options)
|
76
76
|
|
77
77
|
Oboe::API.trace('cassandra', report_kvs) do
|
@@ -85,7 +85,7 @@ module Oboe
|
|
85
85
|
def get_columns_with_oboe(column_family, key, *columns_and_options)
|
86
86
|
args = [column_family, key] + columns_and_options
|
87
87
|
|
88
|
-
if Oboe
|
88
|
+
if Oboe.tracing? and not Oboe::Context.tracing_layer_op?(:multi_get_columns)
|
89
89
|
report_kvs = extract_trace_details(:get_columns, column_family, key, columns_and_options)
|
90
90
|
|
91
91
|
Oboe::API.trace('cassandra', report_kvs) do
|
@@ -99,7 +99,7 @@ module Oboe
|
|
99
99
|
def multi_get_columns_with_oboe(column_family, key, *columns_and_options)
|
100
100
|
args = [column_family, key] + columns_and_options
|
101
101
|
|
102
|
-
if Oboe
|
102
|
+
if Oboe.tracing?
|
103
103
|
report_kvs = extract_trace_details(:multi_get_columns, column_family, key, columns_and_options)
|
104
104
|
|
105
105
|
Oboe::API.trace('cassandra', report_kvs, :multi_get_columns) do
|
@@ -113,7 +113,7 @@ module Oboe
|
|
113
113
|
def get_with_oboe(column_family, key, *columns_and_options)
|
114
114
|
args = [column_family, key] + columns_and_options
|
115
115
|
|
116
|
-
if Oboe
|
116
|
+
if Oboe.tracing?
|
117
117
|
report_kvs = extract_trace_details(:get, column_family, key, columns_and_options)
|
118
118
|
|
119
119
|
Oboe::API.trace('cassandra', report_kvs, :get) do
|
@@ -127,7 +127,7 @@ module Oboe
|
|
127
127
|
def multi_get_with_oboe(column_family, key, *columns_and_options)
|
128
128
|
args = [column_family, key] + columns_and_options
|
129
129
|
|
130
|
-
if Oboe
|
130
|
+
if Oboe.tracing? and not Oboe::Context.tracing_layer_op?(:get)
|
131
131
|
report_kvs = extract_trace_details(:multi_get, column_family, key, columns_and_options)
|
132
132
|
|
133
133
|
Oboe::API.trace('cassandra', report_kvs) do
|
@@ -141,7 +141,7 @@ module Oboe
|
|
141
141
|
def exists_with_oboe?(column_family, key, *columns_and_options)
|
142
142
|
args = [column_family, key] + columns_and_options
|
143
143
|
|
144
|
-
if Oboe
|
144
|
+
if Oboe.tracing?
|
145
145
|
report_kvs = extract_trace_details(:exists?, column_family, key, columns_and_options)
|
146
146
|
|
147
147
|
Oboe::API.trace('cassandra', report_kvs) do
|
@@ -153,7 +153,7 @@ module Oboe
|
|
153
153
|
end
|
154
154
|
|
155
155
|
def get_range_single_with_oboe(column_family, options = {})
|
156
|
-
if Oboe
|
156
|
+
if Oboe.tracing? and not Oboe::Context.tracing_layer_op?(:get_range_batch)
|
157
157
|
report_kvs = extract_trace_details(:get_range_single, column_family, nil, nil)
|
158
158
|
args = [column_family, options]
|
159
159
|
|
@@ -166,7 +166,7 @@ module Oboe
|
|
166
166
|
end
|
167
167
|
|
168
168
|
def get_range_batch_with_oboe(column_family, options = {})
|
169
|
-
if Oboe
|
169
|
+
if Oboe.tracing?
|
170
170
|
report_kvs = extract_trace_details(:get_range_batch, column_family, nil, nil)
|
171
171
|
args = [column_family, options]
|
172
172
|
|
@@ -181,7 +181,7 @@ module Oboe
|
|
181
181
|
def get_indexed_slices_with_oboe(column_family, index_clause, *columns_and_options)
|
182
182
|
args = [column_family, index_clause] + columns_and_options
|
183
183
|
|
184
|
-
if Oboe
|
184
|
+
if Oboe.tracing?
|
185
185
|
report_kvs = extract_trace_details(:get_indexed_slices, column_family, nil, columns_and_options)
|
186
186
|
|
187
187
|
Oboe::API.trace('cassandra', report_kvs) do
|
@@ -193,7 +193,7 @@ module Oboe
|
|
193
193
|
end
|
194
194
|
|
195
195
|
def create_index_with_oboe(keyspace, column_family, column_name, validation_class)
|
196
|
-
if Oboe
|
196
|
+
if Oboe.tracing?
|
197
197
|
report_kvs = extract_trace_details(:create_index, column_family, nil, nil)
|
198
198
|
begin
|
199
199
|
report_kvs[:Keyspace] = keyspace.to_s
|
@@ -211,7 +211,7 @@ module Oboe
|
|
211
211
|
end
|
212
212
|
|
213
213
|
def drop_index_with_oboe(keyspace, column_family, column_name)
|
214
|
-
if Oboe
|
214
|
+
if Oboe.tracing?
|
215
215
|
report_kvs = extract_trace_details(:drop_index, column_family, nil, nil)
|
216
216
|
begin
|
217
217
|
report_kvs[:Keyspace] = keyspace.to_s
|
@@ -228,7 +228,7 @@ module Oboe
|
|
228
228
|
end
|
229
229
|
|
230
230
|
def add_column_family_with_oboe(cf_def)
|
231
|
-
if Oboe
|
231
|
+
if Oboe.tracing?
|
232
232
|
report_kvs = extract_trace_details(:add_column_family, nil, nil, nil)
|
233
233
|
begin
|
234
234
|
report_kvs[:Cf] = cf_def[:name] if cf_def.is_a?(Hash) and cf_def.has_key?(:name)
|
@@ -244,7 +244,7 @@ module Oboe
|
|
244
244
|
end
|
245
245
|
|
246
246
|
def drop_column_family_with_oboe(column_family)
|
247
|
-
if Oboe
|
247
|
+
if Oboe.tracing?
|
248
248
|
report_kvs = extract_trace_details(:drop_column_family, column_family, nil, nil)
|
249
249
|
|
250
250
|
Oboe::API.trace('cassandra', report_kvs) do
|
@@ -256,7 +256,7 @@ module Oboe
|
|
256
256
|
end
|
257
257
|
|
258
258
|
def add_keyspace_with_oboe(ks_def)
|
259
|
-
if Oboe
|
259
|
+
if Oboe.tracing?
|
260
260
|
report_kvs = extract_trace_details(:add_keyspace, nil, nil, nil)
|
261
261
|
report_kvs[:Name] = ks_def.name rescue ""
|
262
262
|
|
@@ -269,7 +269,7 @@ module Oboe
|
|
269
269
|
end
|
270
270
|
|
271
271
|
def drop_keyspace_with_oboe(keyspace)
|
272
|
-
if Oboe
|
272
|
+
if Oboe.tracing?
|
273
273
|
report_kvs = extract_trace_details(:drop_keyspace, nil, nil, nil)
|
274
274
|
report_kvs[:Name] = keyspace.to_s rescue ""
|
275
275
|
|
@@ -284,8 +284,9 @@ module Oboe
|
|
284
284
|
end
|
285
285
|
end
|
286
286
|
|
287
|
-
if defined?(::Cassandra)
|
288
|
-
puts "[oboe/loading] Instrumenting cassandra"
|
287
|
+
if defined?(::Cassandra) and Oboe::Config[:cassandra][:enabled]
|
288
|
+
puts "[oboe/loading] Instrumenting cassandra" if Oboe::Config[:verbose]
|
289
|
+
|
289
290
|
class ::Cassandra
|
290
291
|
include Oboe::Inst::Cassandra
|
291
292
|
|
data/lib/oboe/inst/dalli.rb
CHANGED
@@ -14,11 +14,16 @@ module Oboe
|
|
14
14
|
alias perform perform_with_oboe
|
15
15
|
else puts "[oboe/loading] Couldn't properly instrument Memcache (Dalli). Partial traces may occur."
|
16
16
|
end
|
17
|
+
|
18
|
+
if ::Dalli::Client.method_defined? :get_multi
|
19
|
+
alias get_multi_without_oboe get_multi
|
20
|
+
alias get_multi get_multi_with_oboe
|
21
|
+
end
|
17
22
|
end
|
18
23
|
end
|
19
24
|
|
20
25
|
def perform_with_oboe(op, key, *args)
|
21
|
-
if Oboe
|
26
|
+
if Oboe.tracing? and not Oboe::Context.tracing_layer_op?(:get_multi)
|
22
27
|
opts = {}
|
23
28
|
opts[:KVOp] = op
|
24
29
|
opts[:KVKey] = key
|
@@ -34,12 +39,41 @@ module Oboe
|
|
34
39
|
perform_without_oboe(op, key, *args)
|
35
40
|
end
|
36
41
|
end
|
42
|
+
|
43
|
+
def get_multi_with_oboe(*keys)
|
44
|
+
if Oboe.tracing?
|
45
|
+
layer_kvs = {}
|
46
|
+
layer_kvs[:KVOp] = :get_multi
|
47
|
+
|
48
|
+
Oboe::API.trace('memcache', layer_kvs || {}, :get_multi) do
|
49
|
+
begin
|
50
|
+
info_kvs = {}
|
51
|
+
|
52
|
+
if keys.last.is_a?(Hash) || keys.last.nil?
|
53
|
+
info_kvs[:KVKeyCount] = keys.flatten.length - 1
|
54
|
+
else
|
55
|
+
info_kvs[:KVKeyCount] = keys.flatten.length
|
56
|
+
end
|
57
|
+
|
58
|
+
values = get_multi_without_oboe(keys)
|
59
|
+
|
60
|
+
info_kvs[:KVHitCount] = values.length
|
61
|
+
Oboe::API.log('memcache', 'info', info_kvs)
|
62
|
+
rescue
|
63
|
+
values = get_multi_without_oboe(keys)
|
64
|
+
end
|
65
|
+
values
|
66
|
+
end
|
67
|
+
else
|
68
|
+
get_multi_without_oboe(keys)
|
69
|
+
end
|
70
|
+
end
|
37
71
|
end
|
38
72
|
end
|
39
73
|
end
|
40
74
|
|
41
|
-
if defined?(Dalli)
|
42
|
-
Dalli::Client.module_eval do
|
75
|
+
if defined?(Dalli) and Oboe::Config[:dalli][:enabled]
|
76
|
+
::Dalli::Client.module_eval do
|
43
77
|
include Oboe::Inst::Dalli
|
44
78
|
end
|
45
79
|
end
|
data/lib/oboe/inst/http.rb
CHANGED
@@ -27,7 +27,7 @@ Net::HTTP.class_eval do
|
|
27
27
|
resp = request_without_oboe(*args, &block)
|
28
28
|
|
29
29
|
xtrace = resp.get_fields('X-Trace')
|
30
|
-
if xtrace and xtrace.size and Oboe
|
30
|
+
if xtrace and xtrace.size and Oboe.tracing?
|
31
31
|
Oboe::Context.fromString(xtrace[0])
|
32
32
|
end
|
33
33
|
next resp
|
data/lib/oboe/inst/memcache.rb
CHANGED
@@ -1,40 +1,109 @@
|
|
1
1
|
# Copyright (c) 2012 by Tracelytics, Inc.
|
2
2
|
# All rights reserved.
|
3
3
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
4
|
+
module Oboe
|
5
|
+
module Inst
|
6
|
+
module MemCache
|
7
|
+
include Oboe::API::Memcache
|
8
|
+
|
9
|
+
def self.included(cls)
|
10
|
+
puts "[oboe/loading] Instrumenting memcache" if Oboe::Config[:verbose]
|
11
|
+
|
12
|
+
cls.class_eval do
|
13
|
+
MEMCACHE_OPS.reject { |m| not method_defined?(m) }.each do |m|
|
14
|
+
|
15
|
+
define_method("#{m}_with_oboe") do |*args|
|
16
|
+
report_kvs = { :KVOp => m }
|
17
|
+
|
18
|
+
if Oboe.tracing?
|
19
|
+
Oboe::API.trace('memcache', report_kvs) do
|
20
|
+
result = send("#{m}_without_oboe", *args)
|
21
|
+
end
|
22
|
+
else
|
23
|
+
result = send("#{m}_without_oboe", *args)
|
24
|
+
end
|
25
|
+
result
|
26
|
+
end
|
27
|
+
|
28
|
+
class_eval "alias #{m}_without_oboe #{m}"
|
29
|
+
class_eval "alias #{m} #{m}_with_oboe"
|
30
|
+
end
|
31
|
+
|
32
|
+
if ::MemCache.method_defined? :request_setup
|
33
|
+
alias request_setup_without_oboe request_setup
|
34
|
+
alias request_setup request_setup_with_oboe
|
35
|
+
elsif Oboe::Config[:verbose]
|
36
|
+
puts "[oboe/loading] Couldn't properly instrument Memcache. Partial traces may occur."
|
37
|
+
end
|
38
|
+
|
39
|
+
if ::MemCache.method_defined? :cache_get
|
40
|
+
alias cache_get_without_oboe cache_get
|
41
|
+
alias cache_get cache_get_with_oboe
|
42
|
+
elsif Oboe::Config[:verbose]
|
43
|
+
puts "[oboe/loading] Couldn't properly instrument Memcache. Partial traces may occur."
|
44
|
+
end
|
45
|
+
|
46
|
+
if ::MemCache.method_defined? :get_multi
|
47
|
+
alias get_multi_without_oboe get_multi
|
48
|
+
alias get_multi get_multi_with_oboe
|
49
|
+
elsif Oboe::Config[:verbose]
|
50
|
+
puts "[oboe/loading] Couldn't properly instrument Memcache. Partial traces may occur."
|
51
|
+
end
|
13
52
|
end
|
14
53
|
end
|
15
54
|
|
16
|
-
|
17
|
-
|
18
|
-
|
55
|
+
def get_multi_with_oboe(*args)
|
56
|
+
if Oboe.tracing?
|
57
|
+
layer_kvs = {}
|
58
|
+
layer_kvs[:KVOp] = :get_multi
|
19
59
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
60
|
+
Oboe::API.trace('memcache', layer_kvs || {}, :get_multi) do
|
61
|
+
begin
|
62
|
+
info_kvs = {}
|
63
|
+
|
64
|
+
if args.last.is_a?(Hash) || args.last.nil?
|
65
|
+
info_kvs[:KVKeyCount] = args.flatten.length - 1
|
66
|
+
else
|
67
|
+
info_kvs[:KVKeyCount] = args.flatten.length
|
68
|
+
end
|
25
69
|
|
26
|
-
|
27
|
-
|
70
|
+
values = get_multi_without_oboe(args)
|
71
|
+
|
72
|
+
info_kvs[:KVHitCount] = values.length
|
73
|
+
Oboe::API.log('memcache', 'info', info_kvs)
|
74
|
+
rescue
|
75
|
+
values = get_multi_without_oboe(args)
|
76
|
+
end
|
77
|
+
values
|
78
|
+
end
|
79
|
+
else
|
80
|
+
get_multi_without_oboe(args)
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
def request_setup_with_oboe(*args)
|
85
|
+
if Oboe.tracing? and not Oboe::Context.tracing_layer_op?(:get_multi)
|
86
|
+
server, cache_key = request_setup_without_oboe(*args)
|
87
|
+
Oboe::API.log('memcache', 'info', { :KVKey => cache_key, :RemoteHost => server.host })
|
88
|
+
else
|
89
|
+
server, cache_key = request_setup_without_oboe(*args)
|
90
|
+
end
|
91
|
+
return [server, cache_key]
|
92
|
+
end
|
28
93
|
|
94
|
+
def cache_get_with_oboe(server, cache_key)
|
95
|
+
result = cache_get_without_oboe(server, cache_key)
|
96
|
+
Oboe::API.log('memcache', 'info', { :KVHit => memcache_hit?(result) })
|
97
|
+
result
|
98
|
+
end
|
29
99
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
result
|
34
|
-
end
|
100
|
+
end # module MemCache
|
101
|
+
end # module Inst
|
102
|
+
end # module Oboe
|
35
103
|
|
36
|
-
|
37
|
-
|
104
|
+
if defined?(::MemCache) and Oboe::Config[:memcache][:enabled]
|
105
|
+
::MemCache.class_eval do
|
106
|
+
include Oboe::Inst::MemCache
|
38
107
|
end
|
39
|
-
puts "[oboe/loading] Instrumenting memcache" if Oboe::Config[:verbose]
|
40
108
|
end
|
109
|
+
|
data/lib/oboe/inst/memcached.rb
CHANGED
@@ -2,31 +2,90 @@
|
|
2
2
|
# All rights reserved.
|
3
3
|
#
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
5
|
+
module Oboe
|
6
|
+
module Inst
|
7
|
+
module Memcached
|
8
|
+
include Oboe::API::Memcache
|
9
|
+
|
10
|
+
def self.included(cls)
|
11
|
+
puts "[oboe/loading] Instrumenting memcached" if Oboe::Config[:verbose]
|
12
|
+
|
13
|
+
cls.class_eval do
|
14
|
+
MEMCACHE_OPS.reject { |m| not method_defined?(m) }.each do |m|
|
15
|
+
define_method("#{m}_with_oboe") do |*args|
|
16
|
+
opts = { :KVOp => m }
|
17
|
+
if args.length and args[0].class != Array
|
18
|
+
opts[:KVKey] = args[0].to_s
|
19
|
+
rhost = remote_host(args[0].to_s)
|
20
|
+
opts[:RemoteHost] = rhost if rhost
|
21
|
+
end
|
22
|
+
|
23
|
+
Oboe::API.trace('memcache', opts) do
|
24
|
+
result = send("#{m}_without_oboe", *args)
|
25
|
+
if m == :get and args.length and args[0].class == String
|
26
|
+
Oboe::API.log('memcache', 'info', { :KVHit => memcache_hit?(result) })
|
27
|
+
end
|
28
|
+
result
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
class_eval "alias #{m}_without_oboe #{m}"
|
33
|
+
class_eval "alias #{m} #{m}_with_oboe"
|
34
|
+
end
|
16
35
|
end
|
36
|
+
end
|
37
|
+
|
38
|
+
end # module Memcached
|
17
39
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
40
|
+
module MemcachedRails
|
41
|
+
def self.included(cls)
|
42
|
+
cls.class_eval do
|
43
|
+
if ::Memcached::Rails.method_defined? :get_multi
|
44
|
+
alias get_multi_without_oboe get_multi
|
45
|
+
alias get_multi get_multi_with_oboe
|
46
|
+
elsif Oboe::Config[:verbose]
|
47
|
+
puts "[oboe/loading] Couldn't properly instrument Memcached. Partial traces may occur."
|
22
48
|
end
|
23
|
-
result
|
24
49
|
end
|
25
50
|
end
|
26
51
|
|
27
|
-
|
28
|
-
|
52
|
+
def get_multi_with_oboe(keys, raw=false)
|
53
|
+
if Oboe.tracing?
|
54
|
+
layer_kvs = {}
|
55
|
+
layer_kvs[:KVOp] = :get_multi
|
56
|
+
|
57
|
+
Oboe::API.trace('memcache', layer_kvs || {}, :get_multi) do
|
58
|
+
begin
|
59
|
+
info_kvs = {}
|
60
|
+
info_kvs[:KVKeyCount] = keys.flatten.length
|
61
|
+
|
62
|
+
values = get_multi_without_oboe(keys, raw)
|
63
|
+
|
64
|
+
info_kvs[:KVHitCount] = values.length
|
65
|
+
Oboe::API.log('memcache', 'info', info_kvs)
|
66
|
+
rescue
|
67
|
+
values = get_multi_without_oboe(keys, raw)
|
68
|
+
end
|
69
|
+
values
|
70
|
+
end
|
71
|
+
else
|
72
|
+
get_multi_without_oboe(keys, raw)
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
end # module MemcachedRails
|
77
|
+
end # module Inst
|
78
|
+
end # module Oboe
|
79
|
+
|
80
|
+
if defined?(::Memcached) and Oboe::Config[:memcached][:enabled]
|
81
|
+
::Memcached.class_eval do
|
82
|
+
include Oboe::Inst::Memcached
|
83
|
+
end
|
84
|
+
|
85
|
+
if defined?(::Memcached::Rails)
|
86
|
+
::Memcached::Rails.class_eval do
|
87
|
+
include Oboe::Inst::MemcachedRails
|
29
88
|
end
|
30
89
|
end
|
31
|
-
puts "[oboe/loading] Instrumenting memcached" if Oboe::Config[:verbose]
|
32
90
|
end
|
91
|
+
|