oboe 2.6.8 → 2.7.0.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -12,11 +12,11 @@ begin
12
12
  unless defined?(Oboe_metal)
13
13
  begin
14
14
  if RUBY_PLATFORM == 'java'
15
- require 'joboe_metal'
16
15
  require '/usr/local/tracelytics/tracelyticsagent.jar'
16
+ require 'joboe_metal'
17
17
  else
18
- require 'oboe_metal'
19
18
  require 'oboe_metal.so'
19
+ require 'oboe_metal'
20
20
  end
21
21
  rescue LoadError
22
22
  Oboe.loaded = false
@@ -62,7 +62,7 @@ module Oboe
62
62
  def log_start(layer, xtrace, opts={})
63
63
  return if Oboe.never? or (opts.has_key?(:URL) and ::Oboe::Util.static_asset?(opts[:URL]))
64
64
 
65
- if xtrace
65
+ if xtrace and not xtrace.to_s.empty?
66
66
  Oboe::Context.fromString(xtrace)
67
67
  end
68
68
 
@@ -86,12 +86,12 @@ module Oboe
86
86
  end
87
87
 
88
88
  def log_entry(layer, opts={}, protect_op=nil)
89
- Oboe::Context.layer_op = protect_op if protect_op
89
+ Oboe.layer_op = protect_op if protect_op
90
90
  log_event(layer, 'entry', Oboe::Context.createEvent, opts)
91
91
  end
92
92
 
93
93
  def log_exit(layer, opts={}, protect_op=nil)
94
- Oboe::Context.layer_op = nil if protect_op
94
+ Oboe.layer_op = nil if protect_op
95
95
  log_event(layer, 'exit', Oboe::Context.createEvent, opts)
96
96
  end
97
97
 
@@ -11,7 +11,7 @@ module Oboe
11
11
  # layer - The layer the block of code belongs to.
12
12
  # opts - A hash containing key/value pairs that will be reported along
13
13
  # with the first event of this layer (optional).
14
- # protect_op - specify the operating being traced. Used to avoid
14
+ # protect_op - specify the operation being traced. Used to avoid
15
15
  # double tracing between operations that call each other
16
16
  #
17
17
  # Example
@@ -73,7 +73,7 @@ module Oboe
73
73
  # Returns a list of length two, the first element of which is the result
74
74
  # of the block, and the second element of which is the oboe context that
75
75
  # was set when the block completed execution.
76
- def start_trace(layer, xtrace, opts={})
76
+ def start_trace(layer, xtrace=nil, opts={})
77
77
  log_start(layer, xtrace, opts)
78
78
  begin
79
79
  result = yield
@@ -21,7 +21,7 @@ module Oboe
21
21
  report_kvs[:template] = engine
22
22
  end
23
23
 
24
- if Oboe::Context.tracing_layer_op?('render')
24
+ if Oboe.tracing_layer_op?('render')
25
25
  # For recursive calls to :render (for sub-partials and layouts),
26
26
  # use method profiling.
27
27
  begin
@@ -15,7 +15,7 @@ module Oboe
15
15
  report_kvs[:engine] = engine
16
16
  report_kvs[:template] = data
17
17
 
18
- if Oboe::Context.tracing_layer_op?('render')
18
+ if Oboe.tracing_layer_op?('render')
19
19
  # For recursive calls to :render (for sub-partials and layouts),
20
20
  # use method profiling.
21
21
  begin
@@ -77,7 +77,7 @@ module Oboe
77
77
  def get_columns_with_oboe(column_family, key, *columns_and_options)
78
78
  args = [column_family, key] + columns_and_options
79
79
 
80
- if Oboe.tracing? and not Oboe::Context.tracing_layer_op?(:multi_get_columns)
80
+ if Oboe.tracing? and not Oboe.tracing_layer_op?(:multi_get_columns)
81
81
  report_kvs = extract_trace_details(:get_columns, column_family, key, columns_and_options)
82
82
 
83
83
  Oboe::API.trace('cassandra', report_kvs) do
@@ -113,7 +113,7 @@ module Oboe
113
113
  def multi_get_with_oboe(column_family, key, *columns_and_options)
114
114
  args = [column_family, key] + columns_and_options
115
115
 
116
- if Oboe.tracing? and not Oboe::Context.tracing_layer_op?(:get)
116
+ if Oboe.tracing? and not Oboe.tracing_layer_op?(:get)
117
117
  report_kvs = extract_trace_details(:multi_get, column_family, key, columns_and_options)
118
118
 
119
119
  Oboe::API.trace('cassandra', report_kvs) do
@@ -136,7 +136,7 @@ module Oboe
136
136
  end
137
137
 
138
138
  def get_range_single_with_oboe(column_family, options = {})
139
- if Oboe.tracing? and not Oboe::Context.tracing_layer_op?(:get_range_batch)
139
+ if Oboe.tracing? and not Oboe.tracing_layer_op?(:get_range_batch)
140
140
  report_kvs = extract_trace_details(:get_range_single, column_family, nil, nil)
