couchbase 3.6.0-aarch64-linux → 3.8.0-aarch64-linux

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.
Files changed (53) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +3 -3
  3. data/lib/active_support/cache/couchbase_store.rb +6 -6
  4. data/lib/couchbase/3.2/libcouchbase.so +0 -0
  5. data/lib/couchbase/3.3/libcouchbase.so +0 -0
  6. data/lib/couchbase/3.4/libcouchbase.so +0 -0
  7. data/lib/couchbase/{3.1 → 4.0}/libcouchbase.so +0 -0
  8. data/lib/couchbase/authenticator.rb +14 -0
  9. data/lib/couchbase/binary_collection.rb +37 -22
  10. data/lib/couchbase/bucket.rb +46 -31
  11. data/lib/couchbase/cluster.rb +146 -61
  12. data/lib/couchbase/collection.rb +257 -186
  13. data/lib/couchbase/datastructures/couchbase_list.rb +81 -50
  14. data/lib/couchbase/datastructures/couchbase_map.rb +86 -50
  15. data/lib/couchbase/datastructures/couchbase_queue.rb +64 -38
  16. data/lib/couchbase/datastructures/couchbase_set.rb +57 -41
  17. data/lib/couchbase/deprecations.rb +1 -1
  18. data/lib/couchbase/diagnostics.rb +8 -8
  19. data/lib/couchbase/errors.rb +6 -0
  20. data/lib/couchbase/libcouchbase.rb +1 -1
  21. data/lib/couchbase/management/analytics_index_manager.rb +90 -59
  22. data/lib/couchbase/management/bucket_manager.rb +73 -45
  23. data/lib/couchbase/management/collection_manager.rb +86 -43
  24. data/lib/couchbase/management/collection_query_index_manager.rb +56 -33
  25. data/lib/couchbase/management/query_index_manager.rb +88 -36
  26. data/lib/couchbase/management/scope_search_index_manager.rb +119 -52
  27. data/lib/couchbase/management/search_index_manager.rb +401 -178
  28. data/lib/couchbase/management/user_manager.rb +343 -174
  29. data/lib/couchbase/management/view_index_manager.rb +166 -73
  30. data/lib/couchbase/metrics/logging_meter.rb +108 -0
  31. data/lib/couchbase/metrics/logging_value_recorder.rb +50 -0
  32. data/lib/couchbase/metrics/meter.rb +27 -0
  33. data/lib/couchbase/metrics/noop_meter.rb +30 -0
  34. data/lib/couchbase/metrics/noop_value_recorder.rb +27 -0
  35. data/lib/couchbase/metrics/value_recorder.rb +25 -0
  36. data/lib/couchbase/options.rb +69 -3
  37. data/lib/couchbase/protostellar/cluster.rb +3 -0
  38. data/lib/couchbase/protostellar/response_converter/search.rb +1 -1
  39. data/lib/couchbase/scope.rb +62 -48
  40. data/lib/couchbase/search_options.rb +25 -20
  41. data/lib/couchbase/tracing/noop_span.rb +29 -0
  42. data/lib/couchbase/tracing/noop_tracer.rb +29 -0
  43. data/lib/couchbase/tracing/request_span.rb +34 -0
  44. data/lib/couchbase/tracing/request_tracer.rb +28 -0
  45. data/lib/couchbase/tracing/threshold_logging_span.rb +112 -0
  46. data/lib/couchbase/tracing/threshold_logging_tracer.rb +231 -0
  47. data/lib/couchbase/utils/hdr_histogram.rb +55 -0
  48. data/lib/couchbase/utils/observability.rb +257 -0
  49. data/lib/couchbase/utils/observability_constants.rb +200 -0
  50. data/lib/couchbase/utils/stdlib_logger_adapter.rb +1 -3
  51. data/lib/couchbase/version.rb +1 -1
  52. data/lib/couchbase.rb +2 -2
  53. metadata +37 -8
@@ -190,8 +190,12 @@ module Couchbase
190
190
  alias inspect to_s
191
191
 
192
192
  # @param [Couchbase::Backend] backend
193
- def initialize(backend)
193
+ # @param [Couchbase::Observability::Wrapper] observability wrapper
194
+ #
195
+ # @api private
196
+ def initialize(backend, observability)
194
197
  @backend = backend
