oboe 1.3.9.1 → 1.4.0.2
Sign up to get free protection for your applications and to get access to all the features.
- 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/mongo.rb
CHANGED
@@ -20,210 +20,207 @@ module Oboe
|
|
20
20
|
end
|
21
21
|
end
|
22
22
|
|
23
|
-
if defined?(::Mongo::
|
24
|
-
|
25
|
-
class DB
|
26
|
-
include Oboe::Inst::Mongo
|
27
|
-
|
28
|
-
# Instrument DB operations
|
29
|
-
Oboe::Inst::Mongo::DB_OPS.reject { |m| not method_defined?(m) }.each do |m|
|
30
|
-
define_method("#{m}_with_oboe") do |*args|
|
31
|
-
report_kvs = {}
|
23
|
+
if defined?(::Mongo) and Oboe::Config[:mongo][:enabled]
|
24
|
+
puts "[oboe/loading] Instrumenting mongo" if Oboe::Config[:verbose]
|
32
25
|
|
33
|
-
|
34
|
-
|
26
|
+
if defined?(::Mongo::DB)
|
27
|
+
module ::Mongo
|
28
|
+
class DB
|
29
|
+
include Oboe::Inst::Mongo
|
30
|
+
|
31
|
+
# Instrument DB operations
|
32
|
+
Oboe::Inst::Mongo::DB_OPS.reject { |m| not method_defined?(m) }.each do |m|
|
33
|
+
define_method("#{m}_with_oboe") do |*args|
|
34
|
+
report_kvs = {}
|
35
35
|
|
36
|
-
|
37
|
-
|
38
|
-
report_kvs[:RemotePort] = @connection.port
|
39
|
-
|
40
|
-
report_kvs[:QueryOp] = m
|
36
|
+
begin
|
37
|
+
report_kvs[:Flavor] = Oboe::Inst::Mongo::FLAVOR
|
41
38
|
|
42
|
-
|
43
|
-
|
39
|
+
report_kvs[:Database] = @name
|
40
|
+
report_kvs[:RemoteHost] = @connection.host
|
41
|
+
report_kvs[:RemotePort] = @connection.port
|
42
|
+
|
43
|
+
report_kvs[:QueryOp] = m
|
44
44
|
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
45
|
+
report_kvs[:New_Collection_Name] = args[0] if m == :create_collection
|
46
|
+
report_kvs[:Collection_Name] = args[0] if m == :drop_collection
|
47
|
+
|
48
|
+
report_kvs[:Backtrace] = Oboe::API.backtrace
|
49
|
+
rescue
|
50
|
+
end
|
49
51
|
|
50
|
-
|
51
|
-
|
52
|
+
Oboe::API.trace('mongo', report_kvs) do
|
53
|
+
send("#{m}_without_oboe", *args)
|
54
|
+
end
|
52
55
|
end
|
56
|
+
|
57
|
+
class_eval "alias #{m}_without_oboe #{m}"
|
58
|
+
class_eval "alias #{m} #{m}_with_oboe"
|
53
59
|
end
|
54
|
-
|
55
|
-
class_eval "alias #{m}_without_oboe #{m}"
|
56
|
-
class_eval "alias #{m} #{m}_with_oboe"
|
57
60
|
end
|
58
61
|
end
|
59
62
|
end
|
60
|
-
end
|
61
63
|
|
62
|
-
if defined?(::Mongo::Cursor)
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
64
|
+
if defined?(::Mongo::Cursor)
|
65
|
+
module ::Mongo
|
66
|
+
class Cursor
|
67
|
+
include Oboe::Inst::Mongo
|
68
|
+
|
69
|
+
# Instrument DB cursor operations
|
70
|
+
Oboe::Inst::Mongo::CURSOR_OPS.reject { |m| not method_defined?(m) }.each do |m|
|
71
|
+
define_method("#{m}_with_oboe") do |*args|
|
72
|
+
report_kvs = {}
|
73
|
+
|
74
|
+
begin
|
75
|
+
report_kvs[:Flavor] = Oboe::Inst::Mongo::FLAVOR
|
76
|
+
|
77
|
+
report_kvs[:Database] = @db.name
|
78
|
+
report_kvs[:RemoteHost] = @connection.host
|
79
|
+
report_kvs[:RemotePort] = @connection.port
|
80
|
+
|
81
|
+
report_kvs[:QueryOp] = m
|
82
|
+
if m == :count
|
83
|
+
unless @selector.empty?
|
84
|
+
report_kvs[:Query] = @selector.try(:to_json)
|
85
|
+
else
|
86
|
+
report_kvs[:Query] = 'all'
|
87
|
+
end
|
88
|
+
report_kvs[:Limit] = @limit if @limit != 0
|
85
89
|
end
|
86
|
-
|
90
|
+
rescue
|
91
|
+
end
|
92
|
+
|
93
|
+
Oboe::API.trace('mongo', report_kvs) do
|
94
|
+
send("#{m}_without_oboe", *args)
|
87
95
|
end
|
88
|
-
|
89
|
-
rescue
|
90
|
-
logger.warn "[oboe/error] Problem processing mongo args (#{m})" if defined?(logger)
|
91
96
|
end
|
92
97
|
|
93
|
-
|
94
|
-
|
95
|
-
end
|
98
|
+
class_eval "alias #{m}_without_oboe #{m}"
|
99
|
+
class_eval "alias #{m} #{m}_with_oboe"
|
96
100
|
end
|
97
|
-
|
98
|
-
class_eval "alias #{m}_without_oboe #{m}"
|
99
|
-
class_eval "alias #{m} #{m}_with_oboe"
|
100
101
|
end
|
101
102
|
end
|
102
103
|
end
|
103
|
-
end
|
104
104
|
|
105
|
-
if defined?(::Mongo::Collection)
|
106
|
-
|
107
|
-
|
108
|
-
|
105
|
+
if defined?(::Mongo::Collection)
|
106
|
+
module ::Mongo
|
107
|
+
class Collection
|
108
|
+
include Oboe::Inst::Mongo
|
109
109
|
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
110
|
+
def oboe_collect(m, args)
|
111
|
+
report_kvs = {}
|
112
|
+
report_kvs[:Flavor] = Oboe::Inst::Mongo::FLAVOR
|
113
|
+
|
114
|
+
report_kvs[:Database] = @db.name
|
115
|
+
report_kvs[:RemoteHost] = @db.connection.host
|
116
|
+
report_kvs[:RemotePort] = @db.connection.port
|
117
|
+
report_kvs[:Collection] = @name
|
118
|
+
|
119
|
+
report_kvs[:Backtrace] = Oboe::API.backtrace
|
120
|
+
|
121
|
+
report_kvs[:QueryOp] = m
|
122
|
+
report_kvs[:Query] = args[0].try(:to_json) if args and not args.empty? and args[0].class == Hash
|
123
|
+
report_kvs
|
124
|
+
end
|
125
|
+
|
126
|
+
# Instrument Collection write operations
|
127
|
+
Oboe::Inst::Mongo::COLL_WRITE_OPS.reject { |m| not method_defined?(m) }.each do |m|
|
128
|
+
define_method("#{m}_with_oboe") do |*args|
|
129
|
+
report_kvs = oboe_collect(m, args)
|
130
|
+
args_length = args.length
|
118
131
|
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
report_kvs
|
124
|
-
end
|
125
|
-
|
126
|
-
# Instrument Collection write operations
|
127
|
-
Oboe::Inst::Mongo::COLL_WRITE_OPS.reject { |m| not method_defined?(m) }.each do |m|
|
128
|
-
define_method("#{m}_with_oboe") do |*args|
|
129
|
-
report_kvs = oboe_collect(m, args)
|
130
|
-
args_length = args.length
|
131
|
-
|
132
|
-
begin
|
133
|
-
if m == :find_and_modify and args[0] and args[0].has_key?(:update)
|
134
|
-
report_kvs[:Update_Document] = args[0][:update]
|
135
|
-
end
|
132
|
+
begin
|
133
|
+
if m == :find_and_modify and args[0] and args[0].has_key?(:update)
|
134
|
+
report_kvs[:Update_Document] = args[0][:update]
|
135
|
+
end
|
136
136
|
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
137
|
+
if m == :map_reduce
|
138
|
+
report_kvs[:Map_Function] = args[0]
|
139
|
+
report_kvs[:Reduce_Function] = args[1]
|
140
|
+
report_kvs[:Limit] = args[2][:limit] if args[2] and args[2].has_key?(:limit)
|
141
|
+
end
|
142
142
|
|
143
|
-
|
143
|
+
report_kvs[:New_Collection_Name] = args[0] if m == :rename
|
144
144
|
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
145
|
+
if m == :update
|
146
|
+
if args_length >= 3
|
147
|
+
report_kvs[:Update_Document] = args[1].try(:to_json)
|
148
|
+
report_kvs[:Multi] = args[2][:multi] if args[2] and args[2].has_key?(:multi)
|
149
|
+
end
|
149
150
|
end
|
151
|
+
rescue
|
152
|
+
end
|
153
|
+
|
154
|
+
Oboe::API.trace('mongo', report_kvs) do
|
155
|
+
send("#{m}_without_oboe", *args)
|
150
156
|
end
|
151
|
-
rescue
|
152
|
-
logger.warn "[oboe/error] Problem processing mongo args (#{m})" if defined?(logger)
|
153
|
-
end
|
154
|
-
|
155
|
-
Oboe::API.trace('mongo', report_kvs) do
|
156
|
-
send("#{m}_without_oboe", *args)
|
157
157
|
end
|
158
|
-
end
|
159
|
-
|
160
|
-
class_eval "alias #{m}_without_oboe #{m}"
|
161
|
-
class_eval "alias #{m} #{m}_with_oboe"
|
162
|
-
end
|
163
|
-
|
164
|
-
# Instrument Collection query operations
|
165
|
-
Oboe::Inst::Mongo::COLL_QUERY_OPS.reject { |m| not method_defined?(m) }.each do |m|
|
166
|
-
define_method("#{m}_with_oboe") do |*args|
|
167
|
-
begin
|
168
|
-
report_kvs = oboe_collect(m, args)
|
169
|
-
args_length = args.length
|
170
158
|
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
159
|
+
class_eval "alias #{m}_without_oboe #{m}"
|
160
|
+
class_eval "alias #{m} #{m}_with_oboe"
|
161
|
+
end
|
162
|
+
|
163
|
+
# Instrument Collection query operations
|
164
|
+
Oboe::Inst::Mongo::COLL_QUERY_OPS.reject { |m| not method_defined?(m) }.each do |m|
|
165
|
+
define_method("#{m}_with_oboe") do |*args|
|
166
|
+
begin
|
167
|
+
report_kvs = oboe_collect(m, args)
|
168
|
+
args_length = args.length
|
169
|
+
|
170
|
+
if m == :distinct and args_length >= 2
|
171
|
+
report_kvs[:Key] = args[0]
|
172
|
+
report_kvs[:Query] = args[1].try(:to_json) if args[1] and args[1].class == Hash
|
173
|
+
end
|
175
174
|
|
176
|
-
|
177
|
-
|
178
|
-
|
175
|
+
if m == :find and args_length > 0
|
176
|
+
report_kvs[:Limit] = args[0][:limit] if !args[0].nil? and args[0].has_key?(:limit)
|
177
|
+
end
|
179
178
|
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
179
|
+
if m == :group
|
180
|
+
unless args.empty?
|
181
|
+
if args[0].is_a?(Hash)
|
182
|
+
report_kvs[:Group_Key] = args[0][:key].try(:to_json) if args[0].has_key?(:key)
|
183
|
+
report_kvs[:Group_Condition] = args[0][:cond].try(:to_json) if args[0].has_key?(:cond)
|
184
|
+
report_kvs[:Group_Initial] = args[0][:initial].try(:to_json) if args[0].has_key?(:initial)
|
185
|
+
report_kvs[:Group_Reduce] = args[0][:reduce] if args[0].has_key?(:reduce)
|
186
|
+
end
|
187
187
|
end
|
188
188
|
end
|
189
|
+
rescue
|
189
190
|
end
|
190
|
-
rescue
|
191
|
-
logger.warn "[oboe/error] Problem processing mongo args (#{m})" if defined?(logger)
|
192
|
-
end
|
193
191
|
|
194
|
-
|
195
|
-
|
192
|
+
Oboe::API.trace('mongo', report_kvs) do
|
193
|
+
send("#{m}_without_oboe", *args)
|
194
|
+
end
|
196
195
|
end
|
196
|
+
|
197
|
+
class_eval "alias #{m}_without_oboe #{m}"
|
198
|
+
class_eval "alias #{m} #{m}_with_oboe"
|
197
199
|
end
|
200
|
+
|
201
|
+
# Instrument Collection index operations
|
202
|
+
Oboe::Inst::Mongo::COLL_INDEX_OPS.reject { |m| not method_defined?(m) }.each do |m|
|
203
|
+
define_method("#{m}_with_oboe") do |*args|
|
204
|
+
report_kvs = oboe_collect(m, args)
|
205
|
+
_args = args || []
|
206
|
+
|
207
|
+
begin
|
208
|
+
if [:create_index, :ensure_index, :drop_index].include? m and not _args.empty?
|
209
|
+
report_kvs[:Index] = _args[0].try(:to_json)
|
210
|
+
end
|
211
|
+
rescue
|
212
|
+
end
|
198
213
|
|
199
|
-
|
200
|
-
|
201
|
-
end
|
202
|
-
|
203
|
-
# Instrument Collection index operations
|
204
|
-
Oboe::Inst::Mongo::COLL_INDEX_OPS.reject { |m| not method_defined?(m) }.each do |m|
|
205
|
-
define_method("#{m}_with_oboe") do |*args|
|
206
|
-
report_kvs = oboe_collect(m, args)
|
207
|
-
_args = args || []
|
208
|
-
|
209
|
-
begin
|
210
|
-
if [:create_index, :ensure_index, :drop_index].include? m and not _args.empty?
|
211
|
-
report_kvs[:Index] = _args[0].try(:to_json)
|
214
|
+
Oboe::API.trace('mongo', report_kvs) do
|
215
|
+
send("#{m}_without_oboe", *args)
|
212
216
|
end
|
213
|
-
rescue
|
214
|
-
logger.warn "[oboe/error] Problem processing mongo args (#{m})" if defined?(logger)
|
215
217
|
end
|
216
218
|
|
217
|
-
|
218
|
-
|
219
|
-
end
|
219
|
+
class_eval "alias #{m}_without_oboe #{m}"
|
220
|
+
class_eval "alias #{m} #{m}_with_oboe"
|
220
221
|
end
|
221
|
-
|
222
|
-
class_eval "alias #{m}_without_oboe #{m}"
|
223
|
-
class_eval "alias #{m} #{m}_with_oboe"
|
224
222
|
end
|
225
223
|
end
|
226
224
|
end
|
227
|
-
puts "[oboe/loading] Instrumenting mongo" if Oboe::Config[:verbose]
|
228
225
|
end
|
229
226
|
|
data/lib/oboe/inst/moped.rb
CHANGED
@@ -22,394 +22,396 @@ module Oboe
|
|
22
22
|
end
|
23
23
|
end
|
24
24
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
25
|
+
if defined?(::Moped) and Oboe::Config[:moped][:enabled]
|
26
|
+
puts "[oboe/loading] Instrumenting moped" if Oboe::Config[:verbose]
|
27
|
+
|
28
|
+
if defined?(::Moped::Database)
|
29
|
+
module ::Moped
|
30
|
+
class Database
|
31
|
+
include Oboe::Inst::Moped
|
32
|
+
|
33
|
+
def extract_trace_details(op)
|
34
|
+
report_kvs = {}
|
35
|
+
begin
|
36
|
+
report_kvs[:Flavor] = Oboe::Inst::Moped::FLAVOR
|
37
|
+
# FIXME: We're only grabbing the first of potentially multiple servers here
|
38
|
+
report_kvs[:RemoteHost], report_kvs[:RemotePort] = session.cluster.seeds.first.split(':')
|
39
|
+
report_kvs[:Database] = name
|
40
|
+
report_kvs[:QueryOp] = op.to_s
|
41
|
+
rescue
|
42
|
+
end
|
43
|
+
report_kvs
|
41
44
|
end
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
45
|
+
|
46
|
+
def command_with_oboe(command)
|
47
|
+
if Oboe.tracing? and not Oboe::Context.layer_op and command.has_key?(:mapreduce)
|
48
|
+
report_kvs = extract_trace_details(:map_reduce)
|
49
|
+
report_kvs[:Map_Function] = command[:map]
|
50
|
+
report_kvs[:Reduce_Function] = command[:reduce]
|
51
|
+
|
52
|
+
Oboe::API.trace('mongo', report_kvs) do
|
53
|
+
command_without_oboe(command)
|
54
|
+
end
|
55
|
+
else
|
52
56
|
command_without_oboe(command)
|
53
57
|
end
|
54
|
-
else
|
55
|
-
command_without_oboe(command)
|
56
58
|
end
|
57
|
-
end
|
58
59
|
|
59
|
-
|
60
|
-
|
61
|
-
|
60
|
+
def drop_with_oboe
|
61
|
+
if Oboe.tracing?
|
62
|
+
report_kvs = extract_trace_details(:drop_database)
|
62
63
|
|
63
|
-
|
64
|
+
Oboe::API.trace('mongo', report_kvs) do
|
65
|
+
drop_without_oboe
|
66
|
+
end
|
67
|
+
else
|
64
68
|
drop_without_oboe
|
65
69
|
end
|
66
|
-
else
|
67
|
-
drop_without_oboe
|
68
70
|
end
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
71
|
+
|
72
|
+
Oboe::Inst::Moped::DB_OPS.each do |m|
|
73
|
+
if method_defined?(m)
|
74
|
+
class_eval "alias #{m}_without_oboe #{m}"
|
75
|
+
class_eval "alias #{m} #{m}_with_oboe"
|
76
|
+
else puts "[oboe/loading] Couldn't properly instrument moped (#{m}). Partial traces may occur."
|
77
|
+
end
|
76
78
|
end
|
77
79
|
end
|
78
80
|
end
|
79
81
|
end
|
80
|
-
end
|
81
82
|
|
82
|
-
if defined?(::Moped::Indexes)
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
83
|
+
if defined?(::Moped::Indexes)
|
84
|
+
module ::Moped
|
85
|
+
class Indexes
|
86
|
+
include Oboe::Inst::Moped
|
87
|
+
|
88
|
+
def extract_trace_details(op)
|
89
|
+
report_kvs = {}
|
90
|
+
begin
|
91
|
+
report_kvs[:Flavor] = Oboe::Inst::Moped::FLAVOR
|
92
|
+
# FIXME: We're only grabbing the first of potentially multiple servers here
|
93
|
+
report_kvs[:RemoteHost], report_kvs[:RemotePort] = database.session.cluster.seeds.first.split(':')
|
94
|
+
report_kvs[:Database] = database.name
|
95
|
+
report_kvs[:QueryOp] = op.to_s
|
96
|
+
rescue
|
97
|
+
end
|
98
|
+
report_kvs
|
96
99
|
end
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
100
|
+
|
101
|
+
def create_with_oboe(key, options = {})
|
102
|
+
if Oboe.tracing?
|
103
|
+
# We report :create_index here to be consistent
|
104
|
+
# with other mongo implementations
|
105
|
+
report_kvs = extract_trace_details(:create_index)
|
106
|
+
report_kvs[:Key] = key.try(:to_json)
|
107
|
+
report_kvs[:Options] = options.try(:to_json)
|
108
|
+
|
109
|
+
Oboe::API.trace('mongo', report_kvs, :create_index) do
|
110
|
+
create_without_oboe(key, options = {})
|
111
|
+
end
|
112
|
+
else
|
109
113
|
create_without_oboe(key, options = {})
|
110
114
|
end
|
111
|
-
else
|
112
|
-
create_without_oboe(key, options = {})
|
113
115
|
end
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
116
|
+
|
117
|
+
def drop_with_oboe(key = nil)
|
118
|
+
if Oboe.tracing?
|
119
|
+
# We report :drop_indexes here to be consistent
|
120
|
+
# with other mongo implementations
|
121
|
+
report_kvs = extract_trace_details(:drop_indexes)
|
122
|
+
report_kvs[:Key] = key.nil? ? "all" : key.try(:to_json)
|
123
|
+
|
124
|
+
Oboe::API.trace('mongo', report_kvs) do
|
125
|
+
drop_without_oboe(key = nil)
|
126
|
+
end
|
127
|
+
else
|
124
128
|
drop_without_oboe(key = nil)
|
125
129
|
end
|
126
|
-
else
|
127
|
-
drop_without_oboe(key = nil)
|
128
130
|
end
|
129
|
-
end
|
130
131
|
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
132
|
+
Oboe::Inst::Moped::INDEX_OPS.each do |m|
|
133
|
+
if method_defined?(m)
|
134
|
+
class_eval "alias #{m}_without_oboe #{m}"
|
135
|
+
class_eval "alias #{m} #{m}_with_oboe"
|
136
|
+
else puts "[oboe/loading] Couldn't properly instrument moped (#{m}). Partial traces may occur."
|
137
|
+
end
|
136
138
|
end
|
137
139
|
end
|
138
140
|
end
|
139
141
|
end
|
140
|
-
end
|
141
142
|
|
142
|
-
if defined?(::Moped::Query)
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
143
|
+
if defined?(::Moped::Query)
|
144
|
+
module ::Moped
|
145
|
+
class Query
|
146
|
+
include Oboe::Inst::Moped
|
147
|
+
|
148
|
+
|
149
|
+
def extract_trace_details(op)
|
150
|
+
report_kvs = {}
|
151
|
+
begin
|
152
|
+
report_kvs[:Flavor] = Oboe::Inst::Moped::FLAVOR
|
153
|
+
# FIXME: We're only grabbing the first of potentially multiple servers here
|
154
|
+
report_kvs[:RemoteHost], report_kvs[:RemotePort] = collection.database.session.cluster.seeds.first.split(':')
|
155
|
+
report_kvs[:Database] = collection.database.name
|
156
|
+
report_kvs[:Collection_Name] = collection.name
|
157
|
+
report_kvs[:QueryOp] = op.to_s
|
158
|
+
rescue
|
159
|
+
end
|
160
|
+
report_kvs
|
158
161
|
end
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
162
|
+
|
163
|
+
def count_with_oboe
|
164
|
+
if Oboe.tracing?
|
165
|
+
report_kvs = extract_trace_details(:count)
|
166
|
+
report_kvs[:Query] = selector.try(:empty?) ? "all" : selector.try(:to_json)
|
167
|
+
|
168
|
+
Oboe::API.trace('mongo', report_kvs) do
|
169
|
+
count_without_oboe
|
170
|
+
end
|
171
|
+
else
|
168
172
|
count_without_oboe
|
169
173
|
end
|
170
|
-
else
|
171
|
-
count_without_oboe
|
172
174
|
end
|
173
|
-
end
|
174
175
|
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
176
|
+
def sort_with_oboe(sort)
|
177
|
+
if Oboe.tracing?
|
178
|
+
report_kvs = extract_trace_details(:sort)
|
179
|
+
report_kvs[:Query] = selector.try(:empty?) ? "all" : selector.try(:to_json)
|
180
|
+
report_kvs[:Order] = sort.to_s
|
180
181
|
|
181
|
-
|
182
|
+
Oboe::API.trace('mongo', report_kvs) do
|
183
|
+
sort_without_oboe(sort)
|
184
|
+
end
|
185
|
+
else
|
182
186
|
sort_without_oboe(sort)
|
183
187
|
end
|
184
|
-
else
|
185
|
-
sort_without_oboe(sort)
|
186
188
|
end
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
189
|
+
|
190
|
+
def limit_with_oboe(limit)
|
191
|
+
if Oboe.tracing? and not Oboe::Context.tracing_layer_op?(:explain)
|
192
|
+
report_kvs = extract_trace_details(:limit)
|
193
|
+
report_kvs[:Query] = selector.try(:empty?) ? "all" : selector.try(:to_json)
|
194
|
+
report_kvs[:Limit] = limit.to_s
|
195
|
+
|
196
|
+
Oboe::API.trace('mongo', report_kvs) do
|
197
|
+
limit_without_oboe(limit)
|
198
|
+
end
|
199
|
+
else
|
196
200
|
limit_without_oboe(limit)
|
197
201
|
end
|
198
|
-
else
|
199
|
-
limit_without_oboe(limit)
|
200
202
|
end
|
201
|
-
end
|
202
203
|
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
204
|
+
def distinct_with_oboe(key)
|
205
|
+
if Oboe.tracing?
|
206
|
+
report_kvs = extract_trace_details(:distinct)
|
207
|
+
report_kvs[:Query] = selector.try(:empty?) ? "all" : selector.try(:to_json)
|
208
|
+
report_kvs[:Key] = key.to_s
|
208
209
|
|
209
|
-
|
210
|
+
Oboe::API.trace('mongo', report_kvs) do
|
211
|
+
distinct_without_oboe(key)
|
212
|
+
end
|
213
|
+
else
|
210
214
|
distinct_without_oboe(key)
|
211
215
|
end
|
212
|
-
else
|
213
|
-
distinct_without_oboe(key)
|
214
216
|
end
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
217
|
+
|
218
|
+
def update_with_oboe(change, flags = nil)
|
219
|
+
if Oboe.tracing? and not Oboe::Context.tracing_layer_op?([:update_all, :upsert])
|
220
|
+
report_kvs = extract_trace_details(:update)
|
221
|
+
report_kvs[:Flags] = flags.to_s if flags
|
222
|
+
report_kvs[:Update_Document] = change.try(:to_json)
|
223
|
+
|
224
|
+
Oboe::API.trace('mongo', report_kvs) do
|
225
|
+
update_without_oboe(change, flags = nil)
|
226
|
+
end
|
227
|
+
else
|
224
228
|
update_without_oboe(change, flags = nil)
|
225
229
|
end
|
226
|
-
else
|
227
|
-
update_without_oboe(change, flags = nil)
|
228
230
|
end
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
231
|
+
|
232
|
+
def update_all_with_oboe(change)
|
233
|
+
if Oboe.tracing?
|
234
|
+
report_kvs = extract_trace_details(:update_all)
|
235
|
+
report_kvs[:Update_Document] = change.try(:to_json)
|
236
|
+
|
237
|
+
Oboe::API.trace('mongo', report_kvs, :update_all) do
|
238
|
+
update_all_without_oboe(change)
|
239
|
+
end
|
240
|
+
else
|
237
241
|
update_all_without_oboe(change)
|
238
242
|
end
|
239
|
-
else
|
240
|
-
update_all_without_oboe(change)
|
241
243
|
end
|
242
|
-
end
|
243
244
|
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
245
|
+
def upsert_with_oboe(change)
|
246
|
+
if Oboe.tracing?
|
247
|
+
report_kvs = extract_trace_details(:upsert)
|
248
|
+
report_kvs[:Query] = selector.try(:to_json)
|
249
|
+
report_kvs[:Update_Document] = change.try(:to_json)
|
249
250
|
|
250
|
-
|
251
|
+
Oboe::API.trace('mongo', report_kvs, :upsert) do
|
252
|
+
upsert_without_oboe(change)
|
253
|
+
end
|
254
|
+
else
|
251
255
|
upsert_without_oboe(change)
|
252
256
|
end
|
253
|
-
else
|
254
|
-
upsert_without_oboe(change)
|
255
257
|
end
|
256
|
-
end
|
257
258
|
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
259
|
+
def explain_with_oboe
|
260
|
+
if Oboe.tracing?
|
261
|
+
report_kvs = extract_trace_details(:explain)
|
262
|
+
report_kvs[:Query] = selector.try(:empty?) ? "all" : selector.try(:to_json)
|
262
263
|
|
263
|
-
|
264
|
+
Oboe::API.trace('mongo', report_kvs, :explain) do
|
265
|
+
explain_without_oboe
|
266
|
+
end
|
267
|
+
else
|
264
268
|
explain_without_oboe
|
265
269
|
end
|
266
|
-
else
|
267
|
-
explain_without_oboe
|
268
270
|
end
|
269
|
-
end
|
270
|
-
|
271
|
-
def modify_with_oboe(change, options = {})
|
272
|
-
if Oboe::Config.tracing?
|
273
|
-
report_kvs = extract_trace_details(:modify)
|
274
|
-
report_kvs[:Update_Document] = selector.try(:empty?) ? "all" : selector.try(:to_json)
|
275
|
-
report_kvs[:Change] = change.try(:to_json)
|
276
|
-
report_kvs[:Options] = options.try(:to_json)
|
277
271
|
|
278
|
-
|
272
|
+
def modify_with_oboe(change, options = {})
|
273
|
+
if Oboe.tracing?
|
274
|
+
report_kvs = extract_trace_details(:modify)
|
275
|
+
report_kvs[:Update_Document] = selector.try(:empty?) ? "all" : selector.try(:to_json)
|
276
|
+
report_kvs[:Change] = change.try(:to_json)
|
277
|
+
report_kvs[:Options] = options.try(:to_json)
|
278
|
+
|
279
|
+
Oboe::API.trace('mongo', report_kvs) do
|
280
|
+
modify_without_oboe(change, options)
|
281
|
+
end
|
282
|
+
else
|
279
283
|
modify_without_oboe(change, options)
|
280
284
|
end
|
281
|
-
else
|
282
|
-
modify_without_oboe(change, options)
|
283
285
|
end
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
286
|
+
|
287
|
+
def remove_with_oboe
|
288
|
+
if Oboe.tracing?
|
289
|
+
report_kvs = extract_trace_details(:remove)
|
290
|
+
report_kvs[:Query] = selector.try(:to_json)
|
291
|
+
|
292
|
+
Oboe::API.trace('mongo', report_kvs) do
|
293
|
+
remove_without_oboe
|
294
|
+
end
|
295
|
+
else
|
292
296
|
remove_without_oboe
|
293
297
|
end
|
294
|
-
else
|
295
|
-
remove_without_oboe
|
296
298
|
end
|
297
|
-
end
|
298
299
|
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
300
|
+
def remove_all_with_oboe
|
301
|
+
if Oboe.tracing?
|
302
|
+
report_kvs = extract_trace_details(:remove_all)
|
303
|
+
report_kvs[:Query] = selector.try(:to_json)
|
303
304
|
|
304
|
-
|
305
|
+
Oboe::API.trace('mongo', report_kvs) do
|
306
|
+
remove_all_without_oboe
|
307
|
+
end
|
308
|
+
else
|
305
309
|
remove_all_without_oboe
|
306
310
|
end
|
307
|
-
else
|
308
|
-
remove_all_without_oboe
|
309
311
|
end
|
310
|
-
end
|
311
312
|
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
313
|
+
Oboe::Inst::Moped::QUERY_OPS.each do |m|
|
314
|
+
if method_defined?(m)
|
315
|
+
class_eval "alias #{m}_without_oboe #{m}"
|
316
|
+
class_eval "alias #{m} #{m}_with_oboe"
|
317
|
+
else puts "[oboe/loading] Couldn't properly instrument moped (#{m}). Partial traces may occur."
|
318
|
+
end
|
317
319
|
end
|
318
320
|
end
|
319
321
|
end
|
320
|
-
end
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
322
|
+
end # ::Moped::Query
|
323
|
+
|
324
|
+
|
325
|
+
if defined?(::Moped::Collection)
|
326
|
+
module ::Moped
|
327
|
+
class Collection
|
328
|
+
include Oboe::Inst::Moped
|
329
|
+
|
330
|
+
def extract_trace_details(op)
|
331
|
+
report_kvs = {}
|
332
|
+
begin
|
333
|
+
report_kvs[:Flavor] = Oboe::Inst::Moped::FLAVOR
|
334
|
+
# FIXME: We're only grabbing the first of potentially multiple servers here
|
335
|
+
report_kvs[:RemoteHost], report_kvs[:RemotePort] = @database.session.cluster.seeds.first.split(':')
|
336
|
+
report_kvs[:Database] = @database.name
|
337
|
+
report_kvs[:Collection_Name] = @name
|
338
|
+
report_kvs[:QueryOp] = op.to_s
|
339
|
+
rescue
|
340
|
+
end
|
341
|
+
report_kvs
|
339
342
|
end
|
340
|
-
report_kvs
|
341
|
-
end
|
342
343
|
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
344
|
+
def drop_with_oboe
|
345
|
+
if Oboe.tracing?
|
346
|
+
# We report :drop_collection here to be consistent
|
347
|
+
# with other mongo implementations
|
348
|
+
report_kvs = extract_trace_details(:drop_collection)
|
348
349
|
|
349
|
-
|
350
|
+
Oboe::API.trace('mongo', report_kvs) do
|
351
|
+
drop_without_oboe
|
352
|
+
end
|
353
|
+
else
|
350
354
|
drop_without_oboe
|
351
355
|
end
|
352
|
-
else
|
353
|
-
drop_without_oboe
|
354
356
|
end
|
355
|
-
end
|
356
357
|
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
|
358
|
+
def find_with_oboe(selector = {})
|
359
|
+
if Oboe.tracing?
|
360
|
+
report_kvs = extract_trace_details(:find)
|
361
|
+
report_kvs[:Query] = selector.try(:empty?) ? "all" : selector.try(:to_json)
|
361
362
|
|
362
|
-
|
363
|
+
Oboe::API.trace('mongo', report_kvs) do
|
364
|
+
find_without_oboe(selector)
|
365
|
+
end
|
366
|
+
else
|
363
367
|
find_without_oboe(selector)
|
364
368
|
end
|
365
|
-
else
|
366
|
-
find_without_oboe(selector)
|
367
369
|
end
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
|
374
|
-
|
370
|
+
|
371
|
+
def indexes_with_oboe
|
372
|
+
if Oboe.tracing?
|
373
|
+
report_kvs = extract_trace_details(:indexes)
|
374
|
+
|
375
|
+
Oboe::API.trace('mongo', report_kvs) do
|
376
|
+
indexes_without_oboe
|
377
|
+
end
|
378
|
+
else
|
375
379
|
indexes_without_oboe
|
376
380
|
end
|
377
|
-
else
|
378
|
-
indexes_without_oboe
|
379
381
|
end
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
|
386
|
-
|
382
|
+
|
383
|
+
def insert_with_oboe(documents, flags = nil)
|
384
|
+
if Oboe.tracing? and not Oboe::Context.tracing_layer_op?(:create_index)
|
385
|
+
report_kvs = extract_trace_details(:insert)
|
386
|
+
|
387
|
+
Oboe::API.trace('mongo', report_kvs) do
|
388
|
+
insert_without_oboe(documents, flags)
|
389
|
+
end
|
390
|
+
else
|
387
391
|
insert_without_oboe(documents, flags)
|
388
392
|
end
|
389
|
-
else
|
390
|
-
insert_without_oboe(documents, flags)
|
391
393
|
end
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
|
396
|
-
|
397
|
-
|
398
|
-
|
394
|
+
|
395
|
+
def aggregate_with_oboe(pipeline)
|
396
|
+
if Oboe.tracing?
|
397
|
+
report_kvs = extract_trace_details(:aggregate)
|
398
|
+
|
399
|
+
Oboe::API.trace('mongo', report_kvs) do
|
400
|
+
aggregate_without_oboe(pipeline)
|
401
|
+
end
|
402
|
+
else
|
399
403
|
aggregate_without_oboe(pipeline)
|
400
404
|
end
|
401
|
-
else
|
402
|
-
aggregate_without_oboe(pipeline)
|
403
405
|
end
|
404
|
-
|
405
|
-
|
406
|
-
|
407
|
-
|
408
|
-
|
409
|
-
|
410
|
-
|
406
|
+
|
407
|
+
Oboe::Inst::Moped::COLLECTION_OPS.each do |m|
|
408
|
+
if method_defined?(m)
|
409
|
+
class_eval "alias #{m}_without_oboe #{m}"
|
410
|
+
class_eval "alias #{m} #{m}_with_oboe"
|
411
|
+
else puts "[oboe/loading] Couldn't properly instrument moped (#{m}). Partial traces may occur."
|
412
|
+
end
|
411
413
|
end
|
412
414
|
end
|
413
415
|
end
|
414
|
-
end
|
415
|
-
end
|
416
|
+
end # ::Moped::Collection
|
417
|
+
end
|