141
141
  args = [column_family, options]
142
142
 
@@ -25,7 +25,7 @@ module Oboe
25
25
  def perform_with_oboe(*all_args, &blk)
26
26
  op, key, *args = *all_args
27
27
 
28
- if Oboe.tracing? and not Oboe::Context.tracing_layer_op?(:get_multi)
28
+ if Oboe.tracing? and not Oboe.tracing_layer_op?(:get_multi)
29
29
  Oboe::API.trace('memcache', { :KVOp => op, :KVKey => key }) do
30
30
  result = perform_without_oboe(*all_args, &blk)
31
31
 
@@ -70,7 +70,7 @@ module Oboe
70
70
  end
71
71
 
72
72
  def request_setup_with_oboe(*args)
73
- if Oboe.tracing? and not Oboe::Context.tracing_layer_op?(:get_multi)
73
+ if Oboe.tracing? and not Oboe.tracing_layer_op?(:get_multi)
74
74
  server, cache_key = request_setup_without_oboe(*args)
75
75
 
76
76
  info_kvs = { :KVKey => cache_key, :RemoteHost => server.host }
@@ -37,7 +37,12 @@ if defined?(::Moped) and Oboe::Config[:moped][:enabled]
37
37
  begin
38
38
  report_kvs[:Flavor] = Oboe::Inst::Moped::FLAVOR
39
39
  # FIXME: We're only grabbing the first of potentially multiple servers here
40
- report_kvs[:RemoteHost], report_kvs[:RemotePort] = session.cluster.seeds.first.split(':')
40
+ if ::Moped::VERSION < "2.0.0"
41
+ report_kvs[:RemoteHost], report_kvs[:RemotePort] = session.cluster.seeds.first.split(':')
42
+ else
43
+ report_kvs[:RemoteHost] = session.cluster.seeds.first.address.host
44
+ report_kvs[:RemotePort] = session.cluster.seeds.first.address.port
45
+ end
41
46
  report_kvs[:Database] = name
42
47
  report_kvs[:QueryOp] = op.to_s
43
48
  report_kvs[:Backtrace] = Oboe::API.backtrace if Oboe::Config[:moped][:collect_backtraces]
@@ -48,7 +53,7 @@ if defined?(::Moped) and Oboe::Config[:moped][:enabled]
48
53
  end
49
54
 
50
55
  def command_with_oboe(command)
51
- if Oboe.tracing? and not Oboe::Context.layer_op and command.has_key?(:mapreduce)
56
+ if Oboe.tracing? and not Oboe.layer_op and command.has_key?(:mapreduce)
52
57
  begin
53
58
  report_kvs = extract_trace_details(:map_reduce)
54
59
  report_kvs[:Map_Function] = command[:map]
@@ -96,7 +101,12 @@ if defined?(::Moped) and Oboe::Config[:moped][:enabled]
96
101
  begin
97
102
  report_kvs[:Flavor] = Oboe::Inst::Moped::FLAVOR
98
103
  # FIXME: We're only grabbing the first of potentially multiple servers here
99
- report_kvs[:RemoteHost], report_kvs[:RemotePort] = database.session.cluster.seeds.first.split(':')
104
+ if ::Moped::VERSION < "2.0.0"
105
+ report_kvs[:RemoteHost], report_kvs[:RemotePort] = database.session.cluster.seeds.first.split(':')
106
+ else
107
+ report_kvs[:RemoteHost] = database.session.cluster.seeds.first.address.host
108
+ report_kvs[:RemotePort] = database.session.cluster.seeds.first.address.port
109
+ end
100
110
  report_kvs[:Database] = database.name
101
111
  report_kvs[:QueryOp] = op.to_s
102
112
  report_kvs[:Backtrace] = Oboe::API.backtrace if Oboe::Config[:moped][:collect_backtraces]
@@ -162,7 +172,12 @@ if defined?(::Moped) and Oboe::Config[:moped][:enabled]
162
172
  begin
163
173
  report_kvs[:Flavor] = Oboe::Inst::Moped::FLAVOR
164
174
  # FIXME: We're only grabbing the first of potentially multiple servers here
165
- report_kvs[:RemoteHost], report_kvs[:RemotePort] = collection.database.session.cluster.seeds.first.split(':')
175
+ if ::Moped::VERSION < "2.0.0"
176
+ report_kvs[:RemoteHost], report_kvs[:RemotePort] = collection.database.session.cluster.seeds.first.split(':')
177
+ else
178
+ report_kvs[:RemoteHost] = collection.database.session.cluster.seeds.first.address.host
179
+ report_kvs[:RemotePort] = collection.database.session.cluster.seeds.first.address.port
180
+ end
166
181
  report_kvs[:Database] = collection.database.name
167
182
  report_kvs[:Collection] = collection.name