198
+ @observability = observability
195
199
  end
196
200
 
197
201
  # Creates new bucket
@@ -204,26 +208,32 @@ module Couchbase
204
208
  # @raise [ArgumentError]
205
209
  # @raise [Error::BucketExists]
206
210
  def create_bucket(settings, options = Options::Bucket::CreateBucket.new)
207
- @backend.bucket_create(
208
- {
209
- name: settings.name,
210
- flush_enabled: settings.flush_enabled,
211
- ram_quota_mb: settings.ram_quota_mb,
212
- num_replicas: settings.num_replicas,
213
- replica_indexes: settings.replica_indexes,
214
- bucket_type: settings.bucket_type,
215
- eviction_policy: settings.eviction_policy,
216
- max_expiry: settings.max_expiry,
217
- compression_mode: settings.compression_mode,
218
- minimum_durability_level: settings.minimum_durability_level,
219
- conflict_resolution_type: settings.conflict_resolution_type,
220
- storage_backend: settings.storage_backend,
221
- history_retention_collection_default: settings.history_retention_collection_default,
222
- history_retention_duration: settings.history_retention_duration,
223
- history_retention_bytes: settings.history_retention_bytes,
224
- num_vbuckets: settings.num_vbuckets,
225
- }, options.to_backend
226
- )
211
+ @observability.record_operation(Observability::OP_BM_CREATE_BUCKET, options.parent_span, self, :management) do |obs_handler|
212
+ obs_handler.add_bucket_name(settings.name)
213
+
214
+ @backend.bucket_create(
215
+ {
216
+ name: settings.name,
217
+ flush_enabled: settings.flush_enabled,
218
+ ram_quota_mb: settings.ram_quota_mb,
219
+ num_replicas: settings.num_replicas,
220
+ replica_indexes: settings.replica_indexes,
221
+ bucket_type: settings.bucket_type,
222
+ eviction_policy: settings.eviction_policy,
223
+ max_expiry: settings.max_expiry,
224
+ compression_mode: settings.compression_mode,
225
+ minimum_durability_level: settings.minimum_durability_level,
226
+ conflict_resolution_type: settings.conflict_resolution_type,
227
+ storage_backend: settings.storage_backend,
228
+ history_retention_collection_default: settings.history_retention_collection_default,
229
+ history_retention_duration: settings.history_retention_duration,
230
+ history_retention_bytes: settings.history_retention_bytes,
231
+ num_vbuckets: settings.num_vbuckets,
232
+ },
233
+ options.to_backend,
234
+ obs_handler,
235
+ )
236
+ end
227
237
  end
228
238
 
229
239
  # Updates the bucket settings
@@ -236,25 +246,31 @@ module Couchbase
236
246
  # @raise [ArgumentError]
237
247
  # @raise [Error::BucketNotFound]
238
248
  def update_bucket(settings, options = Options::Bucket::UpdateBucket.new)
239
- @backend.bucket_update(
240
- {
241
- name: settings.name,
242
- flush_enabled: settings.flush_enabled,
243
- ram_quota_mb: settings.ram_quota_mb,
244
- num_replicas: settings.num_replicas,
245
- replica_indexes: settings.replica_indexes,
246
- bucket_type: settings.bucket_type,
247
- eviction_policy: settings.eviction_policy,
248
- max_expiry: settings.max_expiry,
249
- compression_mode: settings.compression_mode,
250
- minimum_durability_level: settings.minimum_durability_level,
251
- storage_backend: settings.storage_backend,
252
- history_retention_collection_default: settings.history_retention_collection_default,
253
- history_retention_bytes: settings.history_retention_bytes,
254
- history_retention_duration: settings.history_retention_duration,
255
- num_vbuckets: settings.num_vbuckets,
256
- }, options.to_backend
257
- )
249
+ @observability.record_operation(Observability::OP_BM_UPDATE_BUCKET, options.parent_span, self, :management) do |obs_handler|
250
+ obs_handler.add_bucket_name(settings.name)
251
+
252
+ @backend.bucket_update(
253
+ {
254
+ name: settings.name,
255
+ flush_enabled: settings.flush_enabled,
256
+ ram_quota_mb: settings.ram_quota_mb,
257
+ num_replicas: settings.num_replicas,
258
+ replica_indexes: settings.replica_indexes,
259
+ bucket_type: settings.bucket_type,
260
+ eviction_policy: settings.eviction_policy,
261
+ max_expiry: settings.max_expiry,
262
+ compression_mode: settings.compression_mode,
263
+ minimum_durability_level: settings.minimum_durability_level,
264
+ storage_backend: settings.storage_backend,
265
+ history_retention_collection_default: settings.history_retention_collection_default,
266
+ history_retention_bytes: settings.history_retention_bytes,
267
+ history_retention_duration: settings.history_retention_duration,
268
+ num_vbuckets: settings.num_vbuckets,
269
+ },
270
+ options.to_backend,
271
+ obs_handler,
272
+ )
273
+ end
258
274
  end
