oboe 2.3.4.1 → 2.4.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -17,8 +17,12 @@ module Oboe
17
17
  begin
18
18
  req = ::Rack::Request.new(env)
19
19
 
20
- report_kvs[:SampleRate] = Oboe::Config[:sample_rate]
21
- report_kvs[:SampleSource] = Oboe::Config[:sample_source]
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
@@ -2,6 +2,7 @@
2
2
  # All rights reserved.
3
3
 
4
4
  require 'socket'
5
+ require 'json'
5
6
 
6
7
  module Oboe
7
8
  module Inst
@@ -4,8 +4,8 @@
4
4
  module Oboe
5
5
  module Version
6
6
  MAJOR = 2
7
- MINOR = 3
8
- PATCH = 4
7
+ MINOR = 4
8
+ PATCH = 0
9
9
  BUILD = 1
10
10
 
11
11
  STRING = [MAJOR, MINOR, PATCH, BUILD].compact.join('.')
@@ -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
- Oboe::Context.sampleRequest(opts[:layer], opts[:xtrace], opts['X-TV-Meta'])
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
- # OBOE_TRACE_NEVER
90
- Oboe::Context.setTracingMode(0)
100
+ Oboe::Context.setTracingMode(OBOE_TRACE_NEVER)
101
+
91
102
  when :always
92
- # OBOE_TRACE_ALWAYS
93
- Oboe::Context.setTracingMode(1)
103
+ Oboe::Context.setTracingMode(OBOE_TRACE_ALWAYS)
104
+
94
105
  when :through
95
- # OBOE_TRACE_THROUGH
96
- Oboe::Context.setTracingMode(2)
106
+ Oboe::Context.setTracingMode(OBOE_TRACE_THROUGH)
107
+
97
108
  else
98
109
  Oboe.logger.fatal "[oboe/error] Invalid tracing mode set: #{mode}"