168
183
  report_kvs[:QueryOp] = op.to_s
@@ -205,7 +220,7 @@ if defined?(::Moped) and Oboe::Config[:moped][:enabled]
205
220
  end
206
221
 
207
222
  def limit_with_oboe(limit)
208
- if Oboe.tracing? and not Oboe::Context.tracing_layer_op?(:explain)
223
+ if Oboe.tracing? and not Oboe.tracing_layer_op?(:explain)
209
224
  begin
210
225
  report_kvs = extract_trace_details(:limit)
211
226
  report_kvs[:Query] = selector.empty? ? "all" : selector.to_json
@@ -239,7 +254,7 @@ if defined?(::Moped) and Oboe::Config[:moped][:enabled]
239
254
  end
240
255
 
241
256
  def update_with_oboe(change, flags = nil)
242
- if Oboe.tracing? and not Oboe::Context.tracing_layer_op?([:update_all, :upsert])
257
+ if Oboe.tracing? and not Oboe.tracing_layer_op?([:update_all, :upsert])
243
258
  begin
244
259
  report_kvs = extract_trace_details(:update)
245
260
  report_kvs[:Flags] = flags.to_s if flags
@@ -371,9 +386,14 @@ if defined?(::Moped) and Oboe::Config[:moped][:enabled]
371
386
  begin
372
387
  report_kvs[:Flavor] = Oboe::Inst::Moped::FLAVOR
373
388
  # FIXME: We're only grabbing the first of potentially multiple servers here
374
- report_kvs[:RemoteHost], report_kvs[:RemotePort] = @database.session.cluster.seeds.first.split(':')
375
- report_kvs[:Database] = @database.name
376
- report_kvs[:Collection] = @name
389
+ if ::Moped::VERSION < "2.0.0"
390
+ report_kvs[:RemoteHost], report_kvs[:RemotePort] = database.session.cluster.seeds.first.split(':')
391
+ else
392
+ report_kvs[:RemoteHost] = database.session.cluster.seeds.first.address.host
393
+ report_kvs[:RemotePort] = database.session.cluster.seeds.first.address.port
394
+ end
395
+ report_kvs[:Database] = database.name
396
+ report_kvs[:Collection] = name
377
397
  report_kvs[:QueryOp] = op.to_s
378
398
  report_kvs[:Backtrace] = Oboe::API.backtrace if Oboe::Config[:moped][:collect_backtraces]
379
399
  rescue StandardError => e
@@ -420,7 +440,7 @@ if defined?(::Moped) and Oboe::Config[:moped][:enabled]
420
440
  end
421
441
 
422
442
  def insert_with_oboe(documents, flags = nil)
423
- if Oboe.tracing? and not Oboe::Context.tracing_layer_op?(:create_index)
443
+ if Oboe.tracing? and not Oboe.tracing_layer_op?(:create_index)
424
444
  report_kvs = extract_trace_details(:insert)
425
445
 
426
446
  Oboe::API.trace('mongo', report_kvs) do
@@ -51,7 +51,7 @@ module Oboe
51
51
  end
52
52
 
53
53
  def enqueue_to_with_oboe(queue, klass, *args)
54
- if Oboe.tracing? and not Oboe::Context.tracing_layer_op?(:enqueue)
54
+ if Oboe.tracing? and not Oboe.tracing_layer_op?(:enqueue)
55
55
  report_kvs = extract_trace_details(:enqueue_to, klass, args)
56
56
  report_kvs[:Queue] = queue.to_s if queue
57
57
 
@@ -4,9 +4,9 @@
4
4
  module Oboe
5
5
  module Version
6
6
  MAJOR = 2
7
- MINOR = 6
8
- PATCH = 8
9
- BUILD = nil
7
+ MINOR = 7
8
+ PATCH = 0
9
+ BUILD = 3
10
10
 
11
11
  STRING = [MAJOR, MINOR, PATCH, BUILD].compact.join('.')
12
12
  end
@@ -38,6 +38,41 @@ module Oboe
38
38
  def self.sendReport(evt)
39
39
  Oboe.reporter.sendReport(evt)
40
40
  end
41
+
42
+ ##
43
+ # clear_all_traces
44
+ #
45
+ # Truncates the trace output file to zero
46
+ #
47
+ def self.clear_all_traces
48
+ File.truncate($trace_file, 0)
49
+ end
50
+
51
+ ##
52
+ # get_all_traces
53
+ #
54
+ # Retrieves all traces written to the trace file
55
+ #
56
+ def self.get_all_traces
57
+ io = File.open($trace_file, "r")
58
+ contents = io.readlines(nil)
59
+
60
+ return contents if contents.empty?
61
+
62
+ s = StringIO.new(contents[0])
63
+
64
+ traces = []
65
+
66
+ until s.eof?
67
+ if ::BSON.respond_to? :read_bson_document
68
+ traces << BSON.read_bson_document(s)
69
+ else
70
+ traces << BSON::Document.from_bson(s)
71
+ end
72
+ end
73
+
74
+ traces
75
+ end
41
76
  end