259
275
 
260
276
  # Removes a bucket
@@ -267,7 +283,11 @@ module Couchbase
267
283
  # @raise [ArgumentError]
268
284
  # @raise [Error::BucketNotFound]
269
285
  def drop_bucket(bucket_name, options = Options::Bucket::DropBucket.new)
270
- @backend.bucket_drop(bucket_name, options.to_backend)
286
+ @observability.record_operation(Observability::OP_BM_DROP_BUCKET, options.parent_span, self, :management) do |obs_handler|
287
+ obs_handler.add_bucket_name(bucket_name)
288
+
289
+ @backend.bucket_drop(bucket_name, options.to_backend, obs_handler)
290
+ end
271
291
  end
272
292
 
273
293
  # Fetch settings of the bucket
@@ -280,7 +300,11 @@ module Couchbase
280
300
  # @raise [ArgumentError]
281
301
  # @raise [Error::BucketNotFound]
282
302
  def get_bucket(bucket_name, options = Options::Bucket::GetBucket.new)
283
- extract_bucket_settings(@backend.bucket_get(bucket_name, options.to_backend))
303
+ @observability.record_operation(Observability::OP_BM_GET_BUCKET, options.parent_span, self, :management) do |obs_handler|
304
+ obs_handler.add_bucket_name(bucket_name)
305
+
306
+ extract_bucket_settings(@backend.bucket_get(bucket_name, options.to_backend, obs_handler))
307
+ end
284
308
  end
285
309
 
286
310
  # Get settings for all buckets
@@ -288,8 +312,10 @@ module Couchbase
288
312
  # @param [Options::Bucket::GetAllBuckets] options
289
313
  # @return [Array<BucketSettings>]
290
314
  def get_all_buckets(options = Options::Bucket::GetAllBuckets.new)
291
- @backend.bucket_get_all(options.to_backend)
292
- .map { |entry| extract_bucket_settings(entry) }
315
+ @observability.record_operation(Observability::OP_BM_GET_ALL_BUCKETS, options.parent_span, self, :management) do |obs_handler|
316
+ @backend.bucket_get_all(options.to_backend, obs_handler)
317
+ .map { |entry| extract_bucket_settings(entry) }
318
+ end
293
319
  end
294
320
 
295
321
  # @param [String] bucket_name name of the bucket
@@ -301,7 +327,9 @@ module Couchbase
301
327
  # @raise [Error::BucketNotFound]
302
328
  # @raise [Error::BucketNotFlushable]
303
329
  def flush_bucket(bucket_name, options = Options::Bucket::FlushBucket.new)
304
- @backend.bucket_flush(bucket_name, options.to_backend)
330
+ @observability.record_operation(Observability::OP_BM_FLUSH_BUCKET, options.parent_span, self, :management) do |obs_handler|
331
+ @backend.bucket_flush(bucket_name, options.to_backend, obs_handler)
332
+ end
305
333
  end
306
334
 
307
335
  # @api private
@@ -198,9 +198,13 @@ module Couchbase
198
198
 
199
199
  # @param [Couchbase::Backend] backend
200
200
  # @param [String] bucket_name
201
- def initialize(backend, bucket_name)
201
+ # @param [Observability::Wrapper] observability wrapper
202
+ #
203
+ # @api private
204
+ def initialize(backend, bucket_name, observability)
202
205
  @backend = backend
203
206
  @bucket_name = bucket_name
207
+ @observability = observability
204
208
  end
205
209
 
206
210
  # Get all scopes
@@ -209,16 +213,18 @@ module Couchbase
209
213
  #
210
214
  # @return [Array<ScopeSpec>]
