oboe 2.3.2 → 2.3.3.7
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.
- checksums.yaml +7 -0
- data/.travis.yml +26 -0
- data/CHANGELOG +28 -2
- data/Gemfile +2 -2
- data/README.md +4 -4
- data/Rakefile +18 -7
- data/lib/base.rb +58 -0
- data/lib/joboe_metal.rb +45 -62
- data/lib/method_profiling.rb +50 -57
- data/lib/oboe.rb +17 -12
- data/lib/oboe/api/util.rb +46 -0
- data/lib/oboe/config.rb +3 -14
- data/lib/oboe/inst/cassandra.rb +1 -1
- data/lib/oboe/inst/mongo.rb +1 -1
- data/lib/oboe/inst/rack.rb +16 -11
- data/lib/oboe/inst/resque.rb +5 -5
- data/lib/oboe/version.rb +2 -2
- data/lib/oboe_metal.rb +43 -36
- data/test/instrumentation/cassandra_test.rb +79 -33
- data/test/instrumentation/mongo_test.rb +10 -2
- data/test/instrumentation/moped_test.rb +429 -424
- data/test/minitest_helper.rb +5 -5
- data/test/profiling/method_test.rb +198 -0
- metadata +70 -84
data/lib/oboe.rb
CHANGED
@@ -5,16 +5,25 @@ begin
|
|
5
5
|
require 'oboe/version'
|
6
6
|
require 'oboe/logger'
|
7
7
|
require 'oboe/util'
|
8
|
+
require 'base.rb'
|
8
9
|
|
9
10
|
# If Oboe_metal is already defined then we are in a PaaS environment
|
10
11
|
# with an alternate metal (such as Heroku: see the oboe-heroku gem)
|
11
12
|
unless defined?(Oboe_metal)
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
13
|
+
begin
|
14
|
+
if RUBY_PLATFORM == 'java'
|
15
|
+
require 'joboe_metal'
|
16
|
+
require '/usr/local/tracelytics/tracelyticsagent.jar'
|
17
|
+
else
|
18
|
+
require 'oboe_metal'
|
19
|
+
require 'oboe_metal.so'
|
20
|
+
end
|
21
|
+
rescue LoadError
|
22
|
+
Oboe.loaded = false
|
23
|
+
$stderr.puts "=============================================================="
|
24
|
+
$stderr.puts "Missing TraceView libraries. Tracing disabled."
|
25
|
+
$stderr.puts "See: https://support.tv.appneta.com/solution/articles/137973"
|
26
|
+
$stderr.puts "=============================================================="
|
18
27
|
end
|
19
28
|
end
|
20
29
|
|
@@ -25,14 +34,10 @@ begin
|
|
25
34
|
require 'oboe/ruby'
|
26
35
|
|
27
36
|
# Frameworks
|
28
|
-
require 'oboe/frameworks/rails' if defined?(::Rails)
|
37
|
+
require 'oboe/frameworks/rails' if defined?(::Rails) and Oboe.loaded
|
29
38
|
|
30
|
-
rescue LoadError
|
31
|
-
$stderr.puts "=============================================================="
|
32
|
-
$stderr.puts "Missing TraceView libraries. Tracing disabled."
|
33
|
-
$stderr.puts "See: https://support.tv.appneta.com/solution/articles/137973"
|
34
|
-
$stderr.puts "=============================================================="
|
35
39
|
rescue Exception => e
|
36
40
|
$stderr.puts "[oboe/error] Problem loading: #{e.inspect}"
|
37
41
|
$stderr.puts e.backtrace
|
38
42
|
end
|
43
|
+
|
data/lib/oboe/api/util.rb
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
# Copyright (c) 2013 AppNeta, Inc.
|
2
2
|
# All rights reserved.
|
3
3
|
|
4
|
+
require 'pp'
|
5
|
+
|
4
6
|
module Oboe
|
5
7
|
module API
|
6
8
|
module Util
|
@@ -66,6 +68,50 @@ module Oboe
|
|
66
68
|
|
67
69
|
false
|
68
70
|
end
|
71
|
+
|
72
|
+
# Internal: Pretty print a list of arguments for reporting
|
73
|
+
#
|
74
|
+
# args - the list of arguments to work on
|
75
|
+
#
|
76
|
+
# Returns a pretty string representation of arguments
|
77
|
+
def pps(*args)
|
78
|
+
old_out = $stdout
|
79
|
+
begin
|
80
|
+
s = StringIO.new
|
81
|
+
$stdout = s
|
82
|
+
pp(*args)
|
83
|
+
ensure
|
84
|
+
$stdout = old_out
|
85
|
+
end
|
86
|
+
s.string
|
87
|
+
end
|
88
|
+
|
89
|
+
# Internal: Determine a string to report representing klass
|
90
|
+
#
|
91
|
+
# args - an instance of a Class, a Class or a Module
|
92
|
+
#
|
93
|
+
# Returns a string representation of klass
|
94
|
+
def get_class_name(klass)
|
95
|
+
kv = {}
|
96
|
+
if klass.to_s =~ /::/
|
97
|
+
klass.class.to_s.rpartition('::').last
|
98
|
+
else
|
99
|
+
if klass.is_a?(Class) and klass.is_a?(Module)
|
100
|
+
# Class
|
101
|
+
kv["Class"] = klass.to_s
|
102
|
+
|
103
|
+
elsif (not klass.is_a?(Class) and not klass.is_a?(Module))
|
104
|
+
# Class instance
|
105
|
+
kv["Class"] = klass.class.to_s
|
106
|
+
|
107
|
+
else
|
108
|
+
# Module
|
109
|
+
kv["Module"] = klass.to_s
|
110
|
+
end
|
111
|
+
end
|
112
|
+
kv
|
113
|
+
end
|
114
|
+
|
69
115
|
end
|
70
116
|
end
|
71
117
|
end
|
data/lib/oboe/config.rb
CHANGED
@@ -107,24 +107,13 @@ module Oboe
|
|
107
107
|
|
108
108
|
# Assure value is an integer
|
109
109
|
@@config[key.to_sym] = value.to_i
|
110
|
-
|
111
|
-
|
112
|
-
Oboe::Context.setDefaultSampleRate(value.to_i)
|
110
|
+
|
111
|
+
Oboe.set_sample_rate(value)
|
113
112
|
end
|
114
113
|
|
115
114
|
# Update liboboe if updating :tracing_mode
|
116
115
|
if key == :tracing_mode
|
117
|
-
|
118
|
-
when 'never'
|
119
|
-
# OBOE_TRACE_NEVER
|
120
|
-
Oboe::Context.setTracingMode(0)
|
121
|
-
when 'always'
|
122
|
-
# OBOE_TRACE_ALWAYS
|
123
|
-
Oboe::Context.setTracingMode(1)
|
124
|
-
else
|
125
|
-
# OBOE_TRACE_THROUGH
|
126
|
-
Oboe::Context.setTracingMode(2)
|
127
|
-
end
|
116
|
+
Oboe.set_tracing_mode(value)
|
128
117
|
end
|
129
118
|
end
|
130
119
|
|
data/lib/oboe/inst/cassandra.rb
CHANGED
@@ -10,7 +10,7 @@ module Oboe
|
|
10
10
|
begin
|
11
11
|
report_kvs[:Op] = op.to_s
|
12
12
|
report_kvs[:Cf] = column_family.to_s if column_family
|
13
|
-
report_kvs[:Key] = keys.
|
13
|
+
report_kvs[:Key] = keys.inspect if keys
|
14
14
|
|
15
15
|
# Open issue - how to handle multiple Cassandra servers
|
16
16
|
report_kvs[:RemoteHost], report_kvs[:RemotePort] = @servers.first.split(":")
|
data/lib/oboe/inst/mongo.rb
CHANGED
@@ -135,7 +135,7 @@ if defined?(::Mongo) and Oboe::Config[:mongo][:enabled]
|
|
135
135
|
|
136
136
|
begin
|
137
137
|
if m == :find_and_modify and args[0] and args[0].has_key?(:update)
|
138
|
-
report_kvs[:Update_Document] = args[0][:update]
|
138
|
+
report_kvs[:Update_Document] = args[0][:update].inspect
|
139
139
|
end
|
140
140
|
|
141
141
|
if m == :map_reduce
|
data/lib/oboe/inst/rack.rb
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
# Copyright (c) 2013 AppNeta, Inc.
|
2
2
|
# All rights reserved.
|
3
3
|
|
4
|
+
require 'uri'
|
5
|
+
|
4
6
|
module Oboe
|
5
7
|
class Rack
|
6
8
|
attr_reader :app
|
@@ -14,28 +16,31 @@ module Oboe
|
|
14
16
|
|
15
17
|
begin
|
16
18
|
req = ::Rack::Request.new(env)
|
19
|
+
|
17
20
|
report_kvs[:SampleRate] = Oboe::Config[:sample_rate]
|
18
21
|
report_kvs[:SampleSource] = Oboe::Config[:sample_source]
|
19
22
|
report_kvs['HTTP-Host'] = req.host
|
20
23
|
report_kvs['Port'] = req.port
|
21
24
|
report_kvs['Proto'] = req.scheme
|
22
|
-
report_kvs['Query-String'] = req.query_string unless req.query_string.empty?
|
23
|
-
report_kvs[:URL] = req.path
|
25
|
+
report_kvs['Query-String'] = URI.unescape(req.query_string) unless req.query_string.empty?
|
26
|
+
report_kvs[:URL] = URI.unescape(req.path)
|
24
27
|
report_kvs[:Method] = req.request_method
|
25
28
|
report_kvs['AJAX'] = true if req.xhr?
|
26
29
|
report_kvs['ClientIP'] = req.ip
|
27
30
|
|
28
|
-
report_kvs['X-TV-Meta']
|
31
|
+
report_kvs['X-TV-Meta'] = env['HTTP_X_TV_META'] if env.has_key?('HTTP_X_TV_META')
|
29
32
|
|
30
33
|
# Report any request queue'ing headers. Report as 'Request-Start' or the summed Queue-Time
|
31
|
-
report_kvs['Request-Start']
|
32
|
-
report_kvs['Request-Start']
|
33
|
-
report_kvs['Queue-Time']
|
34
|
-
|
35
|
-
report_kvs['Forwarded-For']
|
36
|
-
report_kvs['Forwarded-Host']
|
37
|
-
report_kvs['Forwarded-Proto']
|
38
|
-
report_kvs['Forwarded-Port']
|
34
|
+
report_kvs['Request-Start'] = env['HTTP_X_REQUEST_START'] if env.has_key?('HTTP_X_REQUEST_START')
|
35
|
+
report_kvs['Request-Start'] = env['HTTP_X_QUEUE_START'] if env.has_key?('HTTP_X_QUEUE_START')
|
36
|
+
report_kvs['Queue-Time'] = env['HTTP_X_QUEUE_TIME'] if env.has_key?('HTTP_X_QUEUE_TIME')
|
37
|
+
|
38
|
+
report_kvs['Forwarded-For'] = env['HTTP_X_FORWARDED_FOR'] if env.has_key?('HTTP_X_FORWARDED_FOR')
|
39
|
+
report_kvs['Forwarded-Host'] = env['HTTP_X_FORWARDED_HOST'] if env.has_key?('HTTP_X_FORWARDED_HOST')
|
40
|
+
report_kvs['Forwarded-Proto'] = env['HTTP_X_FORWARDED_PROTO'] if env.has_key?('HTTP_X_FORWARDED_PROTO')
|
41
|
+
report_kvs['Forwarded-Port'] = env['HTTP_X_FORWARDED_PORT'] if env.has_key?('HTTP_X_FORWARDED_PORT')
|
42
|
+
|
43
|
+
report_kvs['Ruby.Oboe.Version'] = ::Oboe::Version::STRING
|
39
44
|
rescue Exception => e
|
40
45
|
# Discard any potential exceptions. Debug log and report whatever we can.
|
41
46
|
Oboe.logger.debug "[oboe/debug] Rack KV collection error: #{e.inspect}"
|
data/lib/oboe/inst/resque.rb
CHANGED
@@ -40,7 +40,7 @@ module Oboe
|
|
40
40
|
if Oboe.tracing?
|
41
41
|
report_kvs = extract_trace_details(:enqueue, klass, args)
|
42
42
|
|
43
|
-
Oboe::API.trace('resque', report_kvs, :enqueue) do
|
43
|
+
Oboe::API.trace('resque-client', report_kvs, :enqueue) do
|
44
44
|
args.push({:parent_trace_id => Oboe::Context.toString}) if Oboe::Config[:resque][:link_workers]
|
45
45
|
enqueue_without_oboe(klass, *args)
|
46
46
|
end
|
@@ -54,7 +54,7 @@ module Oboe
|
|
54
54
|
report_kvs = extract_trace_details(:enqueue_to, klass, args)
|
55
55
|
report_kvs[:Queue] = queue.to_s if queue
|
56
56
|
|
57
|
-
Oboe::API.trace('resque', report_kvs) do
|
57
|
+
Oboe::API.trace('resque-client', report_kvs) do
|
58
58
|
args.push({:parent_trace_id => Oboe::Context.toString}) if Oboe::Config[:resque][:link_workers]
|
59
59
|
enqueue_to_without_oboe(queue, klass, *args)
|
60
60
|
end
|
@@ -67,7 +67,7 @@ module Oboe
|
|
67
67
|
if Oboe.tracing?
|
68
68
|
report_kvs = extract_trace_details(:dequeue, klass, args)
|
69
69
|
|
70
|
-
Oboe::API.trace('resque', report_kvs) do
|
70
|
+
Oboe::API.trace('resque-client', report_kvs) do
|
71
71
|
dequeue_without_oboe(klass, *args)
|
72
72
|
end
|
73
73
|
else
|
@@ -123,12 +123,12 @@ module Oboe
|
|
123
123
|
|
124
124
|
# Force this trace regardless of sampling rate so that child trace can be
|
125
125
|
# link to parent trace.
|
126
|
-
Oboe::API.start_trace('resque', nil, report_kvs.merge('Force' => true)) do
|
126
|
+
Oboe::API.start_trace('resque-worker', nil, report_kvs.merge('Force' => true)) do
|
127
127
|
perform_without_oboe(job)
|
128
128
|
end
|
129
129
|
|
130
130
|
else
|
131
|
-
Oboe::API.start_trace('resque', nil, report_kvs) do
|
131
|
+
Oboe::API.start_trace('resque-worker', nil, report_kvs) do
|
132
132
|
perform_without_oboe(job)
|
133
133
|
end
|
134
134
|
end
|
data/lib/oboe/version.rb
CHANGED
data/lib/oboe_metal.rb
CHANGED
@@ -2,16 +2,10 @@
|
|
2
2
|
# All rights reserved.
|
3
3
|
|
4
4
|
module Oboe_metal
|
5
|
-
class Event
|
6
|
-
def self.metadataString(evt)
|
7
|
-
evt.metadataString()
|
8
|
-
end
|
9
|
-
end
|
10
|
-
|
11
5
|
class Context
|
12
6
|
class << self
|
13
7
|
attr_accessor :layer_op
|
14
|
-
|
8
|
+
|
15
9
|
def log(layer, label, options = {}, with_backtrace = false)
|
16
10
|
evt = Oboe::Context.createEvent()
|
17
11
|
evt.addInfo("Layer", layer.to_s)
|
@@ -25,7 +19,7 @@ module Oboe_metal
|
|
25
19
|
|
26
20
|
Oboe.reporter.sendReport(evt)
|
27
21
|
end
|
28
|
-
|
22
|
+
|
29
23
|
def tracing_layer_op?(operation)
|
30
24
|
if operation.is_a?(Array)
|
31
25
|
return operation.include?(@layer_op)
|
@@ -35,22 +29,30 @@ module Oboe_metal
|
|
35
29
|
end
|
36
30
|
end
|
37
31
|
end
|
38
|
-
|
39
|
-
|
32
|
+
|
33
|
+
class Event
|
34
|
+
def self.metadataString(evt)
|
35
|
+
evt.metadataString()
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
class Reporter
|
40
40
|
##
|
41
41
|
# Initialize the Oboe Context, reporter and report the initialization
|
42
42
|
#
|
43
43
|
def self.start
|
44
|
+
return unless Oboe.loaded
|
45
|
+
|
44
46
|
begin
|
45
47
|
Oboe_metal::Context.init()
|
46
48
|
|
47
49
|
if ENV['RACK_ENV'] == "test"
|
48
|
-
Oboe.reporter = Oboe::FileReporter.new("
|
50
|
+
Oboe.reporter = Oboe::FileReporter.new("/tmp/trace_output.bson")
|
49
51
|
else
|
50
52
|
Oboe.reporter = Oboe::UdpReporter.new(Oboe::Config[:reporter_host])
|
51
53
|
end
|
52
54
|
|
53
|
-
Oboe::API.report_init('
|
55
|
+
Oboe::API.report_init('rack') unless ["development", "test"].include? ENV['RACK_ENV']
|
54
56
|
|
55
57
|
rescue Exception => e
|
56
58
|
$stderr.puts e.message
|
@@ -64,28 +66,11 @@ module Oboe_metal
|
|
64
66
|
end
|
65
67
|
end
|
66
68
|
|
67
|
-
module Oboe
|
69
|
+
module Oboe
|
70
|
+
extend OboeBase
|
68
71
|
include Oboe_metal
|
69
72
|
|
70
73
|
class << self
|
71
|
-
attr_accessor :reporter
|
72
|
-
|
73
|
-
def always?
|
74
|
-
Oboe::Config[:tracing_mode].to_s == "always"
|
75
|
-
end
|
76
|
-
|
77
|
-
def log(layer, label, options = {})
|
78
|
-
Context.log(layer, label, options = options)
|
79
|
-
end
|
80
|
-
|
81
|
-
def never?
|
82
|
-
Oboe::Config[:tracing_mode].to_s == "never"
|
83
|
-
end
|
84
|
-
|
85
|
-
def passthrough?
|
86
|
-
["always", "through"].include?(Oboe::Config[:tracing_mode])
|
87
|
-
end
|
88
|
-
|
89
74
|
def sample?(opts = {})
|
90
75
|
# Assure defaults since SWIG enforces Strings
|
91
76
|
opts[:layer] ||= ''
|
@@ -94,14 +79,36 @@ module Oboe
|
|
94
79
|
Oboe::Context.sampleRequest(opts[:layer], opts[:xtrace], opts['X-TV-Meta'])
|
95
80
|
end
|
96
81
|
|
97
|
-
def
|
98
|
-
|
82
|
+
def set_tracing_mode(mode)
|
83
|
+
return unless Oboe.loaded
|
84
|
+
|
85
|
+
value = mode.to_sym
|
86
|
+
|
87
|
+
case value
|
88
|
+
when :never
|
89
|
+
# OBOE_TRACE_NEVER
|
90
|
+
Oboe::Context.setTracingMode(0)
|
91
|
+
when :always
|
92
|
+
# OBOE_TRACE_ALWAYS
|
93
|
+
Oboe::Context.setTracingMode(1)
|
94
|
+
when :through
|
95
|
+
# OBOE_TRACE_THROUGH
|
96
|
+
Oboe::Context.setTracingMode(2)
|
97
|
+
else
|
98
|
+
Oboe.logger.fatal "[oboe/error] Invalid tracing mode set: #{mode}"
|
99
|
+
# OBOE_TRACE_THROUGH
|
100
|
+
Oboe::Context.setTracingMode(2)
|
101
|
+
end
|
99
102
|
end
|
100
|
-
|
101
|
-
def
|
102
|
-
|
103
|
+
|
104
|
+
def set_sample_rate(rate)
|
105
|
+
if Oboe.loaded
|
106
|
+
# Update liboboe with the new SampleRate value
|
107
|
+
Oboe::Context.setDefaultSampleRate(rate.to_i)
|
108
|
+
end
|
103
109
|
end
|
104
110
|
end
|
105
111
|
end
|
106
112
|
|
113
|
+
Oboe.loaded = true
|
107
114
|
|
@@ -4,11 +4,29 @@ describe Oboe::Inst::Cassandra do
|
|
4
4
|
before do
|
5
5
|
clear_all_traces
|
6
6
|
|
7
|
-
@client = Cassandra.new(
|
8
|
-
:retries => 2, :connect_timeout => 1,
|
9
|
-
:timeout => 5)
|
7
|
+
@client = Cassandra.new("system", "127.0.0.1:9160", { :timeout => 10 })
|
10
8
|
@client.disable_node_auto_discovery!
|
11
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)
|
23
|
+
end
|
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)
|
28
|
+
end
|
29
|
+
|
12
30
|
# These are standard entry/exit KVs that are passed up with all mongo operations
|
13
31
|
@entry_kvs = {
|
14
32
|
'Layer' => 'cassandra',
|
@@ -54,7 +72,7 @@ describe Oboe::Inst::Cassandra do
|
|
54
72
|
validate_event_keys(traces[1], @entry_kvs)
|
55
73
|
traces[1]['Op'].must_equal "insert"
|
56
74
|
traces[1]['Cf'].must_equal "Users"
|
57
|
-
traces[1]['Key'].must_equal "5"
|
75
|
+
traces[1]['Key'].must_equal "\"5\""
|
58
76
|
traces[1]['Consistency'].must_equal "1"
|
59
77
|
traces[1]['Ttl'].must_equal "600"
|
60
78
|
traces[1].has_key?('Backtrace').must_equal Oboe::Config[:cassandra][:collect_backtraces]
|
@@ -74,7 +92,7 @@ describe Oboe::Inst::Cassandra do
|
|
74
92
|
validate_event_keys(traces[1], @entry_kvs)
|
75
93
|
traces[1]['Op'].must_equal "remove"
|
76
94
|
traces[1]['Cf'].must_equal "Users"
|
77
|
-
traces[1]['Key'].must_equal "5"
|
95
|
+
traces[1]['Key'].must_equal "\"5\""
|
78
96
|
traces[1].has_key?('Backtrace').must_equal Oboe::Config[:cassandra][:collect_backtraces]
|
79
97
|
validate_event_keys(traces[2], @exit_kvs)
|
80
98
|
end
|
@@ -94,7 +112,7 @@ describe Oboe::Inst::Cassandra do
|
|
94
112
|
validate_event_keys(traces[1], @entry_kvs)
|
95
113
|
traces[1]['Op'].must_equal "count_columns"
|
96
114
|
traces[1]['Cf'].must_equal "Statuses"
|
97
|
-
traces[1]['Key'].must_equal "12"
|
115
|
+
traces[1]['Key'].must_equal "\"12\""
|
98
116
|
traces[1]['Count'].must_equal "50"
|
99
117
|
traces[1].has_key?('Backtrace').must_equal Oboe::Config[:cassandra][:collect_backtraces]
|
100
118
|
validate_event_keys(traces[2], @exit_kvs)
|
@@ -113,7 +131,7 @@ describe Oboe::Inst::Cassandra do
|
|
113
131
|
validate_event_keys(traces[1], @entry_kvs)
|
114
132
|
traces[1]['Op'].must_equal "get_columns"
|
115
133
|
traces[1]['Cf'].must_equal "Statuses"
|
116
|
-
traces[1]['Key'].must_equal "12"
|
134
|
+
traces[1]['Key'].must_equal "\"12\""
|
117
135
|
traces[1].has_key?('Backtrace').must_equal Oboe::Config[:cassandra][:collect_backtraces]
|
118
136
|
validate_event_keys(traces[2], @exit_kvs)
|
119
137
|
end
|
@@ -149,7 +167,7 @@ describe Oboe::Inst::Cassandra do
|
|
149
167
|
validate_event_keys(traces[1], @entry_kvs)
|
150
168
|
traces[1]['Op'].must_equal "get"
|
151
169
|
traces[1]['Cf'].must_equal "Statuses"
|
152
|
-
traces[1]['Key'].must_equal "12"
|
170
|
+
traces[1]['Key'].must_equal "\"12\""
|
153
171
|
traces[1]['Reversed'].must_equal "true"
|
154
172
|
traces[1].has_key?('Backtrace').must_equal Oboe::Config[:cassandra][:collect_backtraces]
|
155
173
|
validate_event_keys(traces[2], @exit_kvs)
|
@@ -169,13 +187,13 @@ describe Oboe::Inst::Cassandra do
|
|
169
187
|
validate_event_keys(traces[1], @entry_kvs)
|
170
188
|
traces[1]['Op'].must_equal "exists?"
|
171
189
|
traces[1]['Cf'].must_equal "Statuses"
|
172
|
-
traces[1]['Key'].must_equal "12"
|
190
|
+
traces[1]['Key'].must_equal "\"12\""
|
173
191
|
traces[1].has_key?('Backtrace').must_equal Oboe::Config[:cassandra][:collect_backtraces]
|
174
192
|
validate_event_keys(traces[2], @exit_kvs)
|
175
193
|
|
176
194
|
traces[3]['Op'].must_equal "exists?"
|
177
195
|
traces[3]['Cf'].must_equal "Statuses"
|
178
|
-
traces[3]['Key'].must_equal "12"
|
196
|
+
traces[3]['Key'].must_equal "\"12\""
|
179
197
|
traces[3].has_key?('Backtrace').must_equal Oboe::Config[:cassandra][:collect_backtraces]
|
180
198
|
end
|
181
199
|
|
@@ -196,37 +214,53 @@ describe Oboe::Inst::Cassandra do
|
|
196
214
|
validate_event_keys(traces[2], @exit_kvs)
|
197
215
|
end
|
198
216
|
|
199
|
-
it 'should trace create_index
|
217
|
+
it 'should trace create_index' do
|
200
218
|
Oboe::API.start_trace('cassandra_test', '', {}) do
|
201
|
-
@client.create_index(
|
202
|
-
@client.drop_index('TRCassInstr', 'Statuses', 'x')
|
219
|
+
@client.create_index(@ks_name, 'Statuses', 'column_name', 'LongType')
|
203
220
|
end
|
204
|
-
|
221
|
+
|
205
222
|
traces = get_all_traces
|
206
223
|
|
207
|
-
traces.count.must_equal
|
224
|
+
traces.count.must_equal 4
|
208
225
|
validate_outer_layers(traces, 'cassandra_test')
|
209
226
|
|
210
227
|
validate_event_keys(traces[1], @entry_kvs)
|
211
228
|
traces[1]['Op'].must_equal "create_index"
|
212
229
|
traces[1]['Cf'].must_equal "Statuses"
|
213
|
-
traces[1]['Keyspace'].must_equal
|
214
|
-
traces[1]['Column_name'].must_equal "
|
230
|
+
traces[1]['Keyspace'].must_equal @ks_name
|
231
|
+
traces[1]['Column_name'].must_equal "column_name"
|
215
232
|
traces[1]['Validation_class'].must_equal "LongType"
|
216
233
|
traces[1].has_key?('Backtrace').must_equal Oboe::Config[:cassandra][:collect_backtraces]
|
217
234
|
validate_event_keys(traces[2], @exit_kvs)
|
218
235
|
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
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')
|
243
|
+
|
244
|
+
Oboe::API.start_trace('cassandra_test', '', {}) do
|
245
|
+
@client.drop_index(@ks_name, 'Statuses', 'column_name')
|
246
|
+
end
|
247
|
+
|
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)
|
226
260
|
end
|
227
261
|
|
228
262
|
it 'should trace get_indexed_slices' do
|
229
|
-
@client.create_index(
|
263
|
+
@client.create_index(@ks_name, 'Statuses', 'x', 'LongType')
|
230
264
|
Oboe::API.start_trace('cassandra_test', '', {}) do
|
231
265
|
expressions = [
|
232
266
|
{ :column_name => 'x',
|
@@ -252,7 +286,7 @@ describe Oboe::Inst::Cassandra do
|
|
252
286
|
|
253
287
|
it 'should trace add and remove of column family' do
|
254
288
|
cf_name = (0...10).map{ ('a'..'z').to_a[rand(26)] }.join
|
255
|
-
cf_def = CassandraThrift::CfDef.new(:keyspace =>
|
289
|
+
cf_def = CassandraThrift::CfDef.new(:keyspace => @ks_name, :name => cf_name)
|
256
290
|
|
257
291
|
Oboe::API.start_trace('cassandra_test', '', {}) do
|
258
292
|
@client.add_column_family(cf_def)
|
@@ -274,23 +308,22 @@ describe Oboe::Inst::Cassandra do
|
|
274
308
|
traces[3].has_key?('Backtrace').must_equal Oboe::Config[:cassandra][:collect_backtraces]
|
275
309
|
end
|
276
310
|
|
277
|
-
it 'should trace
|
311
|
+
it 'should trace adding a keyspace' do
|
278
312
|
ks_name = (0...10).map{ ('a'..'z').to_a[rand(26)] }.join
|
279
313
|
column_families = [{:name =>"a"}, {:name => "b", :type => :super}]
|
280
314
|
ks_def = CassandraThrift::KsDef.new(:name => ks_name,
|
281
315
|
:strategy_class => "org.apache.cassandra.locator.SimpleStrategy",
|
282
|
-
:replication_factor =>
|
316
|
+
:strategy_options => { 'replication_factor' => '2' },
|
283
317
|
:cf_defs => [])
|
284
318
|
|
285
319
|
Oboe::API.start_trace('cassandra_test', '', {}) do
|
286
320
|
@client.add_keyspace(ks_def)
|
287
321
|
@client.keyspace = ks_name
|
288
|
-
@client.drop_keyspace(ks_name)
|
289
322
|
end
|
290
323
|
|
291
324
|
traces = get_all_traces
|
292
325
|
|
293
|
-
traces.count.must_equal
|
326
|
+
traces.count.must_equal 4
|
294
327
|
validate_outer_layers(traces, 'cassandra_test')
|
295
328
|
|
296
329
|
validate_event_keys(traces[1], @entry_kvs)
|
@@ -298,10 +331,23 @@ describe Oboe::Inst::Cassandra do
|
|
298
331
|
traces[1]['Name'].must_equal ks_name
|
299
332
|
traces[1].has_key?('Backtrace').must_equal Oboe::Config[:cassandra][:collect_backtraces]
|
300
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)
|
339
|
+
end
|
301
340
|
|
302
|
-
traces
|
303
|
-
|
304
|
-
traces
|
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)
|
305
351
|
end
|
306
352
|
|
307
353
|
it "should obey :collect_backtraces setting when true" do
|