42
77
 
43
78
  class Event
@@ -12,13 +12,14 @@ Gem::Specification.new do |s|
12
12
  s.email = %q{traceviewsupport@appneta.com}
13
13
  s.homepage = %q{http://www.appneta.com/products/traceview/}
14
14
  s.summary = %q{AppNeta TraceView performance instrumentation gem for Ruby}
15
- s.description = %q{The oboe gem provides TraceView instrumentation for Ruby and Ruby frameworks.}
15
+ s.description = %q{The oboe gem provides TraceView instrumentation for MRI Ruby, JRuby and related frameworks.}
16
16
 
17
17
  s.extra_rdoc_files = ["LICENSE"]
18
18
  s.files = `git ls-files`.split("\n")
19
19
  s.test_files = Dir.glob("{test}/**/*.rb")
20
-
21
- s.extensions = ['ext/oboe_metal/extconf.rb']
20
+
21
+ s.platform = defined?(JRUBY_VERSION) ? 'java' : Gem::Platform::RUBY
22
+ s.extensions = ['ext/oboe_metal/extconf.rb'] unless defined?(JRUBY_VERSION)
22
23
 
23
24
  s.add_runtime_dependency('json', '>= 0')
24
25
  s.add_development_dependency('rake', '>= 0')
@@ -8,5 +8,3 @@ class GrapeSimple < Grape::API
8
8
  end
9
9
  end
10
10
 
11
- use GrapeSimple
12
-
@@ -1,377 +1,381 @@
1
1
  require 'minitest_helper'
2
2
 
3
- describe Oboe::Inst::Cassandra do
4
- before do
5
- clear_all_traces
6
-
7
- @client = Cassandra.new("system", "127.0.0.1:9160", { :timeout => 10 })
8
- @client.disable_node_auto_discovery!
9
-
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)
3
+ # The cassandra-rb client doesn't support JRuby
4
+ # https://github.com/cassandra-rb/cassandra
5
+ unless defined?(JRUBY_VERSION)
6
+ describe Oboe::Inst::Cassandra do
7
+ before do
8
+ clear_all_traces
9
+
10
+ @client = Cassandra.new("system", "127.0.0.1:9160", { :timeout => 10 })
11
+ @client.disable_node_auto_discovery!
12
+
13
+ @ks_name = "AppNetaCassandraTest"
14
+
15
+ ks_def = CassandraThrift::KsDef.new(:name => @ks_name,
16
+ :strategy_class => "SimpleStrategy",
17
+ :strategy_options => { 'replication_factor' => '2' },
18
+ :cf_defs => [])
19
+
20
+ @client.add_keyspace(ks_def) unless @client.keyspaces.include? @ks_name
21
+ @client.keyspace = @ks_name
22
+
23
+ unless @client.column_families.include? "Users"
24
+ cf_def = CassandraThrift::CfDef.new(:keyspace => @ks_name, :name => "Users")
25
+ @client.add_column_family(cf_def)
26
+ end
27
+
28
+ unless @client.column_families.include? "Statuses"
29
+ cf_def = CassandraThrift::CfDef.new(:keyspace => @ks_name, :name => "Statuses")
30
+ @client.add_column_family(cf_def)
31
+ end
32
+
33
+ # These are standard entry/exit KVs that are passed up with all mongo operations
34
+ @entry_kvs = {
35
+ 'Layer' => 'cassandra',
36
+ 'Label' => 'entry',
37
+ 'RemoteHost' => '127.0.0.1',
38
+ 'RemotePort' => '9160' }
39
+
40
+ @exit_kvs = { 'Layer' => 'cassandra', 'Label' => 'exit' }
41
+ @collect_backtraces = Oboe::Config[:cassandra][:collect_backtraces]
23
42
  end
24
43
 
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)
44
+ after do
45
+ Oboe::Config[:cassandra][:collect_backtraces] = @collect_backtraces
46
+ @client.disconnect!
28
47
  end
29
48
 
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
+ it 'Stock Cassandra should be loaded, defined and ready' do
50
+ defined?(::Cassandra).wont_match nil
51
+ end
49
52
 
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
53
+ it 'Cassandra should have oboe methods defined' do
54
+ [ :insert, :remove, :count_columns, :get_columns, :multi_get_columns, :get,
55
+ :multi_get, :get_range_single, :get_range_batch, :get_indexed_slices,
56
+ :create_index, :drop_index, :add_column_family, :drop_column_family,
57
+ :add_keyspace, :drop_keyspace ].each do |m|
58
+ ::Cassandra.method_defined?("#{m}_with_oboe").must_equal true
59
+ end
60
+ # Special 'exists?' case
61
+ ::Cassandra.method_defined?("exists_with_oboe?").must_equal true
56
62
  end