211
215
  def get_all_scopes(options = Options::Collection::GetAllScopes.new)
212
- res = @backend.scope_get_all(@bucket_name, options.to_backend)
213
- res[:scopes].map do |s|
214
- ScopeSpec.new do |scope|
215
- scope.name = s[:name]
216
- scope.collections = s[:collections].map do |c|
217
- CollectionSpec.new do |collection|
218
- collection.name = c[:name]
219
- collection.scope_name = s[:name]
220
- collection.max_expiry = c[:max_expiry]
221
- collection.history = c[:history]
216
+ @observability.record_operation(Observability::OP_CM_GET_ALL_SCOPES, options.parent_span, self, :management) do |obs_handler|
217
+ res = @backend.scope_get_all(@bucket_name, options.to_backend, obs_handler)
218
+ res[:scopes].map do |s|
219
+ ScopeSpec.new do |scope|
220
+ scope.name = s[:name]
221
+ scope.collections = s[:collections].map do |c|
222
+ CollectionSpec.new do |collection|
223
+ collection.name = c[:name]
224
+ collection.scope_name = s[:name]
225
+ collection.max_expiry = c[:max_expiry]
226
+ collection.history = c[:history]
227
+ end
222
228
  end
223
229
  end
224
230
  end
@@ -236,8 +242,12 @@ module Couchbase
236
242
  #
237
243
  # @raise [Error::ScopeNotFound]
238
244
  def get_scope(scope_name, options = GetScopeOptions.new)
239
- get_all_scopes(Options::Collection::GetAllScopes(timeout: options.timeout))
240
- .find { |scope| scope.name == scope_name } or raise Error::ScopeNotFound, "unable to find scope #{scope_name}"
245
+ @observability.record_operation(Observability::OP_CM_GET_SCOPE, options.parent_span, self, :management) do |obs_handler|
246
+ obs_handler.add_scope_name(scope_name)
247
+
248
+ get_all_scopes(Options::Collection::GetAllScopes(timeout: options.timeout, parent_span: obs_handler.op_span))
249
+ .find { |scope| scope.name == scope_name } or raise Error::ScopeNotFound, "unable to find scope #{scope_name}"
250
+ end
241
251
  end
242
252
 
243
253
  deprecate :get_scope, :get_all_scopes, 2021, 6
@@ -251,7 +261,11 @@ module Couchbase
251
261
  #
252
262
  # @raise [ArgumentError]
253
263
  def create_scope(scope_name, options = Options::Collection::CreateScope.new)
254
- @backend.scope_create(@bucket_name, scope_name, options.to_backend)
264
+ @observability.record_operation(Observability::OP_CM_CREATE_SCOPE, options.parent_span, self, :management) do |obs_handler|
265
+ obs_handler.add_scope_name(scope_name)
266
+
267
+ @backend.scope_create(@bucket_name, scope_name, options.to_backend, obs_handler)
268
+ end
255
269
  end
256
270
 
257
271
  # Removes a scope
@@ -263,7 +277,11 @@ module Couchbase
263
277
  #
264
278
  # @raise [Error::ScopeNotFound]
265
279
  def drop_scope(scope_name, options = Options::Collection::DropScope.new)
266
- @backend.scope_drop(@bucket_name, scope_name, options.to_backend)
280
+ @observability.record_operation(Observability::OP_CM_DROP_SCOPE, options.parent_span, self, :management) do |obs_handler|
281
+ obs_handler.add_scope_name(scope_name)
282
+
283
+ @backend.scope_drop(@bucket_name, scope_name, options.to_backend, obs_handler)
284
+ end
267
285
  end
268
286
 
269
287
  # Creates a new collection
@@ -286,21 +304,31 @@ module Couchbase
286
304
  # @raise [Error::CollectionExists]
287
305
  # @raise [Error::ScopeNotFound]
288
306
  def create_collection(*args)
