oboe 2.3.4.1 → 2.4.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.travis.yml +9 -5
- data/CHANGELOG +12 -0
- data/Gemfile +2 -2
- data/README.md +4 -0
- data/ext/oboe_metal/src/oboe.hpp +18 -12
- data/ext/oboe_metal/src/oboe_wrap.cxx +13 -13
- data/lib/base.rb +23 -0
- data/lib/oboe/api/layerinit.rb +31 -2
- data/lib/oboe/config.rb +10 -14
- data/lib/oboe/frameworks/rails/inst/action_controller.rb +3 -0
- data/lib/oboe/frameworks/rails/inst/connection_adapters/utils.rb +7 -15
- data/lib/oboe/inst/cassandra.rb +76 -108
- data/lib/oboe/inst/dalli.rb +20 -30
- data/lib/oboe/inst/memcache.rb +34 -47
- data/lib/oboe/inst/mongo.rb +9 -7
- data/lib/oboe/inst/moped.rb +145 -177
- data/lib/oboe/inst/rack.rb +6 -2
- data/lib/oboe/inst/resque.rb +1 -0
- data/lib/oboe/version.rb +2 -2
- data/lib/oboe_metal.rb +25 -15
- data/lib/rails/generators/oboe/install_generator.rb +44 -27
- data/lib/rails/generators/oboe/templates/oboe_initializer.rb +10 -0
- data/oboe.gemspec +5 -3
- data/test/instrumentation/cassandra_test.rb +330 -339
- data/test/instrumentation/http_test.rb +13 -13
- data/test/support/config_test.rb +0 -2
- data/test/support/srv1_localset_test.rb +41 -0
- metadata +61 -93
- data/lib/oboe_fu.rb +0 -6
- data/oboe_fu.gemspec +0 -13
data/lib/oboe/inst/rack.rb
CHANGED
@@ -17,8 +17,12 @@ module Oboe
|
|
17
17
|
begin
|
18
18
|
req = ::Rack::Request.new(env)
|
19
19
|
|
20
|
-
|
21
|
-
|
20
|
+
if Oboe.always?
|
21
|
+
# Only report these KVs under tracing_mode 'always' (never for 'through')
|
22
|
+
report_kvs[:SampleRate] = Oboe.sample_rate
|
23
|
+
report_kvs[:SampleSource] = Oboe.sample_source
|
24
|
+
end
|
25
|
+
|
22
26
|
report_kvs['HTTP-Host'] = req.host
|
23
27
|
report_kvs['Port'] = req.port
|
24
28
|
report_kvs['Proto'] = req.scheme
|
data/lib/oboe/inst/resque.rb
CHANGED
data/lib/oboe/version.rb
CHANGED
data/lib/oboe_metal.rb
CHANGED
@@ -5,7 +5,7 @@ module Oboe_metal
|
|
5
5
|
class Context
|
6
6
|
class << self
|
7
7
|
attr_accessor :layer_op
|
8
|
-
|
8
|
+
|
9
9
|
def log(layer, label, options = {}, with_backtrace = false)
|
10
10
|
evt = Oboe::Context.createEvent()
|
11
11
|
evt.addInfo("Layer", layer.to_s)
|
@@ -19,7 +19,7 @@ module Oboe_metal
|
|
19
19
|
|
20
20
|
Oboe.reporter.sendReport(evt)
|
21
21
|
end
|
22
|
-
|
22
|
+
|
23
23
|
def tracing_layer_op?(operation)
|
24
24
|
if operation.is_a?(Array)
|
25
25
|
return operation.include?(@layer_op)
|
@@ -53,13 +53,13 @@ module Oboe_metal
|
|
53
53
|
end
|
54
54
|
|
55
55
|
Oboe::API.report_init('rack') unless ["development", "test"].include? ENV['RACK_ENV']
|
56
|
-
|
56
|
+
|
57
57
|
rescue Exception => e
|
58
58
|
$stderr.puts e.message
|
59
59
|
raise
|
60
60
|
end
|
61
61
|
end
|
62
|
-
|
62
|
+
|
63
63
|
def self.sendReport(evt)
|
64
64
|
Oboe.reporter.sendReport(evt)
|
65
65
|
end
|
@@ -75,8 +75,19 @@ module Oboe
|
|
75
75
|
# Assure defaults since SWIG enforces Strings
|
76
76
|
opts[:layer] ||= ''
|
77
77
|
opts[:xtrace] ||= ''
|
78
|
-
opts['X-TV-Meta']
|
79
|
-
|
78
|
+
opts['X-TV-Meta'] ||= ''
|
79
|
+
|
80
|
+
rv = Oboe::Context.sampleRequest(opts[:layer], opts[:xtrace], opts['X-TV-Meta'])
|
81
|
+
|
82
|
+
# For older liboboe that returns true/false, just return that.
|
83
|
+
return rv if [TrueClass, FalseClass].include?(rv.class) or (rv == 0)
|
84
|
+
|
85
|
+
# liboboe version > 1.3.1 returning a bit masked integer with SampleRate and
|
86
|
+
# source embedded
|
87
|
+
Oboe.sample_rate = (rv & SAMPLE_RATE_MASK)
|
88
|
+
Oboe.sample_source = (rv & SAMPLE_SOURCE_MASK) >> 24
|
89
|
+
|
90
|
+
rv
|
80
91
|
end
|
81
92
|
|
82
93
|
def set_tracing_mode(mode)
|
@@ -86,21 +97,20 @@ module Oboe
|
|
86
97
|
|
87
98
|
case value
|
88
99
|
when :never
|
89
|
-
|
90
|
-
|
100
|
+
Oboe::Context.setTracingMode(OBOE_TRACE_NEVER)
|
101
|
+
|
91
102
|
when :always
|
92
|
-
|
93
|
-
|
103
|
+
Oboe::Context.setTracingMode(OBOE_TRACE_ALWAYS)
|
104
|
+
|
94
105
|
when :through
|
95
|
-
|
96
|
-
|
106
|
+
Oboe::Context.setTracingMode(OBOE_TRACE_THROUGH)
|
107
|
+
|
97
108
|
else
|
98
109
|
Oboe.logger.fatal "[oboe/error] Invalid tracing mode set: #{mode}"
|
99
|
-
|
100
|
-
Oboe::Context.setTracingMode(2)
|
110
|
+
Oboe::Context.setTracingMode(OBOE_TRACE_THROUGH)
|
101
111
|
end
|
102
112
|
end
|
103
|
-
|
113
|
+
|
104
114
|
def set_sample_rate(rate)
|
105
115
|
if Oboe.loaded
|
106
116
|
# Update liboboe with the new SampleRate value
|
@@ -12,34 +12,17 @@ module Oboe
|
|
12
12
|
@sample_rate = '300000'
|
13
13
|
@verbose = 'false'
|
14
14
|
|
15
|
-
|
16
|
-
|
17
|
-
say ""
|
18
|
-
say "To instrument your Rails application, you can setup your tracing strategy here."
|
19
|
-
say ""
|
20
|
-
say shell.set_color "Documentation Links", :magenta
|
21
|
-
say "-------------------"
|
22
|
-
say ""
|
23
|
-
say "Details on configuring your sample rate:"
|
24
|
-
say "http://support.tv.appneta.com/support/solutions/articles/86336-configuring-sampling"
|
25
|
-
say ""
|
26
|
-
say "More information on instrumenting Ruby applications can be found here:"
|
27
|
-
say "http://support.tv.appneta.com/support/solutions/articles/86393-instrumenting-ruby-apps"
|
15
|
+
print_header
|
16
|
+
|
28
17
|
while true do
|
29
|
-
|
30
|
-
|
31
|
-
say "------------"
|
32
|
-
say "Tracing Mode determines when traces should be initiated for incoming requests. Valid"
|
33
|
-
say "options are #{shell.set_color "always", :yellow}, #{shell.set_color "through", :yellow} (when using an instrumented Apache or Nginx) and #{shell.set_color "never", :yellow}."
|
34
|
-
say ""
|
35
|
-
say "If you're not using an instrumented Apache or Nginx, set this directive to #{shell.set_color "always", :yellow} in"
|
36
|
-
say "order to initiate tracing from Ruby."
|
37
|
-
say ""
|
18
|
+
print_body
|
19
|
+
|
38
20
|
user_tracing_mode = ask shell.set_color "* Tracing Mode? [through]:", :yellow
|
39
21
|
user_tracing_mode.downcase!
|
40
22
|
|
41
23
|
break if user_tracing_mode.blank?
|
42
24
|
valid = ['always', 'through', 'never'].include?(user_tracing_mode)
|
25
|
+
|
43
26
|
say shell.set_color "Valid values are 'always', 'through' or 'never'", :red, :bold unless valid
|
44
27
|
if valid
|
45
28
|
@tracing_mode = user_tracing_mode
|
@@ -47,13 +30,47 @@ module Oboe
|
|
47
30
|
end
|
48
31
|
end
|
49
32
|
|
50
|
-
|
51
|
-
say "You can change configuration values in the future by modifying config/initializers/oboe.rb"
|
52
|
-
say ""
|
53
|
-
say "Thanks! Creating the TraceView initializer..."
|
54
|
-
say ""
|
33
|
+
print_footer
|
55
34
|
|
56
35
|
template "oboe_initializer.rb", "config/initializers/oboe.rb"
|
57
36
|
end
|
37
|
+
|
38
|
+
private
|
39
|
+
|
40
|
+
def print_header
|
41
|
+
say ""
|
42
|
+
say shell.set_color "Welcome to the TraceView Ruby instrumentation setup.", :green, :bold
|
43
|
+
say ""
|
44
|
+
say "To instrument your Rails application, you can setup your tracing strategy here."
|
45
|
+
say ""
|
46
|
+
say shell.set_color "Documentation Links", :magenta
|
47
|
+
say "-------------------"
|
48
|
+
say ""
|
49
|
+
say "Details on configuring your sample rate:"
|
50
|
+
say "http://support.tv.appneta.com/support/solutions/articles/86336-configuring-sampling"
|
51
|
+
say ""
|
52
|
+
say "More information on instrumenting Ruby applications can be found here:"
|
53
|
+
say "http://support.tv.appneta.com/support/solutions/articles/86393-instrumenting-ruby-apps"
|
54
|
+
end
|
55
|
+
|
56
|
+
def print_body
|
57
|
+
say ""
|
58
|
+
say shell.set_color "Tracing Mode", :magenta
|
59
|
+
say "------------"
|
60
|
+
say "Tracing Mode determines when traces should be initiated for incoming requests. Valid"
|
61
|
+
say "options are #{shell.set_color "always", :yellow}, #{shell.set_color "through", :yellow} (when using an instrumented Apache or Nginx) and #{shell.set_color "never", :yellow}."
|
62
|
+
say ""
|
63
|
+
say "If you're not using an instrumented Apache or Nginx, set this directive to #{shell.set_color "always", :yellow} in"
|
64
|
+
say "order to initiate tracing from Ruby."
|
65
|
+
say ""
|
66
|
+
end
|
67
|
+
|
68
|
+
def print_footer
|
69
|
+
say ""
|
70
|
+
say "You can change configuration values in the future by modifying config/initializers/oboe.rb"
|
71
|
+
say ""
|
72
|
+
say "Thanks! Creating the TraceView initializer..."
|
73
|
+
say ""
|
74
|
+
end
|
58
75
|
end
|
59
76
|
end
|
@@ -79,4 +79,14 @@ if defined?(Oboe::Config)
|
|
79
79
|
# Oboe::Config[:nethttp][:collect_backtraces] = true
|
80
80
|
# Oboe::Config[:resque][:collect_backtraces] = true
|
81
81
|
#
|
82
|
+
|
83
|
+
#
|
84
|
+
# Blacklist actions
|
85
|
+
#
|
86
|
+
# e.g. if your load balancer requests 'index#ok'
|
87
|
+
#
|
88
|
+
# Oboe::Config[:action_blacklist] = {
|
89
|
+
# 'index#ok' => true
|
90
|
+
# }
|
91
|
+
|
82
92
|
end
|
data/oboe.gemspec
CHANGED
@@ -6,9 +6,11 @@ Gem::Specification.new do |s|
|
|
6
6
|
s.version = Oboe::Version::STRING
|
7
7
|
s.date = Time.now.strftime('%Y-%m-%d')
|
8
8
|
|
9
|
+
s.license = "AppNeta Open License, Version 1.0"
|
10
|
+
|
9
11
|
s.authors = ["Peter Giacomo Lombardo", "Spiros Eliopoulos"]
|
10
12
|
s.email = %q{traceviewsupport@appneta.com}
|
11
|
-
s.homepage = %q{http://www.appneta.com/
|
13
|
+
s.homepage = %q{http://www.appneta.com/products/traceview/}
|
12
14
|
s.summary = %q{AppNeta TraceView performance instrumentation gem for Ruby}
|
13
15
|
s.description = %q{The oboe gem provides TraceView instrumentation for Ruby and Ruby frameworks.}
|
14
16
|
|
@@ -19,7 +21,7 @@ Gem::Specification.new do |s|
|
|
19
21
|
s.extensions = ['ext/oboe_metal/extconf.rb']
|
20
22
|
|
21
23
|
s.add_development_dependency 'rake'
|
22
|
-
|
23
|
-
s.
|
24
|
+
|
25
|
+
s.add_runtime_dependency('json', '>= 0')
|
24
26
|
end
|
25
27
|
|
@@ -1,386 +1,377 @@
|
|
1
1
|
require 'minitest_helper'
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
# https://github.com/travis-ci/travis-ci/issues/1203
|
7
|
-
# https://github.com/travis-ci/travis-ci/issues/1053
|
8
|
-
if false
|
3
|
+
describe Oboe::Inst::Cassandra do
|
4
|
+
before do
|
5
|
+
clear_all_traces
|
9
6
|
|
10
|
-
|
11
|
-
|
12
|
-
clear_all_traces
|
7
|
+
@client = Cassandra.new("system", "127.0.0.1:9160", { :timeout => 10 })
|
8
|
+
@client.disable_node_auto_discovery!
|
13
9
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
unless @client.column_families.include? "Users"
|
28
|
-
cf_def = CassandraThrift::CfDef.new(:keyspace => @ks_name, :name => "Users")
|
29
|
-
@client.add_column_family(cf_def)
|
30
|
-
end
|
31
|
-
|
32
|
-
unless @client.column_families.include? "Statuses"
|
33
|
-
cf_def = CassandraThrift::CfDef.new(:keyspace => @ks_name, :name => "Statuses")
|
34
|
-
@client.add_column_family(cf_def)
|
35
|
-
end
|
36
|
-
|
37
|
-
# These are standard entry/exit KVs that are passed up with all mongo operations
|
38
|
-
@entry_kvs = {
|
39
|
-
'Layer' => 'cassandra',
|
40
|
-
'Label' => 'entry',
|
41
|
-
'RemoteHost' => '127.0.0.1',
|
42
|
-
'RemotePort' => '9160' }
|
43
|
-
|
44
|
-
@exit_kvs = { 'Layer' => 'cassandra', 'Label' => 'exit' }
|
45
|
-
@collect_backtraces = Oboe::Config[:cassandra][:collect_backtraces]
|
10
|
+
@ks_name = "AppNetaCassandraTest"
|
11
|
+
|
12
|
+
ks_def = CassandraThrift::KsDef.new(:name => @ks_name,
|
13
|
+
:strategy_class => "SimpleStrategy",
|
14
|
+
:strategy_options => { 'replication_factor' => '2' },
|
15
|
+
:cf_defs => [])
|
16
|
+
|
17
|
+
@client.add_keyspace(ks_def) unless @client.keyspaces.include? @ks_name
|
18
|
+
@client.keyspace = @ks_name
|
19
|
+
|
20
|
+
unless @client.column_families.include? "Users"
|
21
|
+
cf_def = CassandraThrift::CfDef.new(:keyspace => @ks_name, :name => "Users")
|
22
|
+
@client.add_column_family(cf_def)
|
46
23
|
end
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
@client.
|
24
|
+
|
25
|
+
unless @client.column_families.include? "Statuses"
|
26
|
+
cf_def = CassandraThrift::CfDef.new(:keyspace => @ks_name, :name => "Statuses")
|
27
|
+
@client.add_column_family(cf_def)
|
51
28
|
end
|
52
29
|
|
53
|
-
|
54
|
-
|
30
|
+
# These are standard entry/exit KVs that are passed up with all mongo operations
|
31
|
+
@entry_kvs = {
|
32
|
+
'Layer' => 'cassandra',
|
33
|
+
'Label' => 'entry',
|
34
|
+
'RemoteHost' => '127.0.0.1',
|
35
|
+
'RemotePort' => '9160' }
|
36
|
+
|
37
|
+
@exit_kvs = { 'Layer' => 'cassandra', 'Label' => 'exit' }
|
38
|
+
@collect_backtraces = Oboe::Config[:cassandra][:collect_backtraces]
|
39
|
+
end
|
40
|
+
|
41
|
+
after do
|
42
|
+
Oboe::Config[:cassandra][:collect_backtraces] = @collect_backtraces
|
43
|
+
@client.disconnect!
|
44
|
+
end
|
45
|
+
|
46
|
+
it 'Stock Cassandra should be loaded, defined and ready' do
|
47
|
+
defined?(::Cassandra).wont_match nil
|
48
|
+
end
|
49
|
+
|
50
|
+
it 'Cassandra should have oboe methods defined' do
|
51
|
+
[ :insert, :remove, :count_columns, :get_columns, :multi_get_columns, :get,
|
52
|
+
:multi_get, :get_range_single, :get_range_batch, :get_indexed_slices,
|
53
|
+
:create_index, :drop_index, :add_column_family, :drop_column_family,
|
54
|
+
:add_keyspace, :drop_keyspace ].each do |m|
|
55
|
+
::Cassandra.method_defined?("#{m}_with_oboe").must_equal true
|
56
|
+
end
|
57
|
+
# Special 'exists?' case
|
58
|
+
::Cassandra.method_defined?("exists_with_oboe?").must_equal true
|
59
|
+
end
|
60
|
+
|
61
|
+
it 'should trace insert' do
|
62
|
+
Oboe::API.start_trace('cassandra_test', '', {}) do
|
63
|
+
user = {'screen_name' => 'larry', "blah" => "ok"}
|
64
|
+
@client.insert(:Users, '5', user, { :ttl => 600, :consistency => 1})
|
55
65
|
end
|
66
|
+
|
67
|
+
traces = get_all_traces
|
68
|
+
|
69
|
+
traces.count.must_equal 4
|
70
|
+
validate_outer_layers(traces, 'cassandra_test')
|
71
|
+
|
72
|
+
validate_event_keys(traces[1], @entry_kvs)
|
73
|
+
traces[1]['Op'].must_equal "insert"
|
74
|
+
traces[1]['Cf'].must_equal "Users"
|
75
|
+
traces[1]['Key'].must_equal "\"5\""
|
76
|
+
traces[1]['Consistency'].must_equal "1"
|
77
|
+
traces[1]['Ttl'].must_equal "600"
|
78
|
+
traces[1].has_key?('Backtrace').must_equal Oboe::Config[:cassandra][:collect_backtraces]
|
79
|
+
validate_event_keys(traces[2], @exit_kvs)
|
80
|
+
end
|
56
81
|
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
:create_index, :drop_index, :add_column_family, :drop_column_family,
|
61
|
-
:add_keyspace, :drop_keyspace ].each do |m|
|
62
|
-
::Cassandra.method_defined?("#{m}_with_oboe").must_equal true
|
63
|
-
end
|
64
|
-
# Special 'exists?' case
|
65
|
-
::Cassandra.method_defined?("exists_with_oboe?").must_equal true
|
82
|
+
it 'should trace remove' do
|
83
|
+
Oboe::API.start_trace('cassandra_test', '', {}) do
|
84
|
+
@client.remove(:Users, '5', 'blah')
|
66
85
|
end
|
67
86
|
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
validate_event_keys(traces[2], @exit_kvs)
|
87
|
+
traces = get_all_traces
|
88
|
+
|
89
|
+
traces.count.must_equal 4
|
90
|
+
validate_outer_layers(traces, 'cassandra_test')
|
91
|
+
|
92
|
+
validate_event_keys(traces[1], @entry_kvs)
|
93
|
+
traces[1]['Op'].must_equal "remove"
|
94
|
+
traces[1]['Cf'].must_equal "Users"
|
95
|
+
traces[1]['Key'].must_equal "\"5\""
|
96
|
+
traces[1].has_key?('Backtrace').must_equal Oboe::Config[:cassandra][:collect_backtraces]
|
97
|
+
validate_event_keys(traces[2], @exit_kvs)
|
98
|
+
end
|
99
|
+
|
100
|
+
it 'should trace count_columns' do
|
101
|
+
@client.insert(:Statuses, '12', {'body' => 'v1', 'user' => 'v2'})
|
102
|
+
|
103
|
+
Oboe::API.start_trace('cassandra_test', '', {}) do
|
104
|
+
@client.count_columns(:Statuses, '12', :count => 50)
|
87
105
|
end
|
106
|
+
|
107
|
+
traces = get_all_traces
|
108
|
+
|
109
|
+
traces.count.must_equal 4
|
110
|
+
validate_outer_layers(traces, 'cassandra_test')
|
111
|
+
|
112
|
+
validate_event_keys(traces[1], @entry_kvs)
|
113
|
+
traces[1]['Op'].must_equal "count_columns"
|
114
|
+
traces[1]['Cf'].must_equal "Statuses"
|
115
|
+
traces[1]['Key'].must_equal "\"12\""
|
116
|
+
traces[1]['Count'].must_equal "50"
|
117
|
+
traces[1].has_key?('Backtrace').must_equal Oboe::Config[:cassandra][:collect_backtraces]
|
118
|
+
validate_event_keys(traces[2], @exit_kvs)
|
119
|
+
end
|
88
120
|
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
end
|
93
|
-
|
94
|
-
traces = get_all_traces
|
95
|
-
|
96
|
-
traces.count.must_equal 4
|
97
|
-
validate_outer_layers(traces, 'cassandra_test')
|
98
|
-
|
99
|
-
validate_event_keys(traces[1], @entry_kvs)
|
100
|
-
traces[1]['Op'].must_equal "remove"
|
101
|
-
traces[1]['Cf'].must_equal "Users"
|
102
|
-
traces[1]['Key'].must_equal "\"5\""
|
103
|
-
traces[1].has_key?('Backtrace').must_equal Oboe::Config[:cassandra][:collect_backtraces]
|
104
|
-
validate_event_keys(traces[2], @exit_kvs)
|
121
|
+
it 'should trace get_columns' do
|
122
|
+
Oboe::API.start_trace('cassandra_test', '', {}) do
|
123
|
+
@client.get_columns(:Statuses, '12', ['body'])
|
105
124
|
end
|
106
125
|
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
validate_event_keys(traces[1], @entry_kvs)
|
120
|
-
traces[1]['Op'].must_equal "count_columns"
|
121
|
-
traces[1]['Cf'].must_equal "Statuses"
|
122
|
-
traces[1]['Key'].must_equal "\"12\""
|
123
|
-
traces[1]['Count'].must_equal "50"
|
124
|
-
traces[1].has_key?('Backtrace').must_equal Oboe::Config[:cassandra][:collect_backtraces]
|
125
|
-
validate_event_keys(traces[2], @exit_kvs)
|
126
|
-
end
|
126
|
+
traces = get_all_traces
|
127
|
+
|
128
|
+
traces.count.must_equal 4
|
129
|
+
validate_outer_layers(traces, 'cassandra_test')
|
130
|
+
|
131
|
+
validate_event_keys(traces[1], @entry_kvs)
|
132
|
+
traces[1]['Op'].must_equal "get_columns"
|
133
|
+
traces[1]['Cf'].must_equal "Statuses"
|
134
|
+
traces[1]['Key'].must_equal "\"12\""
|
135
|
+
traces[1].has_key?('Backtrace').must_equal Oboe::Config[:cassandra][:collect_backtraces]
|
136
|
+
validate_event_keys(traces[2], @exit_kvs)
|
137
|
+
end
|
127
138
|
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
end
|
132
|
-
|
133
|
-
traces = get_all_traces
|
134
|
-
|
135
|
-
traces.count.must_equal 4
|
136
|
-
validate_outer_layers(traces, 'cassandra_test')
|
137
|
-
|
138
|
-
validate_event_keys(traces[1], @entry_kvs)
|
139
|
-
traces[1]['Op'].must_equal "get_columns"
|
140
|
-
traces[1]['Cf'].must_equal "Statuses"
|
141
|
-
traces[1]['Key'].must_equal "\"12\""
|
142
|
-
traces[1].has_key?('Backtrace').must_equal Oboe::Config[:cassandra][:collect_backtraces]
|
143
|
-
validate_event_keys(traces[2], @exit_kvs)
|
139
|
+
it 'should trace multi_get_columns' do
|
140
|
+
Oboe::API.start_trace('cassandra_test', '', {}) do
|
141
|
+
@client.multi_get_columns(:Users, ['12', '5'], ['body'])
|
144
142
|
end
|
143
|
+
|
144
|
+
traces = get_all_traces
|
145
|
+
|
146
|
+
traces.count.must_equal 4
|
147
|
+
validate_outer_layers(traces, 'cassandra_test')
|
148
|
+
|
149
|
+
validate_event_keys(traces[1], @entry_kvs)
|
150
|
+
traces[1]['Op'].must_equal "multi_get_columns"
|
151
|
+
traces[1]['Cf'].must_equal "Users"
|
152
|
+
traces[1]['Key'].must_equal "[\"12\", \"5\"]"
|
153
|
+
traces[1].has_key?('Backtrace').must_equal Oboe::Config[:cassandra][:collect_backtraces]
|
154
|
+
validate_event_keys(traces[2], @exit_kvs)
|
155
|
+
end
|
145
156
|
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
end
|
150
|
-
|
151
|
-
traces = get_all_traces
|
152
|
-
|
153
|
-
traces.count.must_equal 4
|
154
|
-
validate_outer_layers(traces, 'cassandra_test')
|
155
|
-
|
156
|
-
validate_event_keys(traces[1], @entry_kvs)
|
157
|
-
traces[1]['Op'].must_equal "multi_get_columns"
|
158
|
-
traces[1]['Cf'].must_equal "Users"
|
159
|
-
traces[1]['Key'].must_equal "[\"12\", \"5\"]"
|
160
|
-
traces[1].has_key?('Backtrace').must_equal Oboe::Config[:cassandra][:collect_backtraces]
|
161
|
-
validate_event_keys(traces[2], @exit_kvs)
|
157
|
+
it 'should trace get' do
|
158
|
+
Oboe::API.start_trace('cassandra_test', '', {}) do
|
159
|
+
@client.get(:Statuses, '12', :reversed => true)
|
162
160
|
end
|
161
|
+
|
162
|
+
traces = get_all_traces
|
163
|
+
|
164
|
+
traces.count.must_equal 4
|
165
|
+
validate_outer_layers(traces, 'cassandra_test')
|
166
|
+
|
167
|
+
validate_event_keys(traces[1], @entry_kvs)
|
168
|
+
traces[1]['Op'].must_equal "get"
|
169
|
+
traces[1]['Cf'].must_equal "Statuses"
|
170
|
+
traces[1]['Key'].must_equal "\"12\""
|
171
|
+
traces[1]['Reversed'].must_equal "true"
|
172
|
+
traces[1].has_key?('Backtrace').must_equal Oboe::Config[:cassandra][:collect_backtraces]
|
173
|
+
validate_event_keys(traces[2], @exit_kvs)
|
174
|
+
end
|
163
175
|
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
traces = get_all_traces
|
170
|
-
|
171
|
-
traces.count.must_equal 4
|
172
|
-
validate_outer_layers(traces, 'cassandra_test')
|
173
|
-
|
174
|
-
validate_event_keys(traces[1], @entry_kvs)
|
175
|
-
traces[1]['Op'].must_equal "get"
|
176
|
-
traces[1]['Cf'].must_equal "Statuses"
|
177
|
-
traces[1]['Key'].must_equal "\"12\""
|
178
|
-
traces[1]['Reversed'].must_equal "true"
|
179
|
-
traces[1].has_key?('Backtrace').must_equal Oboe::Config[:cassandra][:collect_backtraces]
|
180
|
-
validate_event_keys(traces[2], @exit_kvs)
|
176
|
+
it 'should trace exists?' do
|
177
|
+
Oboe::API.start_trace('cassandra_test', '', {}) do
|
178
|
+
@client.exists?(:Statuses, '12')
|
179
|
+
@client.exists?(:Statuses, '12', 'body')
|
181
180
|
end
|
181
|
+
|
182
|
+
traces = get_all_traces
|
183
|
+
|
184
|
+
traces.count.must_equal 6
|
185
|
+
validate_outer_layers(traces, 'cassandra_test')
|
186
|
+
|
187
|
+
validate_event_keys(traces[1], @entry_kvs)
|
188
|
+
traces[1]['Op'].must_equal "exists?"
|
189
|
+
traces[1]['Cf'].must_equal "Statuses"
|
190
|
+
traces[1]['Key'].must_equal "\"12\""
|
191
|
+
traces[1].has_key?('Backtrace').must_equal Oboe::Config[:cassandra][:collect_backtraces]
|
192
|
+
validate_event_keys(traces[2], @exit_kvs)
|
193
|
+
|
194
|
+
traces[3]['Op'].must_equal "exists?"
|
195
|
+
traces[3]['Cf'].must_equal "Statuses"
|
196
|
+
traces[3]['Key'].must_equal "\"12\""
|
197
|
+
traces[3].has_key?('Backtrace').must_equal Oboe::Config[:cassandra][:collect_backtraces]
|
198
|
+
end
|
182
199
|
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
@client.exists?(:Statuses, '12', 'body')
|
187
|
-
end
|
188
|
-
|
189
|
-
traces = get_all_traces
|
190
|
-
|
191
|
-
traces.count.must_equal 6
|
192
|
-
validate_outer_layers(traces, 'cassandra_test')
|
193
|
-
|
194
|
-
validate_event_keys(traces[1], @entry_kvs)
|
195
|
-
traces[1]['Op'].must_equal "exists?"
|
196
|
-
traces[1]['Cf'].must_equal "Statuses"
|
197
|
-
traces[1]['Key'].must_equal "\"12\""
|
198
|
-
traces[1].has_key?('Backtrace').must_equal Oboe::Config[:cassandra][:collect_backtraces]
|
199
|
-
validate_event_keys(traces[2], @exit_kvs)
|
200
|
-
|
201
|
-
traces[3]['Op'].must_equal "exists?"
|
202
|
-
traces[3]['Cf'].must_equal "Statuses"
|
203
|
-
traces[3]['Key'].must_equal "\"12\""
|
204
|
-
traces[3].has_key?('Backtrace').must_equal Oboe::Config[:cassandra][:collect_backtraces]
|
200
|
+
it 'should trace get_range_keys' do
|
201
|
+
Oboe::API.start_trace('cassandra_test', '', {}) do
|
202
|
+
@client.get_range_keys(:Statuses, :key_count => 4)
|
205
203
|
end
|
204
|
+
|
205
|
+
traces = get_all_traces
|
206
|
+
|
207
|
+
traces.count.must_equal 4
|
208
|
+
validate_outer_layers(traces, 'cassandra_test')
|
209
|
+
|
210
|
+
validate_event_keys(traces[1], @entry_kvs)
|
211
|
+
traces[1]['Op'].must_equal "get_range_batch"
|
212
|
+
traces[1]['Cf'].must_equal "Statuses"
|
213
|
+
traces[1].has_key?('Backtrace').must_equal Oboe::Config[:cassandra][:collect_backtraces]
|
214
|
+
validate_event_keys(traces[2], @exit_kvs)
|
215
|
+
end
|
206
216
|
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
end
|
211
|
-
|
212
|
-
traces = get_all_traces
|
213
|
-
|
214
|
-
traces.count.must_equal 4
|
215
|
-
validate_outer_layers(traces, 'cassandra_test')
|
216
|
-
|
217
|
-
validate_event_keys(traces[1], @entry_kvs)
|
218
|
-
traces[1]['Op'].must_equal "get_range_batch"
|
219
|
-
traces[1]['Cf'].must_equal "Statuses"
|
220
|
-
traces[1].has_key?('Backtrace').must_equal Oboe::Config[:cassandra][:collect_backtraces]
|
221
|
-
validate_event_keys(traces[2], @exit_kvs)
|
217
|
+
it 'should trace create_index' do
|
218
|
+
Oboe::API.start_trace('cassandra_test', '', {}) do
|
219
|
+
@client.create_index(@ks_name, 'Statuses', 'column_name', 'LongType')
|
222
220
|
end
|
223
221
|
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
222
|
+
traces = get_all_traces
|
223
|
+
|
224
|
+
traces.count.must_equal 4
|
225
|
+
validate_outer_layers(traces, 'cassandra_test')
|
226
|
+
|
227
|
+
validate_event_keys(traces[1], @entry_kvs)
|
228
|
+
traces[1]['Op'].must_equal "create_index"
|
229
|
+
traces[1]['Cf'].must_equal "Statuses"
|
230
|
+
traces[1]['Keyspace'].must_equal @ks_name
|
231
|
+
traces[1]['Column_name'].must_equal "column_name"
|
232
|
+
traces[1]['Validation_class'].must_equal "LongType"
|
233
|
+
traces[1].has_key?('Backtrace').must_equal Oboe::Config[:cassandra][:collect_backtraces]
|
234
|
+
validate_event_keys(traces[2], @exit_kvs)
|
235
|
+
|
236
|
+
# Clean up
|
237
|
+
@client.drop_index(@ks_name, 'Statuses', 'column_name')
|
238
|
+
end
|
239
|
+
|
240
|
+
it 'should trace drop_index' do
|
241
|
+
# Prep
|
242
|
+
@client.create_index(@ks_name, 'Statuses', 'column_name', 'LongType')
|
228
243
|
|
229
|
-
|
230
|
-
|
231
|
-
traces.count.must_equal 4
|
232
|
-
validate_outer_layers(traces, 'cassandra_test')
|
233
|
-
|
234
|
-
validate_event_keys(traces[1], @entry_kvs)
|
235
|
-
traces[1]['Op'].must_equal "create_index"
|
236
|
-
traces[1]['Cf'].must_equal "Statuses"
|
237
|
-
traces[1]['Keyspace'].must_equal @ks_name
|
238
|
-
traces[1]['Column_name'].must_equal "column_name"
|
239
|
-
traces[1]['Validation_class'].must_equal "LongType"
|
240
|
-
traces[1].has_key?('Backtrace').must_equal Oboe::Config[:cassandra][:collect_backtraces]
|
241
|
-
validate_event_keys(traces[2], @exit_kvs)
|
242
|
-
|
243
|
-
# Clean up
|
244
|
+
Oboe::API.start_trace('cassandra_test', '', {}) do
|
244
245
|
@client.drop_index(@ks_name, 'Statuses', 'column_name')
|
245
246
|
end
|
246
247
|
|
247
|
-
|
248
|
-
|
249
|
-
|
248
|
+
traces = get_all_traces
|
249
|
+
|
250
|
+
traces.count.must_equal 4
|
251
|
+
validate_outer_layers(traces, 'cassandra_test')
|
252
|
+
|
253
|
+
validate_event_keys(traces[1], @entry_kvs)
|
254
|
+
traces[1]['Op'].must_equal "drop_index"
|
255
|
+
traces[1]['Cf'].must_equal "Statuses"
|
256
|
+
traces[1]['Keyspace'].must_equal @ks_name
|
257
|
+
traces[1]['Column_name'].must_equal "column_name"
|
258
|
+
traces[1].has_key?('Backtrace').must_equal Oboe::Config[:cassandra][:collect_backtraces]
|
259
|
+
validate_event_keys(traces[2], @exit_kvs)
|
260
|
+
end
|
250
261
|
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
traces[1]['Cf'].must_equal "Statuses"
|
263
|
-
traces[1]['Keyspace'].must_equal @ks_name
|
264
|
-
traces[1]['Column_name'].must_equal "column_name"
|
265
|
-
traces[1].has_key?('Backtrace').must_equal Oboe::Config[:cassandra][:collect_backtraces]
|
266
|
-
validate_event_keys(traces[2], @exit_kvs)
|
262
|
+
it 'should trace get_indexed_slices' do
|
263
|
+
@client.create_index(@ks_name, 'Statuses', 'x', 'LongType')
|
264
|
+
Oboe::API.start_trace('cassandra_test', '', {}) do
|
265
|
+
expressions = [
|
266
|
+
{ :column_name => 'x',
|
267
|
+
:value => [0,20].pack("NN"),
|
268
|
+
:comparison => "=="},
|
269
|
+
{ :column_name => 'non_indexed',
|
270
|
+
:value => [5].pack("N*"),
|
271
|
+
:comparison => ">"} ]
|
272
|
+
@client.get_indexed_slices(:Statuses, expressions).length
|
267
273
|
end
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
traces[1]['Op'].must_equal "get_indexed_slices"
|
289
|
-
traces[1]['Cf'].must_equal "Statuses"
|
290
|
-
traces[1].has_key?('Backtrace').must_equal Oboe::Config[:cassandra][:collect_backtraces]
|
291
|
-
validate_event_keys(traces[2], @exit_kvs)
|
274
|
+
|
275
|
+
traces = get_all_traces
|
276
|
+
|
277
|
+
traces.count.must_equal 4
|
278
|
+
validate_outer_layers(traces, 'cassandra_test')
|
279
|
+
|
280
|
+
validate_event_keys(traces[1], @entry_kvs)
|
281
|
+
traces[1]['Op'].must_equal "get_indexed_slices"
|
282
|
+
traces[1]['Cf'].must_equal "Statuses"
|
283
|
+
traces[1].has_key?('Backtrace').must_equal Oboe::Config[:cassandra][:collect_backtraces]
|
284
|
+
validate_event_keys(traces[2], @exit_kvs)
|
285
|
+
end
|
286
|
+
|
287
|
+
it 'should trace add and remove of column family' do
|
288
|
+
cf_name = (0...10).map{ ('a'..'z').to_a[rand(26)] }.join
|
289
|
+
cf_def = CassandraThrift::CfDef.new(:keyspace => @ks_name, :name => cf_name)
|
290
|
+
|
291
|
+
Oboe::API.start_trace('cassandra_test', '', {}) do
|
292
|
+
@client.add_column_family(cf_def)
|
293
|
+
@client.drop_column_family(cf_name)
|
292
294
|
end
|
293
295
|
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
Oboe::API.start_trace('cassandra_test', '', {}) do
|
299
|
-
@client.add_column_family(cf_def)
|
300
|
-
@client.drop_column_family(cf_name)
|
301
|
-
end
|
302
|
-
|
303
|
-
traces = get_all_traces
|
304
|
-
|
305
|
-
traces.count.must_equal 6
|
306
|
-
validate_outer_layers(traces, 'cassandra_test')
|
296
|
+
traces = get_all_traces
|
297
|
+
|
298
|
+
traces.count.must_equal 6
|
299
|
+
validate_outer_layers(traces, 'cassandra_test')
|
307
300
|
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
traces[3]['Op'].must_equal "drop_column_family"
|
314
|
-
traces[3]['Cf'].must_equal cf_name
|
315
|
-
traces[3].has_key?('Backtrace').must_equal Oboe::Config[:cassandra][:collect_backtraces]
|
316
|
-
end
|
301
|
+
validate_event_keys(traces[1], @entry_kvs)
|
302
|
+
traces[1]['Op'].must_equal "add_column_family"
|
303
|
+
traces[1].has_key?('Backtrace').must_equal Oboe::Config[:cassandra][:collect_backtraces]
|
304
|
+
validate_event_keys(traces[2], @exit_kvs)
|
317
305
|
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
validate_outer_layers(traces, 'cassandra_test')
|
335
|
-
|
336
|
-
validate_event_keys(traces[1], @entry_kvs)
|
337
|
-
traces[1]['Op'].must_equal "add_keyspace"
|
338
|
-
traces[1]['Name'].must_equal ks_name
|
339
|
-
traces[1].has_key?('Backtrace').must_equal Oboe::Config[:cassandra][:collect_backtraces]
|
340
|
-
validate_event_keys(traces[2], @exit_kvs)
|
306
|
+
traces[3]['Op'].must_equal "drop_column_family"
|
307
|
+
traces[3]['Cf'].must_equal cf_name
|
308
|
+
traces[3].has_key?('Backtrace').must_equal Oboe::Config[:cassandra][:collect_backtraces]
|
309
|
+
end
|
310
|
+
|
311
|
+
it 'should trace adding a keyspace' do
|
312
|
+
ks_name = (0...10).map{ ('a'..'z').to_a[rand(26)] }.join
|
313
|
+
column_families = [{:name =>"a"}, {:name => "b", :type => :super}]
|
314
|
+
ks_def = CassandraThrift::KsDef.new(:name => ks_name,
|
315
|
+
:strategy_class => "org.apache.cassandra.locator.SimpleStrategy",
|
316
|
+
:strategy_options => { 'replication_factor' => '2' },
|
317
|
+
:cf_defs => [])
|
318
|
+
|
319
|
+
Oboe::API.start_trace('cassandra_test', '', {}) do
|
320
|
+
@client.add_keyspace(ks_def)
|
321
|
+
@client.keyspace = ks_name
|
341
322
|
end
|
342
323
|
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
|
324
|
+
traces = get_all_traces
|
325
|
+
|
326
|
+
traces.count.must_equal 4
|
327
|
+
validate_outer_layers(traces, 'cassandra_test')
|
328
|
+
|
329
|
+
validate_event_keys(traces[1], @entry_kvs)
|
330
|
+
traces[1]['Op'].must_equal "add_keyspace"
|
331
|
+
traces[1]['Name'].must_equal ks_name
|
332
|
+
traces[1].has_key?('Backtrace').must_equal Oboe::Config[:cassandra][:collect_backtraces]
|
333
|
+
validate_event_keys(traces[2], @exit_kvs)
|
334
|
+
end
|
335
|
+
|
336
|
+
it 'should trace the removal of a keyspace' do
|
337
|
+
Oboe::API.start_trace('cassandra_test', '', {}) do
|
338
|
+
@client.drop_keyspace(@ks_name)
|
358
339
|
end
|
359
340
|
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
|
341
|
+
traces = get_all_traces
|
342
|
+
|
343
|
+
traces.count.must_equal 4
|
344
|
+
validate_outer_layers(traces, 'cassandra_test')
|
345
|
+
|
346
|
+
validate_event_keys(traces[1], @entry_kvs)
|
347
|
+
traces[1]['Op'].must_equal "drop_keyspace"
|
348
|
+
traces[1]['Name'].must_equal @ks_name
|
349
|
+
traces[1].has_key?('Backtrace').must_equal Oboe::Config[:cassandra][:collect_backtraces]
|
350
|
+
validate_event_keys(traces[2], @exit_kvs)
|
351
|
+
end
|
352
|
+
|
353
|
+
it "should obey :collect_backtraces setting when true" do
|
354
|
+
Oboe::Config[:cassandra][:collect_backtraces] = true
|
367
355
|
|
368
|
-
|
369
|
-
|
356
|
+
Oboe::API.start_trace('cassandra_test', '', {}) do
|
357
|
+
user = {'screen_name' => 'larry', "blah" => "ok"}
|
358
|
+
@client.insert(:Users, '5', user, { :ttl => 600, :consistency => 1})
|
370
359
|
end
|
371
360
|
|
372
|
-
|
373
|
-
|
361
|
+
traces = get_all_traces
|
362
|
+
layer_has_key(traces, 'cassandra', 'Backtrace')
|
363
|
+
end
|
374
364
|
|
375
|
-
|
376
|
-
|
377
|
-
@client.insert(:Users, '5', user, { :ttl => 600, :consistency => 1})
|
378
|
-
end
|
365
|
+
it "should obey :collect_backtraces setting when false" do
|
366
|
+
Oboe::Config[:cassandra][:collect_backtraces] = false
|
379
367
|
|
380
|
-
|
381
|
-
|
368
|
+
Oboe::API.start_trace('cassandra_test', '', {}) do
|
369
|
+
user = {'screen_name' => 'larry', "blah" => "ok"}
|
370
|
+
@client.insert(:Users, '5', user, { :ttl => 600, :consistency => 1})
|
382
371
|
end
|
383
|
-
|
384
|
-
end
|
385
372
|
|
386
|
-
|
373
|
+
traces = get_all_traces
|
374
|
+
layer_doesnt_have_key(traces, 'cassandra', 'Backtrace')
|
375
|
+
end
|
376
|
+
|
377
|
+
end
|