57
- # Special 'exists?' case
58
- ::Cassandra.method_defined?("exists_with_oboe?").must_equal true
59
- end
60
63
 
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})
64
+ it 'should trace insert' do
65
+ Oboe::API.start_trace('cassandra_test', '', {}) do
66
+ user = {'screen_name' => 'larry', "blah" => "ok"}
67
+ @client.insert(:Users, '5', user, { :ttl => 600, :consistency => 1})
68
+ end
69
+
70
+ traces = get_all_traces
71
+
72
+ traces.count.must_equal 4
73
+ validate_outer_layers(traces, 'cassandra_test')
74
+
75
+ validate_event_keys(traces[1], @entry_kvs)
76
+ traces[1]['Op'].must_equal "insert"
77
+ traces[1]['Cf'].must_equal "Users"
78
+ traces[1]['Key'].must_equal "\"5\""
79
+ traces[1]['Consistency'].must_equal "1"
80
+ traces[1]['Ttl'].must_equal "600"
81
+ traces[1].has_key?('Backtrace').must_equal Oboe::Config[:cassandra][:collect_backtraces]
82
+ validate_event_keys(traces[2], @exit_kvs)
65
83
  end
66
84
 
67
- traces = get_all_traces
85
+ it 'should trace remove' do
86
+ Oboe::API.start_trace('cassandra_test', '', {}) do
87
+ @client.remove(:Users, '5', 'blah')
88
+ end
68
89
 
69
- traces.count.must_equal 4
70
- validate_outer_layers(traces, 'cassandra_test')
90
+ traces = get_all_traces
71
91
 
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
92
+ traces.count.must_equal 4
93
+ validate_outer_layers(traces, 'cassandra_test')
81
94
 
82
- it 'should trace remove' do
83
- Oboe::API.start_trace('cassandra_test', '', {}) do
84
- @client.remove(:Users, '5', 'blah')
95
+ validate_event_keys(traces[1], @entry_kvs)
96
+ traces[1]['Op'].must_equal "remove"
97
+ traces[1]['Cf'].must_equal "Users"
98
+ traces[1]['Key'].must_equal "\"5\""
99
+ traces[1].has_key?('Backtrace').must_equal Oboe::Config[:cassandra][:collect_backtraces]
100
+ validate_event_keys(traces[2], @exit_kvs)
85
101
  end
86
102
 
87
- traces = get_all_traces
103
+ it 'should trace count_columns' do
104
+ @client.insert(:Statuses, '12', {'body' => 'v1', 'user' => 'v2'})
88
105
 
89
- traces.count.must_equal 4
90
- validate_outer_layers(traces, 'cassandra_test')
106
+ Oboe::API.start_trace('cassandra_test', '', {}) do
107
+ @client.count_columns(:Statuses, '12', :count => 50)
108
+ end
91
109
 
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
110
+ traces = get_all_traces
99
111
 
100
- it 'should trace count_columns' do
101
- @client.insert(:Statuses, '12', {'body' => 'v1', 'user' => 'v2'})
112
+ traces.count.must_equal 4
113
+ validate_outer_layers(traces, 'cassandra_test')
102
114
 
103
- Oboe::API.start_trace('cassandra_test', '', {}) do
104
- @client.count_columns(:Statuses, '12', :count => 50)
115
+ validate_event_keys(traces[1], @entry_kvs)
116
+ traces[1]['Op'].must_equal "count_columns"
117
+ traces[1]['Cf'].must_equal "Statuses"
118
+ traces[1]['Key'].must_equal "\"12\""
119
+ traces[1]['Count'].must_equal "50"
120
+ traces[1].has_key?('Backtrace').must_equal Oboe::Config[:cassandra][:collect_backtraces]
121
+ validate_event_keys(traces[2], @exit_kvs)
105
122
  end
106
123
 
107
- traces = get_all_traces
124
+ it 'should trace get_columns' do
125
+ Oboe::API.start_trace('cassandra_test', '', {}) do
126
+ @client.get_columns(:Statuses, '12', ['body'])
127
+ end
108
128
 
109
- traces.count.must_equal 4
110
- validate_outer_layers(traces, 'cassandra_test')
129
+ traces = get_all_traces
111
130
 
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
131
+ traces.count.must_equal 4
132
+ validate_outer_layers(traces, 'cassandra_test')
120
133
 
121
- it 'should trace get_columns' do
122
- Oboe::API.start_trace('cassandra_test', '', {}) do
123
- @client.get_columns(:Statuses, '12', ['body'])
134
+ validate_event_keys(traces[1], @entry_kvs)
135
+ traces[1]['Op'].must_equal "get_columns"
136
+ traces[1]['Cf'].must_equal "Statuses"
137
+ traces[1]['Key'].must_equal "\"12\""
138
+ traces[1].has_key?('Backtrace').must_equal Oboe::Config[:cassandra][:collect_backtraces]
139
+ validate_event_keys(traces[2], @exit_kvs)
124
140
  end