289
- if args[0].is_a?(CollectionSpec)
290
- collection = args[0]
291
- options = args[1] || Options::Collection::CreateCollection::DEFAULT
292
- settings = CreateCollectionSettings.new(max_expiry: collection.max_expiry, history: collection.history)
293
-
294
- warn "Calling create_collection with a CollectionSpec object has been deprecated, supply scope name, " \
295
- "collection name and optionally a CreateCollectionSettings instance"
296
-
297
- @backend.collection_create(@bucket_name, collection.scope_name, collection.name, settings.to_backend, options.to_backend)
298
- else
299
- scope_name = args[0]
300
- collection_name = args[1]
301
- settings = args[2] || CreateCollectionSettings::DEFAULT
302
- options = args[3] || Options::Collection::CreateCollection::DEFAULT
303
- @backend.collection_create(@bucket_name, scope_name, collection_name, settings.to_backend, options.to_backend)
307
+ scope_name, collection_name, settings, options =
308
+ if args[0].is_a?(CollectionSpec)
309
+ warn "Calling create_collection with a CollectionSpec object has been deprecated, supply scope name, " \
310
+ "collection name and optionally a CreateCollectionSettings instance"
311
+ collection = args[0]
312
+ [
313
+ collection.scope_name,
314
+ collection.name,
315
+ CreateCollectionSettings.new(max_expiry: collection.max_expiry, history: collection.history),
316
+ args[1] || Options::Collection::CreateCollection::DEFAULT,
317
+ ]
318
+ else
319
+ [
320
+ args[0],
321
+ args[1],
322
+ args[2] || CreateCollectionSettings::DEFAULT,
323
+ args[3] || Options::Collection::CreateCollection::DEFAULT,
324
+ ]
325
+ end
326
+
327
+ @observability.record_operation(Observability::OP_CM_CREATE_COLLECTION, options.parent_span, self, :management) do |obs_handler|
328
+ obs_handler.add_scope_name(scope_name)
329
+ obs_handler.add_collection_name(collection_name)
330
+
331
+ @backend.collection_create(@bucket_name, scope_name, collection_name, settings.to_backend, options.to_backend, obs_handler)
304
332
  end
305
333
  end
306
334
 
@@ -315,7 +343,12 @@ module Couchbase
315
343
  # @raise [Error::ScopeNotFound]
316
344
  def update_collection(scope_name, collection_name, settings = UpdateCollectionSettings::DEFAULT,
317
345
  options = Options::Collection::UpdateCollection::DEFAULT)
318
- @backend.collection_update(@bucket_name, scope_name, collection_name, settings.to_backend, options.to_backend)
346
+ @observability.record_operation(Observability::OP_CM_UPDATE_COLLECTION, options.parent_span, self, :management) do |obs_handler|
347
+ obs_handler.add_scope_name(scope_name)
348
+ obs_handler.add_collection_name(collection_name)
349
+
350
+ @backend.collection_update(@bucket_name, scope_name, collection_name, settings.to_backend, options.to_backend, obs_handler)
351
+ end
319
352
  end
320
353
 
321
354
  # Removes a collection
@@ -336,18 +369,28 @@ module Couchbase
336
369
  # @raise [Error::CollectionNotFound]
337
370
  # @raise [Error::ScopeNotFound]
338
371
  def drop_collection(*args)
339
- if args[0].is_a?(CollectionSpec)
340
- collection = args[0]
341
- options = args[1] || Options::Collection::CreateCollection::DEFAULT
342
-
343
- warn "Calling drop_collection with a CollectionSpec object has been deprecated, supply scope name and collection name"
344
-
345
- @backend.collection_drop(@bucket_name, collection.scope_name, collection.name, options.to_backend)
346
- else
347
- scope_name = args[0]
348
- collection_name = args[1]
349
- options = args[2] || Options::Collection::CreateCollection::DEFAULT
350
- @backend.collection_drop(@bucket_name, scope_name, collection_name, options.to_backend)
372
+ scope_name, collection_name, options =
373
+ if args[0].is_a?(CollectionSpec)
374
+ warn "Calling drop_collection with a CollectionSpec object has been deprecated, supply scope name and collection name"
375
+ collection = args[0]
376
+ [
377
+ collection.scope_name,
378
+ collection.name,
379
+ args[1] || Options::Collection::CreateCollection::DEFAULT,
380
+ ]
381
+ else
382
+ [
383
+ args[0],
384
+ args[1],
385
+ args[2] || Options::Collection::CreateCollection::DEFAULT,
386
+ ]
387
+ end
388
+
389
+ @observability.record_operation(Observability::OP_CM_DROP_COLLECTION, options.parent_span, self, :management) do |obs_handler|
390
+ obs_handler.add_scope_name(scope_name)
391
+ obs_handler.add_collection_name(collection_name)
392
+
393
+ @backend.collection_drop(@bucket_name, scope_name, collection_name, options.to_backend, obs_handler)
351
394
  end
