couchbase 4.7.0 → 4.7.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (69) hide show
  1. package/deps/couchbase-cxx-cache/mozilla-ca-bundle.crt +3 -575
  2. package/deps/couchbase-cxx-cache/mozilla-ca-bundle.sha256 +1 -1
  3. package/deps/couchbase-cxx-client/CMakeLists.txt +3 -1
  4. package/deps/couchbase-cxx-client/README.md +2 -2
  5. package/deps/couchbase-cxx-client/core/error_context/base_error_context.hxx +32 -0
  6. package/deps/couchbase-cxx-client/core/error_context/key_value.cxx +1 -0
  7. package/deps/couchbase-cxx-client/core/error_context/key_value.hxx +23 -0
  8. package/deps/couchbase-cxx-client/core/error_context/key_value_error_context.hxx +35 -0
  9. package/deps/couchbase-cxx-client/core/error_context/subdocument_error_context.hxx +41 -0
  10. package/deps/couchbase-cxx-client/core/impl/binary_collection.cxx +123 -88
  11. package/deps/couchbase-cxx-client/core/impl/collection.cxx +416 -189
  12. package/deps/couchbase-cxx-client/core/impl/error.cxx +29 -4
  13. package/deps/couchbase-cxx-client/core/impl/invoke_with_node_id.hxx +44 -0
  14. package/deps/couchbase-cxx-client/core/impl/node_id.cxx +110 -0
  15. package/deps/couchbase-cxx-client/core/impl/node_id.hxx +40 -0
  16. package/deps/couchbase-cxx-client/core/io/configuration_belongs_to_session.hxx +67 -0
  17. package/deps/couchbase-cxx-client/core/io/http_session_manager.hxx +97 -57
  18. package/deps/couchbase-cxx-client/core/io/mcbp_session.cxx +7 -16
  19. package/deps/couchbase-cxx-client/core/operations/document_get_all_replicas.hxx +14 -4
  20. package/deps/couchbase-cxx-client/core/operations/document_get_projected.cxx +3 -4
  21. package/deps/couchbase-cxx-client/core/operations/document_lookup_in_all_replicas.hxx +4 -0
  22. package/deps/couchbase-cxx-client/core/operations/document_query.cxx +12 -12
  23. package/deps/couchbase-cxx-client/core/operations/management/collection_create.cxx +11 -11
  24. package/deps/couchbase-cxx-client/core/operations/management/collection_drop.cxx +11 -11
  25. package/deps/couchbase-cxx-client/core/operations/management/collection_update.cxx +11 -11
  26. package/deps/couchbase-cxx-client/core/operations/management/error_utils.cxx +9 -6
  27. package/deps/couchbase-cxx-client/core/operations/management/query_index_create.cxx +5 -4
  28. package/deps/couchbase-cxx-client/core/operations/management/query_index_drop.cxx +7 -6
  29. package/deps/couchbase-cxx-client/core/operations/management/scope_create.cxx +12 -13
  30. package/deps/couchbase-cxx-client/core/operations/management/scope_drop.cxx +8 -9
  31. package/deps/couchbase-cxx-client/core/topology/configuration.cxx +21 -0
  32. package/deps/couchbase-cxx-client/core/topology/configuration.hxx +28 -0
  33. package/deps/couchbase-cxx-client/core/utils/contains_string.cxx +61 -0
  34. package/deps/couchbase-cxx-client/core/utils/contains_string.hxx +26 -0
  35. package/deps/couchbase-cxx-client/couchbase/collection.hxx +73 -0
  36. package/deps/couchbase-cxx-client/couchbase/error.hxx +16 -0
  37. package/deps/couchbase-cxx-client/couchbase/node_id.hxx +123 -0
  38. package/deps/couchbase-cxx-client/couchbase/node_id_for_options.hxx +61 -0
  39. package/deps/couchbase-cxx-client/couchbase/node_ids_options.hxx +62 -0
  40. package/deps/couchbase-cxx-client/couchbase/result.hxx +42 -0
  41. package/dist/binding.d.ts +1 -0
  42. package/dist/bucket.d.ts +9 -1
  43. package/dist/bucket.js +21 -0
  44. package/dist/cluster.d.ts +10 -1
  45. package/dist/cluster.js +22 -0
  46. package/dist/collection.d.ts +3 -3
  47. package/dist/collection.js +161 -123
  48. package/dist/diagnosticsexecutor.js +2 -2
  49. package/dist/diagnosticstypes.d.ts +36 -0
  50. package/dist/diagnosticstypes.js +22 -1
  51. package/dist/observability.d.ts +5 -1
  52. package/dist/observability.js +11 -3
  53. package/dist/observabilityhandler.d.ts +6 -0
  54. package/dist/observabilityhandler.js +51 -14
  55. package/dist/observabilitytypes.js +19 -42
  56. package/dist/observabilityutilities.js +1 -1
  57. package/dist/oteltracer.d.ts +5 -0
  58. package/dist/oteltracer.js +7 -0
  59. package/dist/queryindexmanager.js +15 -0
  60. package/dist/thresholdlogging.d.ts +5 -0
  61. package/dist/thresholdlogging.js +7 -0
  62. package/dist/tracing.d.ts +6 -0
  63. package/dist/version.d.ts +1 -1
  64. package/dist/version.js +1 -1
  65. package/dist/waituntilreadyexecutor.d.ts +37 -0
  66. package/dist/waituntilreadyexecutor.js +156 -0
  67. package/package.json +8 -8
  68. package/scripts/prebuilds.js +13 -0
  69. package/src/binding.cpp +1 -1