125
141
 
126
- traces = get_all_traces
142
+ it 'should trace multi_get_columns' do
143
+ Oboe::API.start_trace('cassandra_test', '', {}) do
144
+ @client.multi_get_columns(:Users, ['12', '5'], ['body'])
145
+ end
127
146
 
128
- traces.count.must_equal 4
129
- validate_outer_layers(traces, 'cassandra_test')
147
+ traces = get_all_traces
130
148
 
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
149
+ traces.count.must_equal 4
150
+ validate_outer_layers(traces, 'cassandra_test')
138
151
 
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'])
152
+ validate_event_keys(traces[1], @entry_kvs)
153
+ traces[1]['Op'].must_equal "multi_get_columns"
154
+ traces[1]['Cf'].must_equal "Users"
155
+ traces[1]['Key'].must_equal "[\"12\", \"5\"]"
156
+ traces[1].has_key?('Backtrace').must_equal Oboe::Config[:cassandra][:collect_backtraces]
157
+ validate_event_keys(traces[2], @exit_kvs)
142
158
  end
143
159
 
144
- traces = get_all_traces
160
+ it 'should trace get' do
161
+ Oboe::API.start_trace('cassandra_test', '', {}) do
162
+ @client.get(:Statuses, '12', :reversed => true)
163
+ end
145
164
 
146
- traces.count.must_equal 4
147
- validate_outer_layers(traces, 'cassandra_test')
165
+ traces = get_all_traces
148
166
 
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
167
+ traces.count.must_equal 4
168
+ validate_outer_layers(traces, 'cassandra_test')
156
169
 
157
- it 'should trace get' do
158
- Oboe::API.start_trace('cassandra_test', '', {}) do
159
- @client.get(:Statuses, '12', :reversed => true)
170
+ validate_event_keys(traces[1], @entry_kvs)
171
+ traces[1]['Op'].must_equal "get"
172
+ traces[1]['Cf'].must_equal "Statuses"
173
+ traces[1]['Key'].must_equal "\"12\""
174
+ traces[1]['Reversed'].must_equal "true"
175
+ traces[1].has_key?('Backtrace').must_equal Oboe::Config[:cassandra][:collect_backtraces]
176
+ validate_event_keys(traces[2], @exit_kvs)
160
177
  end
161
178
 
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
175
-
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')
180
- end
179
+ it 'should trace exists?' do
180
+ Oboe::API.start_trace('cassandra_test', '', {}) do
181
+ @client.exists?(:Statuses, '12')
182
+ @client.exists?(:Statuses, '12', 'body')
183
+ end
181
184
 
182
- traces = get_all_traces
185
+ traces = get_all_traces
183
186
 
184
- traces.count.must_equal 6
185
- validate_outer_layers(traces, 'cassandra_test')
187
+ traces.count.must_equal 6
188
+ validate_outer_layers(traces, 'cassandra_test')
186
189
 
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)
190
+ validate_event_keys(traces[1], @entry_kvs)
191
+ traces[1]['Op'].must_equal "exists?"
192
+ traces[1]['Cf'].must_equal "Statuses"
193
+ traces[1]['Key'].must_equal "\"12\""
194
+ traces[1].has_key?('Backtrace').must_equal Oboe::Config[:cassandra][:collect_backtraces]
195
+ validate_event_keys(traces[2], @exit_kvs)
193
196
 
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
199
-
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)
197
+ traces[3]['Op'].must_equal "exists?"
198
+ traces[3]['Cf'].must_equal "Statuses"
199
+ traces[3]['Key'].must_equal "\"12\""
200
+ traces[3].has_key?('Backtrace').must_equal Oboe::Config[:cassandra][:collect_backtraces]
203
201
  end
204
202
 
205
- traces = get_all_traces
203
+ it 'should trace get_range_keys' do
204
+ Oboe::API.start_trace('cassandra_test', '', {}) do
205
+ @client.get_range_keys(:Statuses, :key_count => 4)
206
+ end
206
207
 
207
- traces.count.must_equal 4
208
- validate_outer_layers(traces, 'cassandra_test')
208
+ traces = get_all_traces
209
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
210
+ traces.count.must_equal 4
211
+ validate_outer_layers(traces, 'cassandra_test')
216
212
 
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')
213
+ validate_event_keys(traces[1], @entry_kvs)
214
+ traces[1]['Op'].must_equal "get_range_batch"
215
+ traces[1]['Cf'].must_equal "Statuses"
216
+ traces[1].has_key?('Backtrace').must_equal Oboe::Config[:cassandra][:collect_backtraces]
217
+ validate_event_keys(traces[2], @exit_kvs)
220
218
  end
221
219
 