352
395
  end
353
396
 
@@ -27,11 +27,15 @@ module Couchbase
27
27
  # @param [String] bucket_name name of the bucket
28
28
  # @param [String] scope_name name of the scope
29
29
  # @param [String] collection_name name of the collection
30
- def initialize(backend, bucket_name, scope_name, collection_name)
30
+ # @param [Observability::Wrapper] observability wrapper
31
+ #
32
+ # @api private
33
+ def initialize(backend, bucket_name, scope_name, collection_name, observability)
31
34
  @backend = backend
32
35
  @bucket_name = bucket_name
33
36
  @scope_name = scope_name
34
37
  @collection_name = collection_name
38
+ @observability = observability
35
39
  end
36
40
 
37
41
  # Fetches all indexes from the server
@@ -52,19 +56,21 @@ module Couchbase
52
56
  "Collection name cannot be set in the options when using the Query Index manager at the collection level"
53
57
  end
54
58
 
55
- res = @backend.collection_query_index_get_all(@bucket_name, @scope_name, @collection_name, options.to_backend)
56
- res[:indexes].map do |idx|
57
- QueryIndex.new do |index|
58
- index.name = idx[:name]
59
- index.is_primary = idx[:is_primary]
60
- index.type = idx[:type]
61
- index.state = idx[:state]
62
- index.bucket = idx[:bucket_name]
63
- index.scope = idx[:scope_name]
64
- index.collection = idx[:collection_name]
65
- index.index_key = idx[:index_key]
66
- index.condition = idx[:condition]
67
- index.partition = idx[:partition]
59
+ @observability.record_operation(Observability::OP_QM_GET_ALL_INDEXES, options.parent_span, self, :query) do |obs_handler|
60
+ res = @backend.collection_query_index_get_all(@bucket_name, @scope_name, @collection_name, options.to_backend, obs_handler)
61
+ res[:indexes].map do |idx|
62
+ QueryIndex.new do |index|
63
+ index.name = idx[:name]
64
+ index.is_primary = idx[:is_primary]
65
+ index.type = idx[:type]
66
+ index.state = idx[:state]
67
+ index.bucket = idx[:bucket_name]
68
+ index.scope = idx[:scope_name]
69
+ index.collection = idx[:collection_name]
70
+ index.index_key = idx[:index_key]
71
+ index.condition = idx[:condition]
72
+ index.partition = idx[:partition]
73
+ end
68
74
  end
69
75
  end
70
76
  end
@@ -90,7 +96,10 @@ module Couchbase
90
96
  "Collection name cannot be set in the options when using the Query Index manager at the collection level"
91
97
  end
92
98
 
93
- @backend.collection_query_index_create(@bucket_name, @scope_name, @collection_name, index_name, fields, options.to_backend)
99
+ @observability.record_operation(Observability::OP_QM_CREATE_INDEX, options.parent_span, self, :query) do |obs_handler|
100
+ @backend.collection_query_index_create(@bucket_name, @scope_name, @collection_name, index_name, fields, options.to_backend,
101
+ obs_handler)
102
+ end
94
103
  end
95
104
 
96
105
  # Creates new primary index
@@ -112,7 +121,9 @@ module Couchbase
112
121
  "Collection name cannot be set in the options when using the Query Index manager at the collection level"
113
122
  end
114
123
 
115
- @backend.collection_query_index_create_primary(@bucket_name, @scope_name, @collection_name, options.to_backend)
124
+ @observability.record_operation(Observability::OP_QM_CREATE_PRIMARY_INDEX, options.parent_span, self, :query) do |obs_handler|
125
+ @backend.collection_query_index_create_primary(@bucket_name, @scope_name, @collection_name, options.to_backend, obs_handler)
126
+ end
116
127
  end
117
128
 
118
129
  # Drops the index
@@ -135,7 +146,9 @@ module Couchbase
135
146
  "Collection name cannot be set in the options when using the Query Index manager at the collection level"
136
147
  end
137
148
 
