oboe 2.2.6 → 2.3.2
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +6 -1
- data/Appraisals +20 -0
- data/Gemfile +16 -20
- data/README.md +280 -10
- data/Rakefile +63 -7
- data/ext/oboe_metal/extconf.rb +2 -1
- data/ext/oboe_metal/tests/test.rb +4 -0
- data/gemfiles/rails2.3.gemfile +18 -0
- data/gemfiles/rails2.3.gemfile.lock +95 -0
- data/gemfiles/rails3.0.gemfile +18 -0
- data/gemfiles/rails3.0.gemfile.lock +142 -0
- data/gemfiles/rails3.1.gemfile +18 -0
- data/gemfiles/rails3.1.gemfile.lock +152 -0
- data/gemfiles/rails3.2.gemfile +18 -0
- data/gemfiles/rails3.2.gemfile.lock +150 -0
- data/init.rb +1 -1
- data/lib/joboe_metal.rb +52 -34
- data/lib/method_profiling.rb +1 -1
- data/lib/oboe.rb +6 -5
- data/lib/oboe/api.rb +1 -1
- data/lib/oboe/api/layerinit.rb +3 -0
- data/lib/oboe/api/logging.rb +1 -1
- data/lib/oboe/api/memcache.rb +2 -2
- data/lib/oboe/api/profiling.rb +6 -4
- data/lib/oboe/api/tracing.rb +1 -1
- data/lib/oboe/api/util.rb +1 -1
- data/lib/oboe/config.rb +29 -10
- data/lib/oboe/frameworks/rails.rb +6 -7
- data/lib/oboe/frameworks/rails/inst/action_controller.rb +1 -1
- data/lib/oboe/frameworks/rails/inst/action_view.rb +3 -3
- data/lib/oboe/frameworks/rails/inst/action_view_2x.rb +3 -3
- data/lib/oboe/frameworks/rails/inst/action_view_30.rb +3 -3
- data/lib/oboe/frameworks/rails/inst/active_record.rb +1 -1
- data/lib/oboe/frameworks/rails/inst/connection_adapters/mysql.rb +1 -1
- data/lib/oboe/frameworks/rails/inst/connection_adapters/mysql2.rb +1 -1
- data/lib/oboe/frameworks/rails/inst/connection_adapters/oracle.rb +1 -1
- data/lib/oboe/frameworks/rails/inst/connection_adapters/postgresql.rb +1 -1
- data/lib/oboe/frameworks/rails/inst/connection_adapters/utils.rb +2 -2
- data/lib/oboe/inst/cassandra.rb +2 -2
- data/lib/oboe/inst/dalli.rb +8 -4
- data/lib/oboe/inst/http.rb +38 -34
- data/lib/oboe/inst/memcache.rb +12 -3
- data/lib/oboe/inst/memcached.rb +10 -5
- data/lib/oboe/inst/mongo.rb +19 -15
- data/lib/oboe/inst/moped.rb +120 -51
- data/lib/oboe/inst/rack.rb +14 -7
- data/lib/oboe/inst/resque.rb +2 -2
- data/lib/oboe/instrumentation.rb +3 -0
- data/lib/oboe/loading.rb +2 -6
- data/lib/oboe/logger.rb +3 -1
- data/lib/oboe/ruby.rb +3 -0
- data/lib/oboe/util.rb +2 -0
- data/lib/oboe/version.rb +5 -2
- data/lib/oboe_fu.rb +2 -0
- data/lib/oboe_metal.rb +23 -10
- data/lib/rails/generators/oboe/install_generator.rb +5 -3
- data/lib/rails/generators/oboe/templates/oboe_initializer.rb +24 -2
- data/oboe.gemspec +20 -14
- data/test/instrumentation/cassandra_test.rb +331 -0
- data/test/instrumentation/dalli_test.rb +157 -0
- data/test/instrumentation/http_test.rb +74 -0
- data/test/instrumentation/memcache_test.rb +251 -0
- data/test/instrumentation/memcached_test.rb +218 -0
- data/test/instrumentation/mongo_test.rb +406 -0
- data/test/instrumentation/moped_test.rb +468 -0
- data/test/instrumentation/rack_test.rb +55 -0
- data/test/instrumentation/resque_test.rb +62 -0
- data/test/minitest_helper.rb +113 -0
- data/test/support/config_test.rb +41 -0
- metadata +56 -35
- data/Gemfile.lock +0 -103
- data/Guardfile +0 -24
- data/install.rb +0 -1
- data/spec/instrumentation/cassandra_spec.rb +0 -18
- data/spec/instrumentation/dalli_spec.rb +0 -14
- data/spec/instrumentation/http_spec.rb +0 -14
- data/spec/instrumentation/memcache_spec.rb +0 -19
- data/spec/instrumentation/memcached_spec.rb +0 -22
- data/spec/instrumentation/mongo_spec.rb +0 -29
- data/spec/instrumentation/moped_spec.rb +0 -41
- data/spec/instrumentation/resque_spec.rb +0 -18
- data/spec/spec_helper.rb +0 -15
- data/spec/support/config_spec.rb +0 -27
- data/spec/support/oboe_spec.rb +0 -4
@@ -1,3 +1,6 @@
|
|
1
|
+
# Copyright (c) 2013 AppNeta, Inc.
|
2
|
+
# All rights reserved.
|
3
|
+
|
1
4
|
module Oboe
|
2
5
|
module Rails
|
3
6
|
module Helpers
|
@@ -39,8 +42,8 @@ module Oboe
|
|
39
42
|
end # Helpers
|
40
43
|
|
41
44
|
def self.load_initializer
|
42
|
-
# Force load the
|
43
|
-
# Prefer oboe.rb but give priority to tracelytics.rb if it exists
|
45
|
+
# Force load the TraceView Rails initializer if there is one
|
46
|
+
# Prefer oboe.rb but give priority to the legacy tracelytics.rb if it exists
|
44
47
|
if ::Rails::VERSION::MAJOR > 2
|
45
48
|
rails_root = "#{::Rails.root.to_s}"
|
46
49
|
else
|
@@ -66,11 +69,7 @@ module Oboe
|
|
66
69
|
end
|
67
70
|
end
|
68
71
|
|
69
|
-
|
70
|
-
Oboe.logger.info "Tracelytics oboe gem #{Gem.loaded_specs['oboe'].version.to_s} successfully loaded."
|
71
|
-
else
|
72
|
-
Oboe.logger.info "Tracelytics oboe gem #{Oboe::Version::STRING} successfully loaded."
|
73
|
-
end
|
72
|
+
Oboe.logger.info "TraceView oboe gem #{Oboe::Version::STRING} successfully loaded."
|
74
73
|
end
|
75
74
|
|
76
75
|
def self.include_helpers
|
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (c)
|
1
|
+
# Copyright (c) 2013 AppNeta, Inc.
|
2
2
|
# All rights reserved.
|
3
3
|
|
4
4
|
if defined?(ActionView::Base) and Oboe::Config[:action_view][:enabled]
|
@@ -26,7 +26,7 @@ if defined?(ActionView::Base) and Oboe::Config[:action_view][:enabled]
|
|
26
26
|
rescue
|
27
27
|
end
|
28
28
|
|
29
|
-
Oboe::API.profile(name, entry_kvs) do
|
29
|
+
Oboe::API.profile(name, entry_kvs, Oboe::Config[:action_view][:collect_backtraces]) do
|
30
30
|
render_partial_without_oboe
|
31
31
|
end
|
32
32
|
end
|
@@ -44,7 +44,7 @@ if defined?(ActionView::Base) and Oboe::Config[:action_view][:enabled]
|
|
44
44
|
rescue
|
45
45
|
end
|
46
46
|
|
47
|
-
Oboe::API.profile(name, entry_kvs) do
|
47
|
+
Oboe::API.profile(name, entry_kvs, Oboe::Config[:action_view][:collect_backtraces]) do
|
48
48
|
ret = render_collection_without_oboe
|
49
49
|
end
|
50
50
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (c) 2013
|
1
|
+
# Copyright (c) 2013 AppNeta, Inc.
|
2
2
|
# All rights reserved.
|
3
3
|
|
4
4
|
if defined?(ActionView::Base) and Oboe::Config[:action_view][:enabled]
|
@@ -22,7 +22,7 @@ if defined?(ActionView::Base) and Oboe::Config[:action_view][:enabled]
|
|
22
22
|
rescue
|
23
23
|
end
|
24
24
|
|
25
|
-
Oboe::API.profile(name, entry_kvs) do
|
25
|
+
Oboe::API.profile(name, entry_kvs, Oboe::Config[:action_view][:collect_backtraces]) do
|
26
26
|
render_partial_without_oboe(options)
|
27
27
|
end
|
28
28
|
else
|
@@ -43,7 +43,7 @@ if defined?(ActionView::Base) and Oboe::Config[:action_view][:enabled]
|
|
43
43
|
rescue
|
44
44
|
end
|
45
45
|
|
46
|
-
Oboe::API.profile(name, entry_kvs) do
|
46
|
+
Oboe::API.profile(name, entry_kvs, Oboe::Config[:action_view][:collect_backtraces]) do
|
47
47
|
render_partial_collection_without_oboe(options)
|
48
48
|
end
|
49
49
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (c)
|
1
|
+
# Copyright (c) 2013 AppNeta, Inc.
|
2
2
|
# All rights reserved.
|
3
3
|
|
4
4
|
if defined?(ActionView::Base) and Oboe::Config[:action_view][:enabled]
|
@@ -19,7 +19,7 @@ if defined?(ActionView::Base) and Oboe::Config[:action_view][:enabled]
|
|
19
19
|
rescue
|
20
20
|
end
|
21
21
|
|
22
|
-
Oboe::API.profile(name, entry_kvs) do
|
22
|
+
Oboe::API.profile(name, entry_kvs, Oboe::Config[:action_view][:collect_backtraces]) do
|
23
23
|
render_partial_without_oboe(object)
|
24
24
|
end
|
25
25
|
end
|
@@ -37,7 +37,7 @@ if defined?(ActionView::Base) and Oboe::Config[:action_view][:enabled]
|
|
37
37
|
rescue
|
38
38
|
end
|
39
39
|
|
40
|
-
Oboe::API.profile(name, entry_kvs) do
|
40
|
+
Oboe::API.profile(name, entry_kvs, Oboe::Config[:action_view][:collect_backtraces]) do
|
41
41
|
render_collection_without_oboe
|
42
42
|
end
|
43
43
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (c) 2013
|
1
|
+
# Copyright (c) 2013 AppNeta, Inc.
|
2
2
|
# All rights reserved.
|
3
3
|
|
4
4
|
module Oboe
|
@@ -28,7 +28,7 @@ module Oboe
|
|
28
28
|
end
|
29
29
|
|
30
30
|
opts[:Name] = name.to_s if name
|
31
|
-
opts[:Backtrace] = Oboe::API.backtrace
|
31
|
+
opts[:Backtrace] = Oboe::API.backtrace if Oboe::Config[:active_record][:collect_backtraces]
|
32
32
|
|
33
33
|
if ::Rails::VERSION::MAJOR == 2
|
34
34
|
config = ::Rails.configuration.database_configuration[::Rails.env]
|
data/lib/oboe/inst/cassandra.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (c)
|
1
|
+
# Copyright (c) 2013 AppNeta, Inc.
|
2
2
|
# All rights reserved.
|
3
3
|
|
4
4
|
module Oboe
|
@@ -15,7 +15,7 @@ module Oboe
|
|
15
15
|
# Open issue - how to handle multiple Cassandra servers
|
16
16
|
report_kvs[:RemoteHost], report_kvs[:RemotePort] = @servers.first.split(":")
|
17
17
|
|
18
|
-
report_kvs[:Backtrace] = Oboe::API.backtrace
|
18
|
+
report_kvs[:Backtrace] = Oboe::API.backtrace if Oboe::Config[:cassandra][:collect_backtraces]
|
19
19
|
|
20
20
|
if options.empty? and args.is_a?(Array)
|
21
21
|
options = args.last if args.last.is_a?(Hash)
|
data/lib/oboe/inst/dalli.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (c)
|
1
|
+
# Copyright (c) 2013 AppNeta, Inc.
|
2
2
|
# All rights reserved.
|
3
3
|
|
4
4
|
module Oboe
|
@@ -32,9 +32,12 @@ module Oboe
|
|
32
32
|
|
33
33
|
Oboe::API.trace('memcache', opts || {}) do
|
34
34
|
result = perform_without_oboe(*all_args, &blk)
|
35
|
-
|
36
|
-
|
37
|
-
|
35
|
+
|
36
|
+
info_kvs = {}
|
37
|
+
info_kvs[:KVHit] = memcache_hit?(result) if op == :get and key.class == String
|
38
|
+
info_kvs[:Backtrace] = Oboe::API.backtrace if Oboe::Config[:dalli][:collect_backtraces]
|
39
|
+
|
40
|
+
Oboe::API.log('memcache', 'info', info_kvs) unless info_kvs.empty?
|
38
41
|
result
|
39
42
|
end
|
40
43
|
else
|
@@ -60,6 +63,7 @@ module Oboe
|
|
60
63
|
values = get_multi_without_oboe(keys)
|
61
64
|
|
62
65
|
info_kvs[:KVHitCount] = values.length
|
66
|
+
info_kvs[:Backtrace] = Oboe::API.backtrace if Oboe::Config[:dalli][:collect_backtraces]
|
63
67
|
Oboe::API.log('memcache', 'info', info_kvs)
|
64
68
|
rescue
|
65
69
|
values = get_multi_without_oboe(keys)
|
data/lib/oboe/inst/http.rb
CHANGED
@@ -1,49 +1,53 @@
|
|
1
|
-
# Copyright (c)
|
1
|
+
# Copyright (c) 2013 AppNeta, Inc.
|
2
2
|
# All rights reserved.
|
3
3
|
|
4
4
|
require 'net/http'
|
5
5
|
|
6
|
-
|
7
|
-
def request_with_oboe(*args, &block)
|
8
|
-
unless started?
|
9
|
-
return request_without_oboe(*args, &block)
|
10
|
-
end
|
6
|
+
if Oboe::Config[:nethttp][:enabled]
|
11
7
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
opts = {}
|
17
|
-
if args.length and args[0]
|
18
|
-
req = args[0]
|
19
|
-
|
20
|
-
opts['IsService'] = 1
|
21
|
-
opts['RemoteProtocol'] = use_ssl? ? 'HTTPS' : 'HTTP'
|
22
|
-
opts['RemoteHost'] = addr_port
|
23
|
-
opts['ServiceArg'] = req.path
|
24
|
-
opts['HTTPMethod'] = req.method
|
25
|
-
opts['Blacklisted'] = true if blacklisted
|
26
|
-
|
27
|
-
req['X-Trace'] = Oboe::Context.toString() unless blacklisted
|
8
|
+
Net::HTTP.class_eval do
|
9
|
+
def request_with_oboe(*args, &block)
|
10
|
+
unless started?
|
11
|
+
return request_without_oboe(*args, &block)
|
28
12
|
end
|
29
13
|
|
30
|
-
|
14
|
+
# Avoid cross host tracing for blacklisted domains
|
15
|
+
blacklisted = Oboe::API.blacklisted?(addr_port)
|
16
|
+
|
17
|
+
Oboe::API.trace('net-http') do
|
18
|
+
opts = {}
|
19
|
+
if args.length and args[0]
|
20
|
+
req = args[0]
|
21
|
+
|
22
|
+
opts['IsService'] = 1
|
23
|
+
opts['RemoteProtocol'] = use_ssl? ? 'HTTPS' : 'HTTP'
|
24
|
+
opts['RemoteHost'] = addr_port
|
25
|
+
opts['ServiceArg'] = req.path
|
26
|
+
opts['HTTPMethod'] = req.method
|
27
|
+
opts['Blacklisted'] = true if blacklisted
|
28
|
+
opts['Backtrace'] = Oboe::API.backtrace if Oboe::Config[:nethttp][:collect_backtraces]
|
29
|
+
|
30
|
+
req['X-Trace'] = Oboe::Context.toString() unless blacklisted
|
31
|
+
end
|
32
|
+
|
33
|
+
resp = request_without_oboe(*args, &block)
|
31
34
|
|
32
|
-
|
33
|
-
|
35
|
+
opts['HTTPStatus'] = resp.code
|
36
|
+
Oboe::API.log('net-http', 'info', opts)
|
34
37
|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
38
|
+
unless blacklisted
|
39
|
+
xtrace = resp.get_fields('X-Trace')
|
40
|
+
if xtrace and xtrace.size and Oboe.tracing?
|
41
|
+
Oboe::Context.fromString(xtrace[0])
|
42
|
+
end
|
39
43
|
end
|
44
|
+
next resp
|
40
45
|
end
|
41
|
-
next resp
|
42
46
|
end
|
43
|
-
end
|
44
47
|
|
45
|
-
|
46
|
-
|
48
|
+
alias request_without_oboe request
|
49
|
+
alias request request_with_oboe
|
47
50
|
|
48
|
-
|
51
|
+
Oboe.logger.info "[oboe/loading] Instrumenting net/http" if Oboe::Config[:verbose]
|
52
|
+
end
|
49
53
|
end
|
data/lib/oboe/inst/memcache.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (c)
|
1
|
+
# Copyright (c) 2013 AppNeta, Inc.
|
2
2
|
# All rights reserved.
|
3
3
|
|
4
4
|
module Oboe
|
@@ -14,6 +14,7 @@ module Oboe
|
|
14
14
|
|
15
15
|
define_method("#{m}_with_oboe") do |*args|
|
16
16
|
report_kvs = { :KVOp => m }
|
17
|
+
report_kvs[:Backtrace] = Oboe::API.backtrace if Oboe::Config[:memcache][:collect_backtraces]
|
17
18
|
|
18
19
|
if Oboe.tracing?
|
19
20
|
Oboe::API.trace('memcache', report_kvs) do
|
@@ -60,6 +61,7 @@ module Oboe
|
|
60
61
|
Oboe::API.trace('memcache', layer_kvs || {}, :get_multi) do
|
61
62
|
begin
|
62
63
|
info_kvs = {}
|
64
|
+
info_kvs[:Backtrace] = Oboe::API.backtrace if Oboe::Config[:memcache][:collect_backtraces]
|
63
65
|
|
64
66
|
if args.last.is_a?(Hash) || args.last.nil?
|
65
67
|
info_kvs[:KVKeyCount] = args.flatten.length - 1
|
@@ -84,7 +86,11 @@ module Oboe
|
|
84
86
|
def request_setup_with_oboe(*args)
|
85
87
|
if Oboe.tracing? and not Oboe::Context.tracing_layer_op?(:get_multi)
|
86
88
|
server, cache_key = request_setup_without_oboe(*args)
|
87
|
-
|
89
|
+
|
90
|
+
info_kvs = { :KVKey => cache_key, :RemoteHost => server.host }
|
91
|
+
info_kvs[:Backtrace] = Oboe::API.backtrace if Oboe::Config[:memcache][:collect_backtraces]
|
92
|
+
|
93
|
+
Oboe::API.log('memcache', 'info', info_kvs)
|
88
94
|
else
|
89
95
|
server, cache_key = request_setup_without_oboe(*args)
|
90
96
|
end
|
@@ -93,7 +99,10 @@ module Oboe
|
|
93
99
|
|
94
100
|
def cache_get_with_oboe(server, cache_key)
|
95
101
|
result = cache_get_without_oboe(server, cache_key)
|
96
|
-
|
102
|
+
|
103
|
+
info_kvs = { :KVHit => memcache_hit?(result) }
|
104
|
+
info_kvs[:Backtrace] = Oboe::API.backtrace if Oboe::Config[:memcache][:collect_backtraces]
|
105
|
+
Oboe::API.log('memcache', 'info', info_kvs)
|
97
106
|
result
|
98
107
|
end
|
99
108
|
|
data/lib/oboe/inst/memcached.rb
CHANGED
@@ -1,6 +1,5 @@
|
|
1
|
-
# Copyright (c)
|
1
|
+
# Copyright (c) 2013 AppNeta, Inc.
|
2
2
|
# All rights reserved.
|
3
|
-
#
|
4
3
|
|
5
4
|
module Oboe
|
6
5
|
module Inst
|
@@ -14,6 +13,7 @@ module Oboe
|
|
14
13
|
MEMCACHE_OPS.reject { |m| not method_defined?(m) }.each do |m|
|
15
14
|
define_method("#{m}_with_oboe") do |*args|
|
16
15
|
opts = { :KVOp => m }
|
16
|
+
|
17
17
|
if args.length and args[0].class != Array
|
18
18
|
opts[:KVKey] = args[0].to_s
|
19
19
|
rhost = remote_host(args[0].to_s)
|
@@ -22,9 +22,12 @@ module Oboe
|
|
22
22
|
|
23
23
|
Oboe::API.trace('memcache', opts) do
|
24
24
|
result = send("#{m}_without_oboe", *args)
|
25
|
-
|
26
|
-
|
27
|
-
|
25
|
+
|
26
|
+
info_kvs = {}
|
27
|
+
info_kvs[:KVHit] = memcache_hit?(result) if m == :get and args.length and args[0].class == String
|
28
|
+
info_kvs[:Backtrace] = Oboe::API.backtrace if Oboe::Config[:memcached][:collect_backtraces]
|
29
|
+
|
30
|
+
Oboe::API.log('memcache', 'info', info_kvs) unless info_kvs.empty?
|
28
31
|
result
|
29
32
|
end
|
30
33
|
end
|
@@ -62,6 +65,8 @@ module Oboe
|
|
62
65
|
values = get_multi_without_oboe(keys, raw)
|
63
66
|
|
64
67
|
info_kvs[:KVHitCount] = values.length
|
68
|
+
info_kvs[:Backtrace] = Oboe::API.backtrace if Oboe::Config[:memcached][:collect_backtraces]
|
69
|
+
|
65
70
|
Oboe::API.log('memcache', 'info', info_kvs)
|
66
71
|
rescue
|
67
72
|
values = get_multi_without_oboe(keys, raw)
|
data/lib/oboe/inst/mongo.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (c)
|
1
|
+
# Copyright (c) 2013 AppNeta, Inc.
|
2
2
|
# All rights reserved.
|
3
3
|
|
4
4
|
module Oboe
|
@@ -43,9 +43,9 @@ if defined?(::Mongo) and Oboe::Config[:mongo][:enabled]
|
|
43
43
|
report_kvs[:QueryOp] = m
|
44
44
|
|
45
45
|
report_kvs[:New_Collection_Name] = args[0] if m == :create_collection
|
46
|
-
report_kvs[:
|
46
|
+
report_kvs[:Collection] = args[0] if m == :drop_collection
|
47
47
|
|
48
|
-
report_kvs[:Backtrace] = Oboe::API.backtrace
|
48
|
+
report_kvs[:Backtrace] = Oboe::API.backtrace if Oboe::Config[:mongo][:collect_backtraces]
|
49
49
|
rescue
|
50
50
|
end
|
51
51
|
|
@@ -108,18 +108,22 @@ if defined?(::Mongo) and Oboe::Config[:mongo][:enabled]
|
|
108
108
|
include Oboe::Inst::Mongo
|
109
109
|
|
110
110
|
def oboe_collect(m, args)
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
111
|
+
begin
|
112
|
+
report_kvs = {}
|
113
|
+
report_kvs[:Flavor] = Oboe::Inst::Mongo::FLAVOR
|
114
|
+
|
115
|
+
report_kvs[:Database] = @db.name
|
116
|
+
report_kvs[:RemoteHost] = @db.connection.host
|
117
|
+
report_kvs[:RemotePort] = @db.connection.port
|
118
|
+
report_kvs[:Collection] = @name
|
119
|
+
|
120
|
+
report_kvs[:Backtrace] = Oboe::API.backtrace if Oboe::Config[:mongo][:collect_backtraces]
|
121
|
+
|
122
|
+
report_kvs[:QueryOp] = m
|
123
|
+
report_kvs[:Query] = args[0].to_json if args and not args.empty? and args[0].class == Hash
|
124
|
+
rescue
|
125
|
+
Oboe.logger.debug "[oboe/debug] Exception in oboe_collect KV collection."
|
126
|
+
end
|
123
127
|
report_kvs
|
124
128
|
end
|
125
129
|
|
data/lib/oboe/inst/moped.rb
CHANGED
@@ -1,6 +1,8 @@
|
|
1
|
-
# Copyright (c)
|
1
|
+
# Copyright (c) 2013 AppNeta, Inc.
|
2
2
|
# All rights reserved.
|
3
3
|
|
4
|
+
require 'json'
|
5
|
+
|
4
6
|
module Oboe
|
5
7
|
module Inst
|
6
8
|
module Moped
|
@@ -38,16 +40,22 @@ if defined?(::Moped) and Oboe::Config[:moped][:enabled]
|
|
38
40
|
report_kvs[:RemoteHost], report_kvs[:RemotePort] = session.cluster.seeds.first.split(':')
|
39
41
|
report_kvs[:Database] = name
|
40
42
|
report_kvs[:QueryOp] = op.to_s
|
41
|
-
|
43
|
+
report_kvs[:Backtrace] = Oboe::API.backtrace if Oboe::Config[:moped][:collect_backtraces]
|
44
|
+
rescue Exception => e
|
45
|
+
Oboe.logger.debug "[oboe/debug] Moped KV collection error: #{e.inspect}"
|
42
46
|
end
|
43
47
|
report_kvs
|
44
48
|
end
|
45
49
|
|
46
50
|
def command_with_oboe(command)
|
47
51
|
if Oboe.tracing? and not Oboe::Context.layer_op and command.has_key?(:mapreduce)
|
48
|
-
|
49
|
-
|
50
|
-
|
52
|
+
begin
|
53
|
+
report_kvs = extract_trace_details(:map_reduce)
|
54
|
+
report_kvs[:Map_Function] = command[:map]
|
55
|
+
report_kvs[:Reduce_Function] = command[:reduce]
|
56
|
+
rescue Exception => e
|
57
|
+
Oboe.logger.debug "[oboe/debug] Moped KV collection error: #{e.inspect}"
|
58
|
+
end
|
51
59
|
|
52
60
|
Oboe::API.trace('mongo', report_kvs) do
|
53
61
|
command_without_oboe(command)
|
@@ -93,18 +101,24 @@ if defined?(::Moped) and Oboe::Config[:moped][:enabled]
|
|
93
101
|
report_kvs[:RemoteHost], report_kvs[:RemotePort] = database.session.cluster.seeds.first.split(':')
|
94
102
|
report_kvs[:Database] = database.name
|
95
103
|
report_kvs[:QueryOp] = op.to_s
|
96
|
-
|
104
|
+
report_kvs[:Backtrace] = Oboe::API.backtrace if Oboe::Config[:moped][:collect_backtraces]
|
105
|
+
rescue Exception => e
|
106
|
+
Oboe.logger.debug "[oboe/debug] Moped KV collection error: #{e.inspect}"
|
97
107
|
end
|
98
108
|
report_kvs
|
99
109
|
end
|
100
110
|
|
101
111
|
def create_with_oboe(key, options = {})
|
102
112
|
if Oboe.tracing?
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
113
|
+
begin
|
114
|
+
# We report :create_index here to be consistent
|
115
|
+
# with other mongo implementations
|
116
|
+
report_kvs = extract_trace_details(:create_index)
|
117
|
+
report_kvs[:Key] = key.to_json
|
118
|
+
report_kvs[:Options] = options.to_json
|
119
|
+
rescue Exception => e
|
120
|
+
Oboe.logger.debug "[oboe/debug] Moped KV collection error: #{e.inspect}"
|
121
|
+
end
|
108
122
|
|
109
123
|
Oboe::API.trace('mongo', report_kvs, :create_index) do
|
110
124
|
create_without_oboe(key, options = {})
|
@@ -116,10 +130,14 @@ if defined?(::Moped) and Oboe::Config[:moped][:enabled]
|
|
116
130
|
|
117
131
|
def drop_with_oboe(key = nil)
|
118
132
|
if Oboe.tracing?
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
133
|
+
begin
|
134
|
+
# We report :drop_indexes here to be consistent
|
135
|
+
# with other mongo implementations
|
136
|
+
report_kvs = extract_trace_details(:drop_indexes)
|
137
|
+
report_kvs[:Key] = key.nil? ? "all" : key.to_json
|
138
|
+
rescue Exception => e
|
139
|
+
Oboe.logger.debug "[oboe/debug] Moped KV collection error: #{e.inspect}"
|
140
|
+
end
|
123
141
|
|
124
142
|
Oboe::API.trace('mongo', report_kvs) do
|
125
143
|
drop_without_oboe(key = nil)
|
@@ -145,7 +163,6 @@ if defined?(::Moped) and Oboe::Config[:moped][:enabled]
|
|
145
163
|
class Query
|
146
164
|
include Oboe::Inst::Moped
|
147
165
|
|
148
|
-
|
149
166
|
def extract_trace_details(op)
|
150
167
|
report_kvs = {}
|
151
168
|
begin
|
@@ -153,17 +170,23 @@ if defined?(::Moped) and Oboe::Config[:moped][:enabled]
|
|
153
170
|
# FIXME: We're only grabbing the first of potentially multiple servers here
|
154
171
|
report_kvs[:RemoteHost], report_kvs[:RemotePort] = collection.database.session.cluster.seeds.first.split(':')
|
155
172
|
report_kvs[:Database] = collection.database.name
|
156
|
-
report_kvs[:
|
173
|
+
report_kvs[:Collection] = collection.name
|
157
174
|
report_kvs[:QueryOp] = op.to_s
|
158
|
-
|
175
|
+
report_kvs[:Backtrace] = Oboe::API.backtrace if Oboe::Config[:moped][:collect_backtraces]
|
176
|
+
rescue Exception => e
|
177
|
+
Oboe.logger.debug "[oboe/debug] Moped KV collection error: #{e.inspect}"
|
159
178
|
end
|
160
179
|
report_kvs
|
161
180
|
end
|
162
181
|
|
163
182
|
def count_with_oboe
|
164
183
|
if Oboe.tracing?
|
165
|
-
|
166
|
-
|
184
|
+
begin
|
185
|
+
report_kvs = extract_trace_details(:count)
|
186
|
+
report_kvs[:Query] = selector.empty? ? "all" : selector.to_json
|
187
|
+
rescue Exception => e
|
188
|
+
Oboe.logger.debug "[oboe/debug] Moped KV collection error: #{e.inspect}"
|
189
|
+
end
|
167
190
|
|
168
191
|
Oboe::API.trace('mongo', report_kvs) do
|
169
192
|
count_without_oboe
|
@@ -175,9 +198,13 @@ if defined?(::Moped) and Oboe::Config[:moped][:enabled]
|
|
175
198
|
|
176
199
|
def sort_with_oboe(sort)
|
177
200
|
if Oboe.tracing?
|
178
|
-
|
179
|
-
|
180
|
-
|
201
|
+
begin
|
202
|
+
report_kvs = extract_trace_details(:sort)
|
203
|
+
report_kvs[:Query] = selector.empty? ? "all" : selector.to_json
|
204
|
+
report_kvs[:Order] = sort.to_s
|
205
|
+
rescue Exception => e
|
206
|
+
Oboe.logger.debug "[oboe/debug] Moped KV collection error: #{e.inspect}"
|
207
|
+
end
|
181
208
|
|
182
209
|
Oboe::API.trace('mongo', report_kvs) do
|
183
210
|
sort_without_oboe(sort)
|
@@ -189,9 +216,13 @@ if defined?(::Moped) and Oboe::Config[:moped][:enabled]
|
|
189
216
|
|
190
217
|
def limit_with_oboe(limit)
|
191
218
|
if Oboe.tracing? and not Oboe::Context.tracing_layer_op?(:explain)
|
192
|
-
|
193
|
-
|
194
|
-
|
219
|
+
begin
|
220
|
+
report_kvs = extract_trace_details(:limit)
|
221
|
+
report_kvs[:Query] = selector.empty? ? "all" : selector.to_json
|
222
|
+
report_kvs[:Limit] = limit.to_s
|
223
|
+
rescue Exception => e
|
224
|
+
Oboe.logger.debug "[oboe/debug] Moped KV collection error: #{e.inspect}"
|
225
|
+
end
|
195
226
|
|
196
227
|
Oboe::API.trace('mongo', report_kvs) do
|
197
228
|
limit_without_oboe(limit)
|
@@ -203,9 +234,13 @@ if defined?(::Moped) and Oboe::Config[:moped][:enabled]
|
|
203
234
|
|
204
235
|
def distinct_with_oboe(key)
|
205
236
|
if Oboe.tracing?
|
206
|
-
|
207
|
-
|
208
|
-
|
237
|
+
begin
|
238
|
+
report_kvs = extract_trace_details(:distinct)
|
239
|
+
report_kvs[:Query] = selector.empty? ? "all" : selector.to_json
|
240
|
+
report_kvs[:Key] = key.to_s
|
241
|
+
rescue Exception => e
|
242
|
+
Oboe.logger.debug "[oboe/debug] Moped KV collection error: #{e.inspect}"
|
243
|
+
end
|
209
244
|
|
210
245
|
Oboe::API.trace('mongo', report_kvs) do
|
211
246
|
distinct_without_oboe(key)
|
@@ -217,9 +252,13 @@ if defined?(::Moped) and Oboe::Config[:moped][:enabled]
|
|
217
252
|
|
218
253
|
def update_with_oboe(change, flags = nil)
|
219
254
|
if Oboe.tracing? and not Oboe::Context.tracing_layer_op?([:update_all, :upsert])
|
220
|
-
|
221
|
-
|
222
|
-
|
255
|
+
begin
|
256
|
+
report_kvs = extract_trace_details(:update)
|
257
|
+
report_kvs[:Flags] = flags.to_s if flags
|
258
|
+
report_kvs[:Update_Document] = change.to_json
|
259
|
+
rescue Exception => e
|
260
|
+
Oboe.logger.debug "[oboe/debug] Moped KV collection error: #{e.inspect}"
|
261
|
+
end
|
223
262
|
|
224
263
|
Oboe::API.trace('mongo', report_kvs) do
|
225
264
|
update_without_oboe(change, flags = nil)
|
@@ -231,8 +270,12 @@ if defined?(::Moped) and Oboe::Config[:moped][:enabled]
|
|
231
270
|
|
232
271
|
def update_all_with_oboe(change)
|
233
272
|
if Oboe.tracing?
|
234
|
-
|
235
|
-
|
273
|
+
begin
|
274
|
+
report_kvs = extract_trace_details(:update_all)
|
275
|
+
report_kvs[:Update_Document] = change.to_json
|
276
|
+
rescue Exception => e
|
277
|
+
Oboe.logger.debug "[oboe/debug] Moped KV collection error: #{e.inspect}"
|
278
|
+
end
|
236
279
|
|
237
280
|
Oboe::API.trace('mongo', report_kvs, :update_all) do
|
238
281
|
update_all_without_oboe(change)
|
@@ -244,9 +287,13 @@ if defined?(::Moped) and Oboe::Config[:moped][:enabled]
|
|
244
287
|
|
245
288
|
def upsert_with_oboe(change)
|
246
289
|
if Oboe.tracing?
|
247
|
-
|
248
|
-
|
249
|
-
|
290
|
+
begin
|
291
|
+
report_kvs = extract_trace_details(:upsert)
|
292
|
+
report_kvs[:Query] = selector.to_json
|
293
|
+
report_kvs[:Update_Document] = change.to_json
|
294
|
+
rescue Exception => e
|
295
|
+
Oboe.logger.debug "[oboe/debug] Moped KV collection error: #{e.inspect}"
|
296
|
+
end
|
250
297
|
|
251
298
|
Oboe::API.trace('mongo', report_kvs, :upsert) do
|
252
299
|
upsert_without_oboe(change)
|
@@ -258,8 +305,12 @@ if defined?(::Moped) and Oboe::Config[:moped][:enabled]
|
|
258
305
|
|
259
306
|
def explain_with_oboe
|
260
307
|
if Oboe.tracing?
|
261
|
-
|
262
|
-
|
308
|
+
begin
|
309
|
+
report_kvs = extract_trace_details(:explain)
|
310
|
+
report_kvs[:Query] = selector.empty? ? "all" : selector.to_json
|
311
|
+
rescue Exception => e
|
312
|
+
Oboe.logger.debug "[oboe/debug] Moped KV collection error: #{e.inspect}"
|
313
|
+
end
|
263
314
|
|
264
315
|
Oboe::API.trace('mongo', report_kvs, :explain) do
|
265
316
|
explain_without_oboe
|
@@ -271,10 +322,14 @@ if defined?(::Moped) and Oboe::Config[:moped][:enabled]
|
|
271
322
|
|
272
323
|
def modify_with_oboe(change, options = {})
|
273
324
|
if Oboe.tracing?
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
325
|
+
begin
|
326
|
+
report_kvs = extract_trace_details(:modify)
|
327
|
+
report_kvs[:Update_Document] = selector.empty? ? "all" : selector.to_json
|
328
|
+
report_kvs[:Change] = change.to_json
|
329
|
+
report_kvs[:Options] = options.to_json
|
330
|
+
rescue Exception => e
|
331
|
+
Oboe.logger.debug "[oboe/debug] Moped KV collection error: #{e.inspect}"
|
332
|
+
end
|
278
333
|
|
279
334
|
Oboe::API.trace('mongo', report_kvs) do
|
280
335
|
modify_without_oboe(change, options)
|
@@ -286,8 +341,12 @@ if defined?(::Moped) and Oboe::Config[:moped][:enabled]
|
|
286
341
|
|
287
342
|
def remove_with_oboe
|
288
343
|
if Oboe.tracing?
|
289
|
-
|
290
|
-
|
344
|
+
begin
|
345
|
+
report_kvs = extract_trace_details(:remove)
|
346
|
+
report_kvs[:Query] = selector.to_json
|
347
|
+
rescue Exception => e
|
348
|
+
Oboe.logger.debug "[oboe/debug] Moped KV collection error: #{e.inspect}"
|
349
|
+
end
|
291
350
|
|
292
351
|
Oboe::API.trace('mongo', report_kvs) do
|
293
352
|
remove_without_oboe
|
@@ -299,8 +358,12 @@ if defined?(::Moped) and Oboe::Config[:moped][:enabled]
|
|
299
358
|
|
300
359
|
def remove_all_with_oboe
|
301
360
|
if Oboe.tracing?
|
302
|
-
|
303
|
-
|
361
|
+
begin
|
362
|
+
report_kvs = extract_trace_details(:remove_all)
|
363
|
+
report_kvs[:Query] = selector.to_json
|
364
|
+
rescue Exception => e
|
365
|
+
Oboe.logger.debug "[oboe/debug] Moped KV collection error: #{e.inspect}"
|
366
|
+
end
|
304
367
|
|
305
368
|
Oboe::API.trace('mongo', report_kvs) do
|
306
369
|
remove_all_without_oboe
|
@@ -334,9 +397,11 @@ if defined?(::Moped) and Oboe::Config[:moped][:enabled]
|
|
334
397
|
# FIXME: We're only grabbing the first of potentially multiple servers here
|
335
398
|
report_kvs[:RemoteHost], report_kvs[:RemotePort] = @database.session.cluster.seeds.first.split(':')
|
336
399
|
report_kvs[:Database] = @database.name
|
337
|
-
report_kvs[:
|
400
|
+
report_kvs[:Collection] = @name
|
338
401
|
report_kvs[:QueryOp] = op.to_s
|
339
|
-
|
402
|
+
report_kvs[:Backtrace] = Oboe::API.backtrace if Oboe::Config[:moped][:collect_backtraces]
|
403
|
+
rescue Exception => e
|
404
|
+
Oboe.logger.debug "[oboe/debug] Moped KV collection error: #{e.inspect}"
|
340
405
|
end
|
341
406
|
report_kvs
|
342
407
|
end
|
@@ -357,8 +422,12 @@ if defined?(::Moped) and Oboe::Config[:moped][:enabled]
|
|
357
422
|
|
358
423
|
def find_with_oboe(selector = {})
|
359
424
|
if Oboe.tracing?
|
360
|
-
|
361
|
-
|
425
|
+
begin
|
426
|
+
report_kvs = extract_trace_details(:find)
|
427
|
+
report_kvs[:Query] = selector.empty? ? "all" : selector.to_json
|
428
|
+
rescue Exception => e
|
429
|
+
Oboe.logger.debug "[oboe/debug] Moped KV collection error: #{e.inspect}"
|
430
|
+
end
|
362
431
|
|
363
432
|
Oboe::API.trace('mongo', report_kvs) do
|
364
433
|
find_without_oboe(selector)
|