222
- traces = get_all_traces
223
-
224
- traces.count.must_equal 4
225
- validate_outer_layers(traces, 'cassandra_test')
220
+ it 'should trace create_index' do
221
+ Oboe::API.start_trace('cassandra_test', '', {}) do
222
+ @client.create_index(@ks_name, 'Statuses', 'column_name', 'LongType')
223
+ end
226
224
 
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)
225
+ traces = get_all_traces
235
226
 
236
- # Clean up
237
- @client.drop_index(@ks_name, 'Statuses', 'column_name')
238
- end
227
+ traces.count.must_equal 4
228
+ validate_outer_layers(traces, 'cassandra_test')
239
229
 
240
- it 'should trace drop_index' do
241
- # Prep
242
- @client.create_index(@ks_name, 'Statuses', 'column_name', 'LongType')
230
+ validate_event_keys(traces[1], @entry_kvs)
231
+ traces[1]['Op'].must_equal "create_index"
232
+ traces[1]['Cf'].must_equal "Statuses"
233
+ traces[1]['Keyspace'].must_equal @ks_name
234
+ traces[1]['Column_name'].must_equal "column_name"
235
+ traces[1]['Validation_class'].must_equal "LongType"
236
+ traces[1].has_key?('Backtrace').must_equal Oboe::Config[:cassandra][:collect_backtraces]
237
+ validate_event_keys(traces[2], @exit_kvs)
243
238
 
244
- Oboe::API.start_trace('cassandra_test', '', {}) do
239
+ # Clean up
245
240
  @client.drop_index(@ks_name, 'Statuses', 'column_name')
246
241
  end
247
242
 
248
- traces = get_all_traces
243
+ it 'should trace drop_index' do
244
+ # Prep
245
+ @client.create_index(@ks_name, 'Statuses', 'column_name', 'LongType')
249
246
 
250
- traces.count.must_equal 4
251
- validate_outer_layers(traces, 'cassandra_test')
247
+ Oboe::API.start_trace('cassandra_test', '', {}) do
248
+ @client.drop_index(@ks_name, 'Statuses', 'column_name')
249
+ end
252
250
 
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
251
+ traces = get_all_traces
261
252
 
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
273
- end
253
+ traces.count.must_equal 4
254
+ validate_outer_layers(traces, 'cassandra_test')
274
255
 
275
- traces = get_all_traces
276
-
277
- traces.count.must_equal 4
278
- validate_outer_layers(traces, 'cassandra_test')
256
+ validate_event_keys(traces[1], @entry_kvs)
257
+ traces[1]['Op'].must_equal "drop_index"
258
+ traces[1]['Cf'].must_equal "Statuses"
259
+ traces[1]['Keyspace'].must_equal @ks_name
260
+ traces[1]['Column_name'].must_equal "column_name"
261
+ traces[1].has_key?('Backtrace').must_equal Oboe::Config[:cassandra][:collect_backtraces]
262
+ validate_event_keys(traces[2], @exit_kvs)
263
+ end
279
264
 
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
265
+ it 'should trace get_indexed_slices' do
266
+ @client.create_index(@ks_name, 'Statuses', 'x', 'LongType')
267
+ Oboe::API.start_trace('cassandra_test', '', {}) do
268
+ expressions = [
269
+ { :column_name => 'x',
270
+ :value => [0,20].pack("NN"),
271
+ :comparison => "=="},
272
+ { :column_name => 'non_indexed',
273
+ :value => [5].pack("N*"),
274
+ :comparison => ">"} ]
275
+ @client.get_indexed_slices(:Statuses, expressions).length
276
+ end
277
+
278
+ traces = get_all_traces
279
+
280
+ traces.count.must_equal 4
281
+ validate_outer_layers(traces, 'cassandra_test')
282
+
283
+ validate_event_keys(traces[1], @entry_kvs)
284
+ traces[1]['Op'].must_equal "get_indexed_slices"
285
+ traces[1]['Cf'].must_equal "Statuses"
286
+ traces[1].has_key?('Backtrace').must_equal Oboe::Config[:cassandra][:collect_backtraces]
287
+ validate_event_keys(traces[2], @exit_kvs)
288
+ end
286
289
 
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
+ it 'should trace add and remove of column family' do
291
+ cf_name = (0...10).map{ ('a'..'z').to_a[rand(26)] }.join
292
+ cf_def = CassandraThrift::CfDef.new(:keyspace => @ks_name, :name => cf_name)
290
293
 
291
- Oboe::API.start_trace('cassandra_test', '', {}) do
292
- @client.add_column_family(cf_def)
293
- @client.drop_column_family(cf_name)
294
- end
294
+ Oboe::API.start_trace('cassandra_test', '', {}) do
295
+ @client.add_column_family(cf_def)
296
+ @client.drop_column_family(cf_name)
297
+ end
295
298
 
296
- traces = get_all_traces
299
+ traces = get_all_traces
297
300
 
