Module: TraceView::Inst::Cassandra
- Included in:
- Cassandra
- Defined in:
- lib/traceview/inst/twitter-cassandra.rb
Instance Method Summary collapse
- #add_column_family_with_traceview(cf_def) ⇒ Object
- #add_keyspace_with_traceview(ks_def) ⇒ Object
- #count_columns_with_traceview(column_family, key, *columns_and_options) ⇒ Object
- #create_index_with_traceview(keyspace, column_family, column_name, validation_class) ⇒ Object
- #drop_column_family_with_traceview(column_family) ⇒ Object
- #drop_index_with_traceview(keyspace, column_family, column_name) ⇒ Object
- #drop_keyspace_with_traceview(keyspace) ⇒ Object
- #exists_with_traceview?(column_family, key, *columns_and_options) ⇒ Boolean
- #extract_trace_details(op, column_family, keys, args, options = {}) ⇒ Object
- #get_columns_with_traceview(column_family, key, *columns_and_options) ⇒ Object
- #get_indexed_slices_with_traceview(column_family, index_clause, *columns_and_options) ⇒ Object
- #get_range_batch_with_traceview(column_family, options = {}) ⇒ Object
- #get_range_single_with_traceview(column_family, options = {}) ⇒ Object
- #get_with_traceview(column_family, key, *columns_and_options) ⇒ Object
- #insert_with_traceview(column_family, key, hash, options = {}) ⇒ Object
- #multi_get_columns_with_traceview(column_family, key, *columns_and_options) ⇒ Object
- #multi_get_with_traceview(column_family, key, *columns_and_options) ⇒ Object
- #remove_with_traceview(column_family, key, *columns_and_options) ⇒ Object
Instance Method Details
#add_column_family_with_traceview(cf_def) ⇒ Object
213 214 215 216 217 218 219 220 221 222 223 224 225 226 |
# File 'lib/traceview/inst/twitter-cassandra.rb', line 213 def add_column_family_with_traceview(cf_def) return add_column_family_without_traceview(cf_def) unless TraceView.tracing? report_kvs = extract_trace_details(:add_column_family, nil, nil, nil) begin report_kvs[:Cf] = cf_def[:name] if cf_def.is_a?(Hash) && cf_def.key?(:name) rescue => e TraceView.logger.debug "[traceview/debug] #{__method__}:#{File.basename(__FILE__)}:#{__LINE__}: #{e.}" if TraceView::Config[:verbose] end TraceView::API.trace(:cassandra, report_kvs) do add_column_family_without_traceview(cf_def) end end |
#add_keyspace_with_traceview(ks_def) ⇒ Object
238 239 240 241 242 243 244 245 246 247 |
# File 'lib/traceview/inst/twitter-cassandra.rb', line 238 def add_keyspace_with_traceview(ks_def) return add_keyspace_without_traceview(ks_def) unless TraceView.tracing? report_kvs = extract_trace_details(:add_keyspace, nil, nil, nil) report_kvs[:Name] = ks_def.name rescue '' TraceView::API.trace(:cassandra, report_kvs) do add_keyspace_without_traceview(ks_def) end end |
#count_columns_with_traceview(column_family, key, *columns_and_options) ⇒ Object
68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/traceview/inst/twitter-cassandra.rb', line 68 def count_columns_with_traceview(column_family, key, *) args = [column_family, key] + return send :count_columns_without_traceview, *args unless TraceView.tracing? report_kvs = extract_trace_details(:count_columns, column_family, key, ) TraceView::API.trace(:cassandra, report_kvs) do send :count_columns_without_traceview, *args end end |
#create_index_with_traceview(keyspace, column_family, column_name, validation_class) ⇒ Object
178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 |
# File 'lib/traceview/inst/twitter-cassandra.rb', line 178 def create_index_with_traceview(keyspace, column_family, column_name, validation_class) unless TraceView.tracing? return create_index_without_traceview(keyspace, column_family, column_name, validation_class) end report_kvs = extract_trace_details(:create_index, column_family, nil, nil) begin report_kvs[:Keyspace] = keyspace.to_s report_kvs[:Column_name] = column_name.to_s report_kvs[:Validation_class] = validation_class.to_s rescue => e TraceView.logger.debug "[traceview/debug] #{__method__}:#{File.basename(__FILE__)}:#{__LINE__}: #{e.}" if TraceView::Config[:verbose] end TraceView::API.trace(:cassandra, report_kvs) do create_index_without_traceview(keyspace, column_family, column_name, validation_class) end end |
#drop_column_family_with_traceview(column_family) ⇒ Object
228 229 230 231 232 233 234 235 236 |
# File 'lib/traceview/inst/twitter-cassandra.rb', line 228 def drop_column_family_with_traceview(column_family) return drop_column_family_without_traceview(column_family) unless TraceView.tracing? report_kvs = extract_trace_details(:drop_column_family, column_family, nil, nil) TraceView::API.trace(:cassandra, report_kvs) do drop_column_family_without_traceview(column_family) end end |
#drop_index_with_traceview(keyspace, column_family, column_name) ⇒ Object
197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 |
# File 'lib/traceview/inst/twitter-cassandra.rb', line 197 def drop_index_with_traceview(keyspace, column_family, column_name) return drop_index_without_traceview(keyspace, column_family, column_name) unless TraceView.tracing? report_kvs = extract_trace_details(:drop_index, column_family, nil, nil) begin report_kvs[:Keyspace] = keyspace.to_s report_kvs[:Column_name] = column_name.to_s rescue => e TraceView.logger.debug "[traceview/debug] #{__method__}:#{File.basename(__FILE__)}:#{__LINE__}: #{e.}" if TraceView::Config[:verbose] end TraceView::API.trace(:cassandra, report_kvs) do drop_index_without_traceview(keyspace, column_family, column_name) end end |
#drop_keyspace_with_traceview(keyspace) ⇒ Object
249 250 251 252 253 254 255 256 257 258 |
# File 'lib/traceview/inst/twitter-cassandra.rb', line 249 def drop_keyspace_with_traceview(keyspace) return drop_keyspace_without_traceview(keyspace) unless TraceView.tracing? report_kvs = extract_trace_details(:drop_keyspace, nil, nil, nil) report_kvs[:Name] = keyspace.to_s rescue '' TraceView::API.trace(:cassandra, report_kvs) do drop_keyspace_without_traceview(keyspace) end end |
#exists_with_traceview?(column_family, key, *columns_and_options) ⇒ Boolean
132 133 134 135 136 137 138 139 140 141 142 |
# File 'lib/traceview/inst/twitter-cassandra.rb', line 132 def exists_with_traceview?(column_family, key, *) args = [column_family, key] + return send :exists_without_traceview?, *args unless TraceView.tracing? report_kvs = extract_trace_details(:exists?, column_family, key, ) TraceView::API.trace(:cassandra, report_kvs) do send :exists_without_traceview?, *args end end |
#extract_trace_details(op, column_family, keys, args, options = {}) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/traceview/inst/twitter-cassandra.rb', line 7 def extract_trace_details(op, column_family, keys, args, = {}) report_kvs = {} begin report_kvs[:Op] = op.to_s report_kvs[:Cf] = column_family.to_s if column_family report_kvs[:Key] = keys.inspect if keys # Open issue - how to handle multiple Cassandra servers report_kvs[:RemoteHost], report_kvs[:RemotePort] = @servers.first.split(':') report_kvs[:Backtrace] = TraceView::API.backtrace if TraceView::Config[:cassandra][:collect_backtraces] if .empty? && args.is_a?(Array) = args.last if args.last.is_a?(Hash) end unless .empty? [:start_key, :finish_key, :key_count, :batch_size, :columns, :count, :start, :stop, :finish, :finished, :reversed, :consistency, :ttl].each do |k| report_kvs[k.to_s.capitalize] = [k] if .key?(k) end if op == :get_indexed_slices index_clause = [:index_clause] || {} unless index_clause.empty? [:column_name, :value, :comparison].each do |k| report_kvs[k.to_s.capitalize] = index_clause[k] if index_clause.key?(k) end end end end rescue => e TraceView.logger.debug "[traceview/debug] #{__method__}:#{File.basename(__FILE__)}:#{__LINE__}: #{e.}" if TraceView::Config[:verbose] end report_kvs end |
#get_columns_with_traceview(column_family, key, *columns_and_options) ⇒ Object
80 81 82 83 84 85 86 87 88 89 90 91 92 |
# File 'lib/traceview/inst/twitter-cassandra.rb', line 80 def get_columns_with_traceview(column_family, key, *) args = [column_family, key] + if TraceView.tracing? && !TraceView.tracing_layer_op?(:multi_get_columns) report_kvs = extract_trace_details(:get_columns, column_family, key, ) TraceView::API.trace(:cassandra, report_kvs) do send :get_columns_without_traceview, *args end else send :get_columns_without_traceview, *args end end |
#get_indexed_slices_with_traceview(column_family, index_clause, *columns_and_options) ⇒ Object
166 167 168 169 170 171 172 173 174 175 176 |
# File 'lib/traceview/inst/twitter-cassandra.rb', line 166 def get_indexed_slices_with_traceview(column_family, index_clause, *) args = [column_family, index_clause] + return send :get_indexed_slices_without_traceview, *args unless TraceView.tracing? report_kvs = extract_trace_details(:get_indexed_slices, column_family, nil, ) TraceView::API.trace(:cassandra, report_kvs) do send :get_indexed_slices_without_traceview, *args end end |
#get_range_batch_with_traceview(column_family, options = {}) ⇒ Object
156 157 158 159 160 161 162 163 164 |
# File 'lib/traceview/inst/twitter-cassandra.rb', line 156 def get_range_batch_with_traceview(column_family, = {}) return get_range_batch_without_traceview(column_family, ) unless TraceView.tracing? report_kvs = extract_trace_details(:get_range_batch, column_family, nil, nil) TraceView::API.trace(:cassandra, report_kvs, :get_range_batch) do get_range_batch_without_traceview(column_family, ) end end |
#get_range_single_with_traceview(column_family, options = {}) ⇒ Object
144 145 146 147 148 149 150 151 152 153 154 |
# File 'lib/traceview/inst/twitter-cassandra.rb', line 144 def get_range_single_with_traceview(column_family, = {}) if TraceView.tracing? && !TraceView.tracing_layer_op?(:get_range_batch) report_kvs = extract_trace_details(:get_range_single, column_family, nil, nil) TraceView::API.trace(:cassandra, report_kvs) do get_range_single_without_traceview(column_family, ) end else get_range_single_without_traceview(column_family, ) end end |
#get_with_traceview(column_family, key, *columns_and_options) ⇒ Object
106 107 108 109 110 111 112 113 114 115 116 |
# File 'lib/traceview/inst/twitter-cassandra.rb', line 106 def get_with_traceview(column_family, key, *) args = [column_family, key] + return send :get_without_traceview, *args unless TraceView.tracing? report_kvs = extract_trace_details(:get, column_family, key, ) TraceView::API.trace(:cassandra, report_kvs, :get) do send :get_without_traceview, *args end end |
#insert_with_traceview(column_family, key, hash, options = {}) ⇒ Object
46 47 48 49 50 51 52 53 54 |
# File 'lib/traceview/inst/twitter-cassandra.rb', line 46 def insert_with_traceview(column_family, key, hash, = {}) return insert_without_traceview(column_family, key, hash, = {}) unless TraceView.tracing? report_kvs = extract_trace_details(:insert, column_family, key, hash, ) TraceView::API.trace(:cassandra, report_kvs) do insert_without_traceview(column_family, key, hash, = {}) end end |
#multi_get_columns_with_traceview(column_family, key, *columns_and_options) ⇒ Object
94 95 96 97 98 99 100 101 102 103 104 |
# File 'lib/traceview/inst/twitter-cassandra.rb', line 94 def multi_get_columns_with_traceview(column_family, key, *) args = [column_family, key] + return send :multi_get_columns_without_traceview, *args unless TraceView.tracing? report_kvs = extract_trace_details(:multi_get_columns, column_family, key, ) TraceView::API.trace(:cassandra, report_kvs, :multi_get_columns) do send :multi_get_columns_without_traceview, *args end end |
#multi_get_with_traceview(column_family, key, *columns_and_options) ⇒ Object
118 119 120 121 122 123 124 125 126 127 128 129 130 |
# File 'lib/traceview/inst/twitter-cassandra.rb', line 118 def multi_get_with_traceview(column_family, key, *) args = [column_family, key] + if TraceView.tracing? && !TraceView.tracing_layer_op?(:get) report_kvs = extract_trace_details(:multi_get, column_family, key, ) TraceView::API.trace(:cassandra, report_kvs) do send :multi_get_without_traceview, *args end else send :multi_get_without_traceview, *args end end |
#remove_with_traceview(column_family, key, *columns_and_options) ⇒ Object
56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/traceview/inst/twitter-cassandra.rb', line 56 def remove_with_traceview(column_family, key, *) args = [column_family, key] + return send :remove_without_traceview, *args unless TraceView.tracing? report_kvs = extract_trace_details(:remove, column_family, key, ) TraceView::API.trace(:cassandra, report_kvs) do send :remove_without_traceview, *args end end |