138
- @backend.collection_query_index_drop(@bucket_name, @scope_name, @collection_name, index_name, options.to_backend)
149
+ @observability.record_operation(Observability::OP_QM_DROP_INDEX, options.parent_span, self, :query) do |obs_handler|
150
+ @backend.collection_query_index_drop(@bucket_name, @scope_name, @collection_name, index_name, options.to_backend, obs_handler)
151
+ end
139
152
  end
140
153
 
141
154
  # Drops the primary index
@@ -157,7 +170,9 @@ module Couchbase
157
170
  "Collection name cannot be set in the options when using the Query Index manager at the collection level"
158
171
  end
159
172
 
160
- @backend.collection_query_index_drop_primary(@bucket_name, @scope_name, @collection_name, options.to_backend)
173
+ @observability.record_operation(Observability::OP_QM_DROP_PRIMARY_INDEX, options.parent_span, self, :query) do |obs_handler|
174
+ @backend.collection_query_index_drop_primary(@bucket_name, @scope_name, @collection_name, options.to_backend, obs_handler)
175
+ end
161
176
  end
162
177
 
163
178
  # Build all indexes which are currently in deferred state
@@ -178,7 +193,9 @@ module Couchbase
178
193
  "Collection name cannot be set in the options when using the Query Index manager at the collection level"
179
194
  end
180
195
 
181
- @backend.collection_query_index_build_deferred(@bucket_name, @scope_name, @collection_name, options.to_backend)
196
+ @observability.record_operation(Observability::OP_QM_BUILD_DEFERRED_INDEXES, options.parent_span, self, :query) do |obs_handler|
197
+ @backend.collection_query_index_build_deferred(@bucket_name, @scope_name, @collection_name, options.to_backend, obs_handler)
198
+ end
182
199
  end
183
200
 
184
201
  # Polls indexes until they are online
@@ -200,24 +217,30 @@ module Couchbase
200
217
  "Collection name cannot be set in the options when using the Query Index manager at the collection level"
201
218
  end
202
219
 
203
- index_names.append("#primary") if options.watch_primary
220
+ @observability.record_operation(Observability::OP_QM_WATCH_INDEXES, options.parent_span, self, :query) do |obs_handler|
221
+ index_names.append("#primary") if options.watch_primary
204
222
 
205
- interval_millis = 50
206
- deadline = Time.now + (Utils::Time.extract_duration(timeout) * 0.001)
207
- while Time.now <= deadline
208
- get_all_opts = Options::Query::GetAllIndexes.new(timeout: ((deadline - Time.now) * 1000).round)
209
- indexes = get_all_indexes(get_all_opts).select { |idx| index_names.include? idx.name }
210
- indexes_not_found = index_names - indexes.map(&:name)
211
- raise Error::IndexNotFound, "Failed to find the indexes: #{indexes_not_found.join(', ')}" unless indexes_not_found.empty?
223
+ interval_millis = 50
224
+ deadline = Time.now + (Utils::Time.extract_duration(timeout) * 0.001)
225
+ all_online = false
226
+ while Time.now <= deadline
227
+ get_all_opts = Options::Query::GetAllIndexes.new(
228
+ timeout: ((deadline - Time.now) * 1000).round,
229
+ parent_span: obs_handler.op_span,
230
+ )
231
+ indexes = get_all_indexes(get_all_opts).select { |idx| index_names.include? idx.name }
232
+ indexes_not_found = index_names - indexes.map(&:name)
233
+ raise Error::IndexNotFound, "Failed to find the indexes: #{indexes_not_found.join(', ')}" unless indexes_not_found.empty?
212
234
 
213
- all_online = indexes.all? { |idx| idx.state == :online }
214
- return if all_online
235
+ all_online = indexes.all? { |idx| idx.state == :online }
236
+ break if all_online
215
237
 
216
- sleep(interval_millis / 1000)
217
- interval_millis += 500
218
- interval_millis = 1000 if interval_millis > 1000
238
+ sleep(interval_millis / 1000)
239
+ interval_millis += 500
240
+ interval_millis = 1000 if interval_millis > 1000
241
+ end
242
+ raise Error::UnambiguousTimeout, "Failed to find all indexes online within the allotted time" unless all_online
219
243
  end
220
- raise Error::UnambiguousTimeout, "Failed to find all indexes online within the allotted time"
221
244
  end
222
245
  end
223
246
  end