298
- traces.count.must_equal 6
299
- validate_outer_layers(traces, 'cassandra_test')
301
+ traces.count.must_equal 6
302
+ validate_outer_layers(traces, 'cassandra_test')
300
303
 
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)
304
+ validate_event_keys(traces[1], @entry_kvs)
305
+ traces[1]['Op'].must_equal "add_column_family"
306
+ traces[1].has_key?('Backtrace').must_equal Oboe::Config[:cassandra][:collect_backtraces]
307
+ validate_event_keys(traces[2], @exit_kvs)
305
308
 
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
309
+ traces[3]['Op'].must_equal "drop_column_family"
310
+ traces[3]['Cf'].must_equal cf_name
311
+ traces[3].has_key?('Backtrace').must_equal Oboe::Config[:cassandra][:collect_backtraces]
312
+ end
310
313
 
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
314
+ it 'should trace adding a keyspace' do
315
+ ks_name = (0...10).map{ ('a'..'z').to_a[rand(26)] }.join
316
+ column_families = [{:name =>"a"}, {:name => "b", :type => :super}]
317
+ ks_def = CassandraThrift::KsDef.new(:name => ks_name,
318
+ :strategy_class => "org.apache.cassandra.locator.SimpleStrategy",
319
+ :strategy_options => { 'replication_factor' => '2' },
320
+ :cf_defs => [])
321
+
322
+ Oboe::API.start_trace('cassandra_test', '', {}) do
323
+ @client.add_keyspace(ks_def)
324
+ @client.keyspace = ks_name
325
+ end
326
+
327
+ traces = get_all_traces
328
+
329
+ traces.count.must_equal 4
330
+ validate_outer_layers(traces, 'cassandra_test')
331
+
332
+ validate_event_keys(traces[1], @entry_kvs)
333
+ traces[1]['Op'].must_equal "add_keyspace"
334
+ traces[1]['Name'].must_equal ks_name
335
+ traces[1].has_key?('Backtrace').must_equal Oboe::Config[:cassandra][:collect_backtraces]
336
+ validate_event_keys(traces[2], @exit_kvs)
322
337
  end
323
338
 
324
- traces = get_all_traces
339
+ it 'should trace the removal of a keyspace' do
340
+ Oboe::API.start_trace('cassandra_test', '', {}) do
341
+ @client.drop_keyspace(@ks_name)
342
+ end
325
343
 
326
- traces.count.must_equal 4
327
- validate_outer_layers(traces, 'cassandra_test')
344
+ traces = get_all_traces
328
345
 
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
346
+ traces.count.must_equal 4
347
+ validate_outer_layers(traces, 'cassandra_test')
335
348
 
336
- it 'should trace the removal of a keyspace' do
337
- Oboe::API.start_trace('cassandra_test', '', {}) do
338
- @client.drop_keyspace(@ks_name)
349
+ validate_event_keys(traces[1], @entry_kvs)
350
+ traces[1]['Op'].must_equal "drop_keyspace"
351
+ traces[1]['Name'].must_equal @ks_name
352
+ traces[1].has_key?('Backtrace').must_equal Oboe::Config[:cassandra][:collect_backtraces]
353
+ validate_event_keys(traces[2], @exit_kvs)
339
354
  end
340
355
 
341
- traces = get_all_traces
356
+ it "should obey :collect_backtraces setting when true" do
357
+ Oboe::Config[:cassandra][:collect_backtraces] = true
342
358
 
343
- traces.count.must_equal 4
344
- validate_outer_layers(traces, 'cassandra_test')
359
+ Oboe::API.start_trace('cassandra_test', '', {}) do
360
+ user = {'screen_name' => 'larry', "blah" => "ok"}
361
+ @client.insert(:Users, '5', user, { :ttl => 600, :consistency => 1})
362
+ end
345
363
 
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
355
-
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})
364
+ traces = get_all_traces
365
+ layer_has_key(traces, 'cassandra', 'Backtrace')
359
366
  end
360
367
 
361
- traces = get_all_traces
362
- layer_has_key(traces, 'cassandra', 'Backtrace')
363
- end
368
+ it "should obey :collect_backtraces setting when false" do
369
+ Oboe::Config[:cassandra][:collect_backtraces] = false
364
370
 
365
- it "should obey :collect_backtraces setting when false" do
366
- Oboe::Config[:cassandra][:collect_backtraces] = false
371
+ Oboe::API.start_trace('cassandra_test', '', {}) do
372
+ user = {'screen_name' => 'larry', "blah" => "ok"}
373
+ @client.insert(:Users, '5', user, { :ttl => 600, :consistency => 1})
374
+ end
367
375
 
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})
376
+ traces = get_all_traces
377
+ layer_doesnt_have_key(traces, 'cassandra', 'Backtrace')
371
378
  end
372
379
 
373
- traces = get_all_traces
374
- layer_doesnt_have_key(traces, 'cassandra', 'Backtrace')
375
380
  end
376
-
377
381
  end