99
- # OBOE_TRACE_THROUGH
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
- say ""
16
- say shell.set_color "Welcome to the TraceView Ruby instrumentation setup.", :green, :bold
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
- say ""
30
- say shell.set_color "Tracing Mode", :magenta
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
- say ""
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
@@ -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/application-performance-management}
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
- s.add_development_dependency 'minitest'
23
- s.add_development_dependency 'bson'
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
- # Disable Cassandra tests until TravisCI issues are cleared up.
4
- # https://github.com/travis-ci/travis-ci/issues/1053
5
- # https://github.com/travis-ci/travis-ci/issues/840
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
- describe Oboe::Inst::Cassandra do
11
- before do
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
- @client = Cassandra.new("system", "127.0.0.1:9160", { :timeout => 10 })
15
- @client.disable_node_auto_discovery!
16
-
17
- @ks_name = "AppNetaCassandraTest"
18
-
19
- ks_def = CassandraThrift::KsDef.new(:name => @ks_name,
20
- :strategy_class => "SimpleStrategy",
21
- :strategy_options => { 'replication_factor' => '2' },
22
- :cf_defs => [])
23
-
24
- @client.add_keyspace(ks_def) unless @client.keyspaces.include? @ks_name
25
- @client.keyspace = @ks_name
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
- after do
49
- Oboe::Config[:cassandra][:collect_backtraces] = @collect_backtraces
50
- @client.disconnect!
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
- it 'Stock Cassandra should be loaded, defined and ready' do
54
- defined?(::Cassandra).wont_match nil
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
- it 'Cassandra should have oboe methods defined' do
58
- [ :insert, :remove, :count_columns, :get_columns, :multi_get_columns, :get,
59
- :multi_get, :get_range_single, :get_range_batch, :get_indexed_slices,
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
- it 'should trace insert' do
69
- Oboe::API.start_trace('cassandra_test', '', {}) do
70
- user = {'screen_name' => 'larry', "blah" => "ok"}
71
- @client.insert(:Users, '5', user, { :ttl => 600, :consistency => 1})
72
- end
73
-
74
- traces = get_all_traces
75
-
76
- traces.count.must_equal 4
77
- validate_outer_layers(traces, 'cassandra_test')
78
-
79
- validate_event_keys(traces[1], @entry_kvs)
80
- traces[1]['Op'].must_equal "insert"
81
- traces[1]['Cf'].must_equal "Users"
82
- traces[1]['Key'].must_equal "\"5\""
83
- traces[1]['Consistency'].must_equal "1"
84
- traces[1]['Ttl'].must_equal "600"
85
- traces[1].has_key?('Backtrace').must_equal Oboe::Config[:cassandra][:collect_backtraces]
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
- it 'should trace remove' do
90
- Oboe::API.start_trace('cassandra_test', '', {}) do
91
- @client.remove(:Users, '5', 'blah')
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
- it 'should trace count_columns' do
108
- @client.insert(:Statuses, '12', {'body' => 'v1', 'user' => 'v2'})
109
-
110
- Oboe::API.start_trace('cassandra_test', '', {}) do
111
- @client.count_columns(:Statuses, '12', :count => 50)
112
- end
113
-
114
- traces = get_all_traces
115
-
116
- traces.count.must_equal 4
117
- validate_outer_layers(traces, 'cassandra_test')
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
- it 'should trace get_columns' do
129
- Oboe::API.start_trace('cassandra_test', '', {}) do
130
- @client.get_columns(:Statuses, '12', ['body'])
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
- it 'should trace multi_get_columns' do
147
- Oboe::API.start_trace('cassandra_test', '', {}) do
148
- @client.multi_get_columns(:Users, ['12', '5'], ['body'])
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
- it 'should trace get' do
165
- Oboe::API.start_trace('cassandra_test', '', {}) do
166
- @client.get(:Statuses, '12', :reversed => true)
167
- end
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
- it 'should trace exists?' do
184
- Oboe::API.start_trace('cassandra_test', '', {}) do
185
- @client.exists?(:Statuses, '12')
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
- it 'should trace get_range_keys' do
208
- Oboe::API.start_trace('cassandra_test', '', {}) do
209
- @client.get_range_keys(:Statuses, :key_count => 4)
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
- it 'should trace create_index' do
225
- Oboe::API.start_trace('cassandra_test', '', {}) do
226
- @client.create_index(@ks_name, 'Statuses', 'column_name', 'LongType')
227
- end
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
- traces = get_all_traces
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
- it 'should trace drop_index' do
248
- # Prep
249
- @client.create_index(@ks_name, 'Statuses', 'column_name', 'LongType')
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
- Oboe::API.start_trace('cassandra_test', '', {}) do
252
- @client.drop_index(@ks_name, 'Statuses', 'column_name')
253
- end
254
-
255
- traces = get_all_traces
256
-
257
- traces.count.must_equal 4
258
- validate_outer_layers(traces, 'cassandra_test')
259
-
260
- validate_event_keys(traces[1], @entry_kvs)
261
- traces[1]['Op'].must_equal "drop_index"
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
- it 'should trace get_indexed_slices' do
270
- @client.create_index(@ks_name, 'Statuses', 'x', 'LongType')
271
- Oboe::API.start_trace('cassandra_test', '', {}) do
272
- expressions = [
273
- { :column_name => 'x',
274
- :value => [0,20].pack("NN"),
275
- :comparison => "=="},
276
- { :column_name => 'non_indexed',
277
- :value => [5].pack("N*"),
278
- :comparison => ">"} ]
279
- @client.get_indexed_slices(:Statuses, expressions).length
280
- end
281
-
282
- traces = get_all_traces
283
-
284
- traces.count.must_equal 4
285
- validate_outer_layers(traces, 'cassandra_test')
286
-
287
- validate_event_keys(traces[1], @entry_kvs)
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
- it 'should trace add and remove of column family' do
295
- cf_name = (0...10).map{ ('a'..'z').to_a[rand(26)] }.join
296
- cf_def = CassandraThrift::CfDef.new(:keyspace => @ks_name, :name => cf_name)
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
- validate_event_keys(traces[1], @entry_kvs)
309
- traces[1]['Op'].must_equal "add_column_family"
310
- traces[1].has_key?('Backtrace').must_equal Oboe::Config[:cassandra][:collect_backtraces]
311
- validate_event_keys(traces[2], @exit_kvs)
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
- it 'should trace adding a keyspace' do
319
- ks_name = (0...10).map{ ('a'..'z').to_a[rand(26)] }.join
320
- column_families = [{:name =>"a"}, {:name => "b", :type => :super}]
321
- ks_def = CassandraThrift::KsDef.new(:name => ks_name,
322
- :strategy_class => "org.apache.cassandra.locator.SimpleStrategy",
323
- :strategy_options => { 'replication_factor' => '2' },
324
- :cf_defs => [])
325
-
326
- Oboe::API.start_trace('cassandra_test', '', {}) do
327
- @client.add_keyspace(ks_def)
328
- @client.keyspace = ks_name
329
- end
330
-
331
- traces = get_all_traces
332
-
333
- traces.count.must_equal 4
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
- it 'should trace the removal of a keyspace' do
344
- Oboe::API.start_trace('cassandra_test', '', {}) do
345
- @client.drop_keyspace(@ks_name)
346
- end
347
-
348
- traces = get_all_traces
349
-
350
- traces.count.must_equal 4
351
- validate_outer_layers(traces, 'cassandra_test')
352
-
353
- validate_event_keys(traces[1], @entry_kvs)
354
- traces[1]['Op'].must_equal "drop_keyspace"
355
- traces[1]['Name'].must_equal @ks_name
356
- traces[1].has_key?('Backtrace').must_equal Oboe::Config[:cassandra][:collect_backtraces]
357
- validate_event_keys(traces[2], @exit_kvs)
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
- it "should obey :collect_backtraces setting when true" do
361
- Oboe::Config[:cassandra][:collect_backtraces] = true
362
-
363
- Oboe::API.start_trace('cassandra_test', '', {}) do
364
- user = {'screen_name' => 'larry', "blah" => "ok"}
365
- @client.insert(:Users, '5', user, { :ttl => 600, :consistency => 1})
366
- end
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
- traces = get_all_traces
369
- layer_has_key(traces, 'cassandra', 'Backtrace')
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
- it "should obey :collect_backtraces setting when false" do
373
- Oboe::Config[:cassandra][:collect_backtraces] = false
361
+ traces = get_all_traces
362
+ layer_has_key(traces, 'cassandra', 'Backtrace')
363
+ end
374
364
 
375
- Oboe::API.start_trace('cassandra_test', '', {}) do
376
- user = {'screen_name' => 'larry', "blah" => "ok"}
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
- traces = get_all_traces
381
- layer_doesnt_have_key(traces, 'cassandra', 'Backtrace')
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
- end # false
373
+ traces = get_all_traces
374
+ layer_doesnt_have_key(traces, 'cassandra', 'Backtrace')
375
+ end
376
+
377
+ end