@@ -67,13 +67,13 @@ class PingExecutor {
67
67
  */
68
68
  async ping(options) {
69
69
  return new Promise((resolve, reject) => {
70
- // BUG(JSCBC-993): timeout is not currently sent to the C++ client
71
- void options.timeout;
72
70
  this._cluster.conn.ping({
73
71
  report_id: options.reportId,
72
+ bucket_name: options.bucket,
74
73
  services: options.serviceTypes
75
74
  ? options.serviceTypes.map((svc) => (0, bindingutilities_1.serviceTypeToCpp)(svc))
76
75
  : undefined,
76
+ timeout: options.timeout,
77
77
  }, (cppErr, resp) => {
78
78
  const err = (0, bindingutilities_1.errorFromCpp)(cppErr);
79
79
  if (err || !resp) {
@@ -280,3 +280,39 @@ export interface DiagnosticsOptions {
280
280
  */
281
281
  reportId?: string;
282
282
  }
283
+ /**
284
+ * Represents the desired state of a cluster.
285
+ *
286
+ * @category Diagnostics
287
+ */
288
+ export declare enum ClusterState {
289
+ /**
290
+ * Indicates that all nodes and their sockets are reachable.
291
+ */
292
+ Online = "online",
293
+ /**
294
+ * Indicates that at least one socket per service is reachable.
295
+ */
296
+ Degraded = "degraded",
297
+ /**
298
+ * Indicates that not even one socket per service is reachable.
299
+ * Invalid as a desired state for waitUntilReady.
300
+ */
301
+ Offline = "offline"
302
+ }
303
+ /**
304
+ * Options for the waitUntilReady operation on a Cluster or Bucket.
305
+ *
306
+ * @category Diagnostics
307
+ */
308
+ export interface WaitUntilReadyOptions {
309
+ /**
310
+ * The desired cluster state to wait for.
311
+ * Defaults to ClusterState.Online.
312
+ */
313
+ desiredState?: ClusterState;
314
+ /**
315
+ * The set of services to wait on.
316
+ */
317
+ serviceTypes?: ServiceType[];
318
+ }
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.DiagnosticsResult = exports.DiagnosticsEndpoint = exports.PingResult = exports.PingEndpoint = exports.PingState = exports.EndpointState = void 0;
3
+ exports.ClusterState = exports.DiagnosticsResult = exports.DiagnosticsEndpoint = exports.PingResult = exports.PingEndpoint = exports.PingState = exports.EndpointState = void 0;
4
4
  /**
5
5
  * Represents the status of an an endpoint in a diagnostics report.
6
6
  *
@@ -170,3 +170,24 @@ class DiagnosticsResult {
170
170
  }
171
171
  }
172
172
  exports.DiagnosticsResult = DiagnosticsResult;
173
+ /**
174
+ * Represents the desired state of a cluster.
175
+ *
176
+ * @category Diagnostics
177
+ */
178
+ var ClusterState;
179
+ (function (ClusterState) {
180
+ /**
181
+ * Indicates that all nodes and their sockets are reachable.
182
+ */
183
+ ClusterState["Online"] = "online";
184
+ /**
185
+ * Indicates that at least one socket per service is reachable.
186
+ */
187
+ ClusterState["Degraded"] = "degraded";
188
+ /**
189
+ * Indicates that not even one socket per service is reachable.
190
+ * Invalid as a desired state for waitUntilReady.
191
+ */
192
+ ClusterState["Offline"] = "offline";
193
+ })(ClusterState || (exports.ClusterState = ClusterState = {}));
@@ -22,6 +22,10 @@ export declare class NoOpSpan implements RequestSpan {
22
22
  * @internal
23
23
  */
24
24
  end(): void;
25
+ /**
26
+ * @internal
27
+ */
28
+ isRecording(): boolean;
25
29
  /**
26
30
  * @internal
27
31
  */
@@ -39,7 +43,7 @@ export declare class NoOpTracer implements RequestTracer {
39
43
  /**
40
44
  * @internal
41
45
  */
42
- export declare function wrapObservableBindingCall<TReq extends CppObservableRequests, TResp extends CppObservableResponse>(fn: ObservableBindingFunc<TReq, TResp>, req: TReq, obsReqHandler: ObservableRequestHandler): Promise<[Error | null, TResp]>;
46
+ export declare function wrapObservableBindingCall<TReq extends CppObservableRequests, TResp extends CppObservableResponse>(fn: ObservableBindingFunc<TReq, TResp>, req: TReq, obsReqHandler: ObservableRequestHandler | null): Promise<[Error | null, TResp]>;
43
47
  /**
44
48
  * @internal
45
49
  */
@@ -22,6 +22,12 @@ class NoOpSpan {
22
22
  * @internal
23
23
  */
24
24
  end() { }
25
+ /**
26
+ * @internal
27
+ */
28
+ isRecording() {
29
+ return false;
30
+ }
25
31
  /**
26
32
  * @internal
27
33
  */
@@ -47,15 +53,17 @@ exports.NoOpTracer = NoOpTracer;
47
53
  */
48
54
  async function wrapObservableBindingCall(fn, req, obsReqHandler) {
49
55
  return await new Promise((resolve) => {
50
- req.wrapper_span_name = obsReqHandler.wrapperSpanName;
56
+ if (obsReqHandler) {
57
+ req.wrapper_span_name = obsReqHandler.wrapperSpanName;
58
+ }
51
59
  fn(req, (cppErr, res) => {
52
60
  let err = null;
53
61
  if (cppErr) {
54
62
  err = (0, bindingutilities_1.errorFromCpp)(cppErr);
55
- obsReqHandler.processCoreSpan(cppErr.cpp_core_span);
63
+ obsReqHandler === null || obsReqHandler === void 0 ? void 0 : obsReqHandler.processCoreSpan(cppErr.cpp_core_span);
56
64
  }
57
65
  else {
58
- obsReqHandler.processCoreSpan(res.cpp_core_span);
66
+ obsReqHandler === null || obsReqHandler === void 0 ? void 0 : obsReqHandler.processCoreSpan(res.cpp_core_span);
59
67
  }
60
68
  resolve([err, res]);
61
69
  });
@@ -5,6 +5,11 @@ import { ObservabilityInstruments } from './observabilitytypes';
5
5
  import { AttributeValue, CppOpAttributeName, OpType, OpAttributeName, SpanStatus, ServiceName } from './observabilitytypes';
6
6
  import { HttpOpAttributesOptions } from './observabilityutilities';
7
7
  import { RequestSpan, RequestTracer } from './tracing';
8
+ /**
9
+ * Returns true when both tracer and meter are NoOp, enabling the fast-path bypass in KV ops.
10
+ * @internal
11
+ */
12
+ export declare function isNoopObservabilityInstruments(instruments: ObservabilityInstruments): boolean;
8
13
  /**
9
14
  * @internal
10
15
  */
@@ -80,6 +85,7 @@ export declare class WrappedSpan implements RequestSpan {
80
85
  private readonly _tracer;
81
86
  private readonly _hasMultipleEncodingSpans;
82
87
  readonly _requestSpan: RequestSpan;
88
+ private readonly _isRecording;
83
89
  private _parentSpan;
84
90
  private _endedEncodingSpans;
85
91
  private _encodingSpan;
@@ -1,17 +1,22 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.WrappedSpan = exports.ObservableRequestHandler = void 0;
6
+ exports.WrappedSpan = exports.ObservableRequestHandler = exports.isNoopObservabilityInstruments = void 0;
7
+ const binding_1 = __importDefault(require("./binding"));
4
8
  const observability_1 = require("./observability");
5
9
  const observabilitytypes_1 = require("./observabilitytypes");
6
10
  const observabilityutilities_1 = require("./observabilityutilities");
7
11
  const observabilityutilities_2 = require("./observabilityutilities");
8
12
  const utilities_1 = require("./utilities");
13
+ const _DATASTRUCTURE_OPS = new Set(Object.values(observabilitytypes_1.DatastructureOp));
9
14
  /**
10
15
  * @internal
11
16
  */
12
17
  class ObservableRequestHandlerTracerImpl {
13
- constructor(opType, observabilityInstruments, parentSpan) {
14
- this._startTime = (0, observabilityutilities_1.timeInputToHiResTime)();
18
+ constructor(opType, observabilityInstruments, parentSpan, startTime) {
19
+ this._startTime = startTime !== null && startTime !== void 0 ? startTime : (0, observabilityutilities_1.timeInputToHiResTime)();
15
20
  this._opType = opType;
16
21
  this._serviceName = (0, observabilitytypes_1.serviceNameFromOpType)(opType);
17
22
  this._tracer = observabilityInstruments.tracer;
@@ -120,11 +125,23 @@ class ObservableRequestHandlerTracerImpl {
120
125
  * @internal
121
126
  */
122
127
  setRequestKeyValueAttributes(cppDocId, durability) {
123
- const opAttrs = (0, observabilityutilities_1.getAttributesForKeyValueOpType)(this._opType, cppDocId, durability);
124
- for (const [k, v] of Object.entries(opAttrs)) {
125
- this._wrappedSpan.setAttribute(k, v);
128
+ this._wrappedSpan.setAttribute(observabilitytypes_1.OpAttributeName.SystemName, 'couchbase');
129
+ this._wrappedSpan.setAttribute(observabilitytypes_1.OpAttributeName.Service, observabilitytypes_1.ServiceName.KeyValue);
130
+ this._wrappedSpan.setAttribute(observabilitytypes_1.OpAttributeName.OperationName, this._opType);
131
+ this._wrappedSpan.setAttribute(observabilitytypes_1.OpAttributeName.BucketName, cppDocId.bucket);
132
+ this._wrappedSpan.setAttribute(observabilitytypes_1.OpAttributeName.ScopeName, cppDocId.scope);
133
+ this._wrappedSpan.setAttribute(observabilitytypes_1.OpAttributeName.CollectionName, cppDocId.collection);
134
+ if (durability && durability !== binding_1.default.durability_level.none) {
135
+ if (durability === binding_1.default.durability_level.majority) {
136
+ this._wrappedSpan.setAttribute(observabilitytypes_1.OpAttributeName.DurabilityLevel, 'majority');
137
+ }
138
+ else if (durability === binding_1.default.durability_level.majority_and_persist_to_active) {
139
+ this._wrappedSpan.setAttribute(observabilitytypes_1.OpAttributeName.DurabilityLevel, 'majority_and_persist_to_active');
140
+ }
141
+ else if (durability === binding_1.default.durability_level.persist_to_majority) {
142
+ this._wrappedSpan.setAttribute(observabilitytypes_1.OpAttributeName.DurabilityLevel, 'persist_to_majority');
143
+ }
126
144
  }
127
- // TODO: meter attrs
128
145
  }
129
146
  }
130
147
  /**
@@ -223,14 +240,14 @@ class ObservableRequestHandlerNoOpMeterImpl {
223
240
  * @internal
224
241
  */
225
242
  class ObservableRequestHandlerMeterImpl {
226
- constructor(opType, observabilityInstruments) {
243
+ constructor(opType, observabilityInstruments, startTime) {
227
244
  this._attrs = {};
228
245
  this._opType = opType;
229
246
  this._serviceName = (0, observabilitytypes_1.serviceNameFromOpType)(opType);
230
247
  this._meter = observabilityInstruments.meter;
231
248
  this._getClusterLabelsFn = observabilityInstruments.clusterLabelsFn;
232
- this._startTime = (0, observabilityutilities_1.timeInputToHiResTime)();
233
- this._ignoreTopLevelOp = Object.values(observabilitytypes_1.DatastructureOp).includes(opType);
249
+ this._startTime = startTime !== null && startTime !== void 0 ? startTime : (0, observabilityutilities_1.timeInputToHiResTime)();
250
+ this._ignoreTopLevelOp = _DATASTRUCTURE_OPS.has(opType);
234
251
  }
235
252
  /**
236
253
  * @internal
@@ -315,6 +332,17 @@ class ObservableRequestHandlerMeterImpl {
315
332
  tags[observabilitytypes_1.OpAttributeName.ErrorType] = errorType;
316
333
  }
317
334
  }
335
+ const _NOOP_TRACER_IMPL = new ObservableRequestHandlerNoOpTracerImpl('', null);
336
+ const _NOOP_METER_IMPL = new ObservableRequestHandlerNoOpMeterImpl('', null);
337
+ /**
338
+ * Returns true when both tracer and meter are NoOp, enabling the fast-path bypass in KV ops.
339
+ * @internal
340
+ */
341
+ function isNoopObservabilityInstruments(instruments) {
342
+ return ((!instruments.tracer || instruments.tracer instanceof observability_1.NoOpTracer) &&
343
+ instruments.meter instanceof observability_1.NoOpMeter);
344
+ }
345
+ exports.isNoopObservabilityInstruments = isNoopObservabilityInstruments;
318
346
  /**
319
347
  * @internal
320
348
  */
@@ -322,18 +350,19 @@ class ObservableRequestHandler {
322
350
  constructor(opType, observabilityInstruments, parentSpan) {
323
351
  this._opType = opType;
324
352
  this._requestHasEnded = false;
353
+ const startTime = (0, observabilityutilities_1.timeInputToHiResTime)();
325
354
  if (!observabilityInstruments.tracer ||
326
355
  observabilityInstruments.tracer instanceof observability_1.NoOpTracer) {
327
- this._tracerImpl = new ObservableRequestHandlerNoOpTracerImpl(opType, observabilityInstruments, parentSpan);
356
+ this._tracerImpl = _NOOP_TRACER_IMPL;
328
357
  }
329
358
  else {
330
- this._tracerImpl = new ObservableRequestHandlerTracerImpl(opType, observabilityInstruments, parentSpan);
359
+ this._tracerImpl = new ObservableRequestHandlerTracerImpl(opType, observabilityInstruments, parentSpan, startTime);
331
360
  }
332
361
  if (observabilityInstruments.meter instanceof observability_1.NoOpMeter) {
333
- this._meterImpl = new ObservableRequestHandlerNoOpMeterImpl(opType, observabilityInstruments);
362
+ this._meterImpl = _NOOP_METER_IMPL;
334
363
  }
335
364
  else {
336
- this._meterImpl = new ObservableRequestHandlerMeterImpl(opType, observabilityInstruments);
365
+ this._meterImpl = new ObservableRequestHandlerMeterImpl(opType, observabilityInstruments, startTime);
337
366
  }
338
367
  }
339
368
  /**
@@ -444,6 +473,7 @@ class WrappedEncodingSpan {
444
473
  */
445
474
  class WrappedSpan {
446
475
  constructor(serviceName, opType, tracer, startTime, parentSpan) {
476
+ var _a, _b, _c;
447
477
  this._serviceName = serviceName;
448
478
  this._opType = opType;
449
479
  this._tracer = tracer;
@@ -454,6 +484,7 @@ class WrappedSpan {
454
484
  : this._parentSpan;
455
485
  this._hasMultipleEncodingSpans = this._opType == observabilitytypes_1.KeyValueOp.MutateIn;
456
486
  this._requestSpan = this._createRequestSpan(this._opType, startTime, pSpan);
487
+ this._isRecording = (_c = (_b = (_a = this._requestSpan).isRecording) === null || _b === void 0 ? void 0 : _b.call(_a)) !== null && _c !== void 0 ? _c : true;
457
488
  this._endedEncodingSpans = false;
458
489
  this._startTime = startTime;
459
490
  this._endTimeWatermark = (0, observabilityutilities_1.timeInputToHiResTime)();
@@ -660,6 +691,9 @@ class WrappedSpan {
660
691
  * @internal
661
692
  */
662
693
  processCoreSpan(coreSpan) {
694
+ if (!this._isRecording) {
695
+ return;
696
+ }
663
697
  this._maybeSetAttributeFromCoreSpan(coreSpan, observabilitytypes_1.CppOpAttributeName.ClusterName);
664
698
  this._maybeSetAttributeFromCoreSpan(coreSpan, observabilitytypes_1.CppOpAttributeName.ClusterUUID);
665
699
  this._maybeSetAttributeFromCoreSpan(coreSpan, observabilitytypes_1.CppOpAttributeName.RetryCount, true);
@@ -705,6 +739,9 @@ class WrappedSpan {
705
739
  * @internal
706
740
  */
707
741
  setAttribute(key, value) {
742
+ if (!this._isRecording) {
743
+ return;
744
+ }
708
745
  if (key === observabilitytypes_1.OpAttributeName.ClusterName) {
709
746
  this._clusterName = value;
710
747
  }
@@ -263,52 +263,29 @@ var ServiceName;
263
263
  ServiceName["Transactions"] = "transactions";
264
264
  ServiceName["Views"] = "views";
265
265
  })(ServiceName || (exports.ServiceName = ServiceName = {}));
266
+ const _OP_TYPE_TO_SERVICE = new Map([
267
+ ...Object.values(KeyValueOp).map((v) => [v, ServiceName.KeyValue]),
268
+ ...Object.values(DatastructureOp).map((v) => [v, ServiceName.KeyValue]),
269
+ [StreamingOp.Analytics, ServiceName.Analytics],
270
+ [StreamingOp.Query, ServiceName.Query],
271
+ [StreamingOp.Search, ServiceName.Search],
272
+ [StreamingOp.View, ServiceName.Views],
273
+ ...Object.values(AnalyticsMgmtOp).map((v) => [v, ServiceName.Analytics]),
274
+ ...Object.values(BucketMgmtOp).map((v) => [v, ServiceName.Management]),
275
+ ...Object.values(CollectionMgmtOp).map((v) => [v, ServiceName.Management]),
276
+ ...Object.values(EventingFunctionMgmtOp).map((v) => [v, ServiceName.Eventing]),
277
+ ...Object.values(QueryIndexMgmtOp).map((v) => [v, ServiceName.Query]),
278
+ ...Object.values(SearchIndexMgmtOp).map((v) => [v, ServiceName.Search]),
279
+ ...Object.values(UserMgmtOp).map((v) => [v, ServiceName.Management]),
280
+ ...Object.values(ViewIndexMgmtOp).map((v) => [v, ServiceName.Views]),
281
+ ]);
266
282
  /**
267
283
  * @internal
268
284
  */
269
285
  function serviceNameFromOpType(opType) {
270
- if (Object.values(KeyValueOp).includes(opType)) {
271
- return ServiceName.KeyValue;
272
- }
273
- else if (Object.values(DatastructureOp).includes(opType)) {
274
- return ServiceName.KeyValue;
275
- }
276
- else if (Object.values(StreamingOp).includes(opType)) {
277
- switch (opType) {
278
- case StreamingOp.Analytics:
279
- return ServiceName.Analytics;
280
- case StreamingOp.Query:
281
- return ServiceName.Query;
282
- case StreamingOp.Search:
283
- return ServiceName.Search;
284
- case StreamingOp.View:
285
- return ServiceName.Views;
286
- }
287
- }
288
- else if (Object.values(AnalyticsMgmtOp).includes(opType)) {
289
- return ServiceName.Analytics;
290
- }
291
- else if (Object.values(BucketMgmtOp).includes(opType)) {
292
- return ServiceName.Management;
293
- }
294
- else if (Object.values(CollectionMgmtOp).includes(opType)) {
295
- return ServiceName.Management;
296
- }
297
- else if (Object.values(EventingFunctionMgmtOp).includes(opType)) {
298
- return ServiceName.Eventing;
299
- }
300
- else if (Object.values(QueryIndexMgmtOp).includes(opType)) {
301
- return ServiceName.Query;
302
- }
303
- else if (Object.values(SearchIndexMgmtOp).includes(opType)) {
304
- return ServiceName.Search;
305
- }
306
- else if (Object.values(UserMgmtOp).includes(opType)) {
307
- return ServiceName.Management;
308
- }
309
- else if (Object.values(ViewIndexMgmtOp).includes(opType)) {
310
- return ServiceName.Views;
311
- }
286
+ const svc = _OP_TYPE_TO_SERVICE.get(opType);
287
+ if (svc !== undefined)
288
+ return svc;
312
289
  throw new Error(`Unknown OpType: ${opType}`);
313
290
  }
314
291
  exports.serviceNameFromOpType = serviceNameFromOpType;
@@ -120,7 +120,7 @@ exports.timeInputToHiResTime = timeInputToHiResTime;
120
120
  function getAttributesForKeyValueOpType(opType, cppDocId, durability) {
121
121
  const attributes = {
122
122
  [observabilitytypes_1.OpAttributeName.SystemName]: 'couchbase',
123
- [observabilitytypes_1.OpAttributeName.Service]: (0, observabilitytypes_1.serviceNameFromOpType)(opType),
123
+ [observabilitytypes_1.OpAttributeName.Service]: observabilitytypes_1.ServiceName.KeyValue,
124
124
  [observabilitytypes_1.OpAttributeName.OperationName]: opType,
125
125
  [observabilitytypes_1.OpAttributeName.BucketName]: cppDocId.bucket,
126
126
  [observabilitytypes_1.OpAttributeName.ScopeName]: cppDocId.scope,
@@ -40,6 +40,11 @@ export declare class OTelWrapperSpan implements RequestSpan {
40
40
  * @param endTime - Optional timestamp for when the span ended.
41
41
  */
42
42
  end(endTime?: TimeInput): void;
43
+ /**
44
+ * Delegates to the underlying OTel span's isRecording, allowing the SDK
45
+ * to skip attribute and dispatch span work when the sampler dropped the span.
46
+ */
47
+ isRecording(): boolean;
43
48
  }
44
49
  /**
45
50
  * Wrapper class for OpenTelemetry Tracer that implements RequestTracer interface.
@@ -77,6 +77,13 @@ class OTelWrapperSpan {
77
77
  end(endTime) {
78
78
  this._otelSpan.end(endTime);
79
79
  }
80
+ /**
81
+ * Delegates to the underlying OTel span's isRecording, allowing the SDK
82
+ * to skip attribute and dispatch span work when the sampler dropped the span.
83
+ */
84
+ isRecording() {
85
+ return this._otelSpan.isRecording();
86
+ }
80
87
  }
81
88
  exports.OTelWrapperSpan = OTelWrapperSpan;
82
89
  /**
@@ -212,6 +212,14 @@ class InternalQueryIndexManager {
212
212
  }, callback);
213
213
  }
214
214
  }
215
+ /**
216
+ * @internal
217
+ */
218
+ function _checkCollectionQueryIndexManagerOptions(options) {
219
+ if (options.collectionName !== undefined || options.scopeName !== undefined) {
220
+ throw new errors_1.InvalidArgumentError(new Error('collectionName and scopeName are not supported on CollectionQueryIndexManager. Use CollectionQueryIndexManager directly instead.'));
221
+ }
222
+ }
215
223
  /**
216
224
  * CollectionQueryIndexManager provides an interface for managing the
217
225
  * query indexes on the collection.
@@ -244,6 +252,7 @@ class CollectionQueryIndexManager {
244
252
  if (!options) {
245
253
  options = {};
246
254
  }
255
+ _checkCollectionQueryIndexManagerOptions(options);
247
256
  const obsReqHandler = new observabilityhandler_1.ObservableRequestHandler(observabilitytypes_1.QueryIndexMgmtOp.QueryIndexCreate, this._manager.observabilityInstruments, options === null || options === void 0 ? void 0 : options.parentSpan);
248
257
  obsReqHandler.setRequestHttpAttributes();
249
258
  try {
@@ -277,6 +286,7 @@ class CollectionQueryIndexManager {
277
286
  if (!options) {
278
287
  options = {};
279
288
  }
289
+ _checkCollectionQueryIndexManagerOptions(options);
280
290
  const obsReqHandler = new observabilityhandler_1.ObservableRequestHandler(observabilitytypes_1.QueryIndexMgmtOp.QueryIndexCreate, this._manager.observabilityInstruments, options === null || options === void 0 ? void 0 : options.parentSpan);
281
291
  obsReqHandler.setRequestHttpAttributes();
282
292
  try {
@@ -309,6 +319,7 @@ class CollectionQueryIndexManager {
309
319
  if (!options) {
310
320
  options = {};
311
321
  }
322
+ _checkCollectionQueryIndexManagerOptions(options);
312
323
  const obsReqHandler = new observabilityhandler_1.ObservableRequestHandler(observabilitytypes_1.QueryIndexMgmtOp.QueryIndexDrop, this._manager.observabilityInstruments, options === null || options === void 0 ? void 0 : options.parentSpan);
313
324
  obsReqHandler.setRequestHttpAttributes();
314
325
  try {
@@ -339,6 +350,7 @@ class CollectionQueryIndexManager {
339
350
  if (!options) {
340
351
  options = {};
341
352
  }
353
+ _checkCollectionQueryIndexManagerOptions(options);
342
354
  const obsReqHandler = new observabilityhandler_1.ObservableRequestHandler(observabilitytypes_1.QueryIndexMgmtOp.QueryIndexDrop, this._manager.observabilityInstruments, options === null || options === void 0 ? void 0 : options.parentSpan);
343
355
  obsReqHandler.setRequestHttpAttributes();
344
356
  try {
@@ -369,6 +381,7 @@ class CollectionQueryIndexManager {
369
381
  if (!options) {
370
382
  options = {};
371
383
  }
384
+ _checkCollectionQueryIndexManagerOptions(options);
372
385
  const obsReqHandler = new observabilityhandler_1.ObservableRequestHandler(observabilitytypes_1.QueryIndexMgmtOp.QueryIndexGetAll, this._manager.observabilityInstruments, options === null || options === void 0 ? void 0 : options.parentSpan);
373
386
  obsReqHandler.setRequestHttpAttributes();
374
387
  try {
@@ -397,6 +410,7 @@ class CollectionQueryIndexManager {
397
410
  if (!options) {
398
411
  options = {};
399
412
  }
413
+ _checkCollectionQueryIndexManagerOptions(options);
400
414
  const obsReqHandler = new observabilityhandler_1.ObservableRequestHandler(observabilitytypes_1.QueryIndexMgmtOp.QueryIndexBuildDeferred, this._manager.observabilityInstruments, options === null || options === void 0 ? void 0 : options.parentSpan);
401
415
  obsReqHandler.setRequestHttpAttributes();
402
416
  try {
@@ -427,6 +441,7 @@ class CollectionQueryIndexManager {
427
441
  if (!options) {
428
442
  options = {};
429
443
  }
444
+ _checkCollectionQueryIndexManagerOptions(options);
430
445
  const obsReqHandler = new observabilityhandler_1.ObservableRequestHandler(observabilitytypes_1.QueryIndexMgmtOp.QueryIndexWatchIndexes, this._manager.observabilityInstruments, options === null || options === void 0 ? void 0 : options.parentSpan);
431
446
  obsReqHandler.setRequestHttpAttributes();
432
447
  try {
@@ -196,6 +196,11 @@ export declare class ThresholdLoggingSpan implements RequestSpan {
196
196
  * Adds a timestamped event to the span.
197
197
  */
198
198
  addEvent(): void;
199
+ /**
200
+ * Always returns true — threshold logging spans must record every operation
201
+ * to evaluate against configured thresholds.
202
+ */
203
+ isRecording(): boolean;
199
204
  /**
200
205
  * Sets the status of the span.
201
206
  *
@@ -447,6 +447,13 @@ class ThresholdLoggingSpan {
447
447
  * Adds a timestamped event to the span.
448
448
  */
449
449
  addEvent() { }
450
+ /**
451
+ * Always returns true — threshold logging spans must record every operation
452
+ * to evaluate against configured thresholds.
453
+ */
454
+ isRecording() {
455
+ return true;
456
+ }
450
457
  /**
451
458
  * Sets the status of the span.
452
459
  *
package/dist/tracing.d.ts CHANGED
@@ -36,6 +36,12 @@ export interface RequestSpan {
36
36
  * @param endTime - Optional end time; defaults to current time if not provided.
37
37
  */
38
38
  end(endTime?: TimeInput): void;
39
+ /**
40
+ * Returns whether this span is actively recording. When false, setAttribute
41
+ * and processCoreSpan work is skipped. Defaults to true when not implemented,
42
+ * preserving backward compatibility with existing custom implementations.
43
+ */
44
+ isRecording?(): boolean;
39
45
  }
40
46
  /**
41
47
  * Interface for creating and managing distributed tracing spans.
package/dist/version.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- export declare const SDK_VERSION = "4.7.0";
1
+ export declare const SDK_VERSION = "4.7.1";
2
2
  export declare const SDK_NAME = "couchbase";
package/dist/version.js CHANGED
@@ -3,5 +3,5 @@
3
3
  // DO NOT EDIT DIRECTLY.
4
4
  Object.defineProperty(exports, "__esModule", { value: true });
5
5
  exports.SDK_NAME = exports.SDK_VERSION = void 0;
6
- exports.SDK_VERSION = '4.7.0';
6
+ exports.SDK_VERSION = '4.7.1';
7
7
  exports.SDK_NAME = 'couchbase';
@@ -0,0 +1,37 @@
1
+ import { Cluster } from './cluster';
2
+ import { WaitUntilReadyOptions } from './diagnosticstypes';
3
+ /**
4
+ * @internal
5
+ */
6
+ export declare class WaitUntilReadyExecutor {
7
+ private _cluster;
8
+ private _bucketName;
9
+ private _diagExec;
10
+ private _pingExec;
11
+ /**
12
+ * @internal
13
+ */
14
+ constructor(cluster: Cluster, bucketName?: string);
15
+ /**
16
+ * Checks whether the endpoints for a single service satisfy the desired cluster state.
17
+ *
18
+ * @internal
19
+ */
20
+ private _meetsDesiredState;
21
+ /**
22
+ * Logs any ping endpoints that reported an error, at warn level.
23
+ *
24
+ * @internal
25
+ */
26
+ private _logPingErrors;
27
+ /**
28
+ * Builds the set of services to wait on, either from the user provided list or via discovery ping.
29
+ *
30
+ * @internal
31
+ */
32
+ private _resolveWaitSet;
33
+ /**
34
+ * @internal
35
+ */
36
+ waitUntilReady(timeout: number, options: WaitUntilReadyOptions): Promise<void>;
37
+ }