couchbase 3.5.6 → 3.6.0

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 (156) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +2 -2
  3. data/ext/cache/extconf_include.rb +3 -3
  4. data/ext/cache/mozilla-ca-bundle.crt +3 -165
  5. data/ext/cache/mozilla-ca-bundle.sha256 +1 -1
  6. data/ext/cache/snappy/{585305c8dbb8f762f2c2e17f937f1cf3ac6cbc9c → 3cde171792b3607f75c14e5011eaf69da4857bd8}/snappy/CMakeLists.txt +14 -10
  7. data/ext/cache/snappy/{585305c8dbb8f762f2c2e17f937f1cf3ac6cbc9c → 3cde171792b3607f75c14e5011eaf69da4857bd8}/snappy/snappy.cc +7 -4
  8. data/ext/couchbase/CMakeLists.txt +12 -1
  9. data/ext/couchbase/cmake/Profiler.cmake +15 -0
  10. data/ext/couchbase/cmake/ThirdPartyDependencies.cmake +2 -2
  11. data/ext/couchbase/cmake/couchbase_cxx_client.pc.in +1 -1
  12. data/ext/couchbase/core/app_telemetry_address.cxx +55 -0
  13. data/ext/couchbase/core/app_telemetry_address.hxx +39 -0
  14. data/ext/couchbase/core/app_telemetry_meter.cxx +753 -0
  15. data/ext/couchbase/core/app_telemetry_meter.hxx +198 -0
  16. data/ext/couchbase/core/app_telemetry_reporter.cxx +895 -0
  17. data/ext/couchbase/core/app_telemetry_reporter.hxx +59 -0
  18. data/ext/couchbase/core/bucket.cxx +77 -35
  19. data/ext/couchbase/core/bucket.hxx +17 -10
  20. data/ext/couchbase/core/cluster.cxx +54 -16
  21. data/ext/couchbase/core/cluster_credentials.cxx +27 -0
  22. data/ext/couchbase/core/cluster_credentials.hxx +36 -0
  23. data/ext/couchbase/core/cluster_options.hxx +12 -0
  24. data/ext/couchbase/core/collections_component.cxx +7 -5
  25. data/ext/couchbase/core/http_component.cxx +6 -0
  26. data/ext/couchbase/core/impl/binary_collection.cxx +4 -0
  27. data/ext/couchbase/core/impl/bucket_manager.cxx +2 -0
  28. data/ext/couchbase/core/impl/cluster.cxx +9 -0
  29. data/ext/couchbase/core/impl/collection.cxx +2 -0
  30. data/ext/couchbase/core/impl/error.cxx +1 -0
  31. data/ext/couchbase/core/impl/logger.cxx +51 -0
  32. data/ext/couchbase/core/impl/replica_utils.cxx +1 -1
  33. data/ext/couchbase/core/impl/transaction_get_multi_replicas_from_preferred_server_group_spec.cxx +32 -0
  34. data/ext/couchbase/core/impl/transaction_get_multi_spec.cxx +30 -0
  35. data/ext/couchbase/core/impl/transaction_op_error_category.cxx +2 -0
  36. data/ext/couchbase/core/io/config_tracker.cxx +6 -6
  37. data/ext/couchbase/core/io/http_command.hxx +35 -11
  38. data/ext/couchbase/core/io/http_session.cxx +10 -0
  39. data/ext/couchbase/core/io/http_session.hxx +4 -0
  40. data/ext/couchbase/core/io/http_session_manager.hxx +83 -34
  41. data/ext/couchbase/core/io/mcbp_command.hxx +41 -2
  42. data/ext/couchbase/core/io/mcbp_session.cxx +52 -19
  43. data/ext/couchbase/core/io/mcbp_session.hxx +3 -0
  44. data/ext/couchbase/core/logger/logger.cxx +46 -0
  45. data/ext/couchbase/core/logger/logger.hxx +41 -1
  46. data/ext/couchbase/core/management/bucket_settings.hxx +1 -0
  47. data/ext/couchbase/core/management/bucket_settings_json.hxx +4 -0
  48. data/ext/couchbase/core/meta/features.hxx +32 -0
  49. data/ext/couchbase/core/operations/document_analytics.cxx +9 -9
  50. data/ext/couchbase/core/operations/document_append.cxx +1 -0
  51. data/ext/couchbase/core/operations/document_append.hxx +1 -0
  52. data/ext/couchbase/core/operations/document_get_all_replicas.hxx +10 -2
  53. data/ext/couchbase/core/operations/document_lookup_in.cxx +4 -0
  54. data/ext/couchbase/core/operations/document_lookup_in_all_replicas.hxx +14 -2
  55. data/ext/couchbase/core/operations/document_lookup_in_any_replica.hxx +4 -0
  56. data/ext/couchbase/core/operations/document_mutate_in.cxx +4 -0
  57. data/ext/couchbase/core/operations/document_mutate_in.hxx +1 -0
  58. data/ext/couchbase/core/operations/document_prepend.cxx +1 -0
  59. data/ext/couchbase/core/operations/document_prepend.hxx +1 -0
  60. data/ext/couchbase/core/operations/document_query.cxx +12 -10
  61. data/ext/couchbase/core/operations/http_noop.cxx +1 -0
  62. data/ext/couchbase/core/operations/management/bucket_create.cxx +3 -0
  63. data/ext/couchbase/core/operations/management/bucket_update.cxx +3 -0
  64. data/ext/couchbase/core/origin.cxx +0 -5
  65. data/ext/couchbase/core/origin.hxx +2 -11
  66. data/ext/couchbase/core/platform/random.cc +6 -3
  67. data/ext/couchbase/core/platform/random.h +2 -2
  68. data/ext/couchbase/core/protocol/cmd_mutate_in.hxx +9 -0
  69. data/ext/couchbase/core/timeout_defaults.hxx +4 -0
  70. data/ext/couchbase/core/topology/configuration.cxx +10 -13
  71. data/ext/couchbase/core/topology/configuration.hxx +14 -15
  72. data/ext/couchbase/core/topology/configuration_json.hxx +6 -0
  73. data/ext/couchbase/core/transactions/async_attempt_context.hxx +22 -2
  74. data/ext/couchbase/core/transactions/attempt_context.hxx +25 -7
  75. data/ext/couchbase/core/transactions/attempt_context_impl.cxx +688 -238
  76. data/ext/couchbase/core/transactions/attempt_context_impl.hxx +91 -12
  77. data/ext/couchbase/core/transactions/exceptions.cxx +5 -0
  78. data/ext/couchbase/core/transactions/exceptions.hxx +20 -0
  79. data/ext/couchbase/core/transactions/exceptions_fmt.hxx +3 -0
  80. data/ext/couchbase/core/transactions/forward_compat.cxx +71 -6
  81. data/ext/couchbase/core/transactions/forward_compat.hxx +45 -59
  82. data/ext/couchbase/core/transactions/get_multi_orchestrator.cxx +616 -0
  83. data/ext/couchbase/core/transactions/get_multi_orchestrator.hxx +61 -0
  84. data/ext/couchbase/core/transactions/internal/doc_record.cxx +8 -0
  85. data/ext/couchbase/core/transactions/internal/doc_record.hxx +16 -5
  86. data/ext/couchbase/core/transactions/internal/exceptions_internal.hxx +12 -0
  87. data/ext/couchbase/core/transactions/internal/transaction_context.hxx +13 -0
  88. data/ext/couchbase/core/transactions/internal/transaction_fields.hxx +1 -0
  89. data/ext/couchbase/core/transactions/staged_mutation.cxx +277 -96
  90. data/ext/couchbase/core/transactions/staged_mutation.hxx +28 -76
  91. data/ext/couchbase/core/transactions/transaction_context.cxx +33 -0
  92. data/ext/couchbase/core/transactions/transaction_get_multi_mode.hxx +28 -0
  93. data/ext/couchbase/core/transactions/transaction_get_multi_replicas_from_preferred_server_group_mode.hxx +27 -0
  94. data/ext/couchbase/core/transactions/transaction_get_multi_replicas_from_preferred_server_group_result.hxx +71 -0
  95. data/ext/couchbase/core/transactions/transaction_get_multi_result.hxx +66 -0
  96. data/ext/couchbase/core/transactions/transaction_links.hxx +10 -0
  97. data/ext/couchbase/core/transactions/transactions.cxx +8 -3
  98. data/ext/couchbase/core/utils/connection_string.cxx +4 -0
  99. data/ext/couchbase/core/utils/url_codec.cxx +26 -0
  100. data/ext/couchbase/core/utils/url_codec.hxx +11 -0
  101. data/ext/couchbase/core/websocket_codec.cxx +647 -0
  102. data/ext/couchbase/core/websocket_codec.hxx +77 -0
  103. data/ext/couchbase/couchbase/analytics_options.hxx +70 -6
  104. data/ext/couchbase/couchbase/application_telemetry_options.hxx +124 -0
  105. data/ext/couchbase/couchbase/cluster_options.hxx +17 -0
  106. data/ext/couchbase/couchbase/error_codes.hxx +1 -0
  107. data/ext/couchbase/couchbase/logger.hxx +16 -0
  108. data/ext/couchbase/couchbase/management/bucket_settings.hxx +1 -0
  109. data/ext/couchbase/couchbase/query_options.hxx +70 -6
  110. data/ext/couchbase/couchbase/transactions/async_attempt_context.hxx +29 -5
  111. data/ext/couchbase/couchbase/transactions/attempt_context.hxx +24 -7
  112. data/ext/couchbase/couchbase/transactions/transaction_get_multi_mode.hxx +47 -0
  113. data/ext/couchbase/couchbase/transactions/transaction_get_multi_options.hxx +44 -0
  114. data/ext/couchbase/couchbase/transactions/transaction_get_multi_replicas_from_preferred_server_group_mode.hxx +46 -0
  115. data/ext/couchbase/couchbase/transactions/transaction_get_multi_replicas_from_preferred_server_group_options.hxx +48 -0
  116. data/ext/couchbase/couchbase/transactions/transaction_get_multi_replicas_from_preferred_server_group_result.hxx +109 -0
  117. data/ext/couchbase/couchbase/transactions/transaction_get_multi_replicas_from_preferred_server_group_spec.hxx +47 -0
  118. data/ext/couchbase/couchbase/transactions/transaction_get_multi_result.hxx +102 -0
  119. data/ext/couchbase/couchbase/transactions/transaction_get_multi_spec.hxx +45 -0
  120. data/ext/extconf.rb +6 -0
  121. data/ext/rcb_buckets.cxx +26 -0
  122. data/lib/active_support/cache/couchbase_store.rb +1 -1
  123. data/lib/couchbase/cluster.rb +1 -1
  124. data/lib/couchbase/collection.rb +1 -1
  125. data/lib/couchbase/collection_options.rb +2 -2
  126. data/lib/couchbase/management/analytics_index_manager.rb +4 -4
  127. data/lib/couchbase/management/bucket_manager.rb +8 -2
  128. data/lib/couchbase/protostellar/cluster.rb +2 -2
  129. data/lib/couchbase/protostellar/collection.rb +1 -1
  130. data/lib/couchbase/protostellar/management/collection_query_index_manager.rb +1 -1
  131. data/lib/couchbase/protostellar/request_generator/admin/bucket.rb +4 -4
  132. data/lib/couchbase/protostellar/request_generator/admin/collection.rb +6 -6
  133. data/lib/couchbase/protostellar/request_generator/admin/query.rb +13 -13
  134. data/lib/couchbase/protostellar/request_generator/kv.rb +25 -25
  135. data/lib/couchbase/protostellar/request_generator/query.rb +4 -4
  136. data/lib/couchbase/protostellar/request_generator/search.rb +25 -25
  137. data/lib/couchbase/protostellar/response_converter/search.rb +1 -1
  138. data/lib/couchbase/protostellar/retry/reason.rb +1 -1
  139. data/lib/couchbase/protostellar/timeouts.rb +1 -1
  140. data/lib/couchbase/scope.rb +1 -1
  141. data/lib/couchbase/transcoder_flags.rb +1 -1
  142. data/lib/couchbase/utils/stdlib_logger_adapter.rb +1 -1
  143. data/lib/couchbase/version.rb +1 -1
  144. metadata +47 -19
  145. /data/ext/cache/snappy/{585305c8dbb8f762f2c2e17f937f1cf3ac6cbc9c → 3cde171792b3607f75c14e5011eaf69da4857bd8}/snappy/COPYING +0 -0
  146. /data/ext/cache/snappy/{585305c8dbb8f762f2c2e17f937f1cf3ac6cbc9c → 3cde171792b3607f75c14e5011eaf69da4857bd8}/snappy/cmake/SnappyConfig.cmake.in +0 -0
  147. /data/ext/cache/snappy/{585305c8dbb8f762f2c2e17f937f1cf3ac6cbc9c → 3cde171792b3607f75c14e5011eaf69da4857bd8}/snappy/cmake/config.h.in +0 -0
  148. /data/ext/cache/snappy/{585305c8dbb8f762f2c2e17f937f1cf3ac6cbc9c → 3cde171792b3607f75c14e5011eaf69da4857bd8}/snappy/snappy-c.cc +0 -0
  149. /data/ext/cache/snappy/{585305c8dbb8f762f2c2e17f937f1cf3ac6cbc9c → 3cde171792b3607f75c14e5011eaf69da4857bd8}/snappy/snappy-c.h +0 -0
  150. /data/ext/cache/snappy/{585305c8dbb8f762f2c2e17f937f1cf3ac6cbc9c → 3cde171792b3607f75c14e5011eaf69da4857bd8}/snappy/snappy-internal.h +0 -0
  151. /data/ext/cache/snappy/{585305c8dbb8f762f2c2e17f937f1cf3ac6cbc9c → 3cde171792b3607f75c14e5011eaf69da4857bd8}/snappy/snappy-sinksource.cc +0 -0
  152. /data/ext/cache/snappy/{585305c8dbb8f762f2c2e17f937f1cf3ac6cbc9c → 3cde171792b3607f75c14e5011eaf69da4857bd8}/snappy/snappy-sinksource.h +0 -0
  153. /data/ext/cache/snappy/{585305c8dbb8f762f2c2e17f937f1cf3ac6cbc9c → 3cde171792b3607f75c14e5011eaf69da4857bd8}/snappy/snappy-stubs-internal.cc +0 -0
  154. /data/ext/cache/snappy/{585305c8dbb8f762f2c2e17f937f1cf3ac6cbc9c → 3cde171792b3607f75c14e5011eaf69da4857bd8}/snappy/snappy-stubs-internal.h +0 -0
  155. /data/ext/cache/snappy/{585305c8dbb8f762f2c2e17f937f1cf3ac6cbc9c → 3cde171792b3607f75c14e5011eaf69da4857bd8}/snappy/snappy-stubs-public.h.in +0 -0
  156. /data/ext/cache/snappy/{585305c8dbb8f762f2c2e17f937f1cf3ac6cbc9c → 3cde171792b3607f75c14e5011eaf69da4857bd8}/snappy/snappy.h +0 -0
@@ -155,6 +155,9 @@ public:
155
155
  if (!callback_) {
156
156
  return;
157
157
  }
158
+ #ifdef COUCHBASE_CXX_CLIENT_COLUMNAR
159
+ dispatch_deadline_.cancel();
160
+ #endif
158
161
  session_ = std::move(session);
159
162
 
160
163
  auto start_op = [self = shared_from_this()]() {
@@ -344,6 +347,9 @@ public:
344
347
  if (!callback_) {
345
348
  return;
346
349
  }
350
+ #ifdef COUCHBASE_CXX_CLIENT_COLUMNAR
351
+ dispatch_deadline_.cancel();
352
+ #endif
347
353
  session_ = std::move(session);
348
354
 
349
355
  session_->write_and_subscribe(
@@ -96,6 +96,7 @@ public:
96
96
  std::move(data),
97
97
  {},
98
98
  {},
99
+ options.cas,
99
100
  options.durability_level,
100
101
  options.timeout,
101
102
  { options.retry_strategy },
@@ -114,6 +115,7 @@ public:
114
115
  std::move(data),
115
116
  {},
116
117
  {},
118
+ options.cas,
117
119
  durability_level::none,
118
120
  options.timeout,
119
121
  { options.retry_strategy },
@@ -165,6 +167,7 @@ public:
165
167
  std::move(data),
166
168
  {},
167
169
  {},
170
+ options.cas,
168
171
  options.durability_level,
169
172
  options.timeout,
170
173
  { options.retry_strategy },
@@ -183,6 +186,7 @@ public:
183
186
  std::move(data),
184
187
  {},
185
188
  {},
189
+ options.cas,
186
190
  durability_level::none,
187
191
  options.timeout,
188
192
  { options.retry_strategy },
@@ -61,6 +61,7 @@ map_bucket_settings(const couchbase::core::management::cluster::bucket_settings&
61
61
  bucket_settings.flush_enabled = bucket.flush_enabled;
62
62
  bucket_settings.history_retention_bytes = bucket.history_retention_bytes;
63
63
  bucket_settings.history_retention_duration = bucket.history_retention_duration;
64
+ bucket_settings.num_vbuckets = bucket.num_vbuckets;
64
65
  switch (bucket.conflict_resolution_type) {
65
66
  case core::management::cluster::bucket_conflict_resolution::unknown:
66
67
  bucket_settings.conflict_resolution_type =
@@ -169,6 +170,7 @@ map_bucket_settings(const couchbase::management::cluster::bucket_settings& bucke
169
170
  bucket.history_retention_collection_default;
170
171
  bucket_settings.history_retention_bytes = bucket.history_retention_bytes;
171
172
  bucket_settings.history_retention_duration = bucket.history_retention_duration;
173
+ bucket_settings.num_vbuckets = bucket.num_vbuckets;
172
174
  switch (bucket.conflict_resolution_type) {
173
175
  case management::cluster::bucket_conflict_resolution::unknown:
174
176
  bucket_settings.conflict_resolution_type =
@@ -192,6 +192,15 @@ options_to_origin(const std::string& connection_string, const couchbase::cluster
192
192
  user_options.tracing_options.eventing_threshold = opts.tracing.eventing_threshold;
193
193
  }
194
194
  user_options.transactions = opts.transactions;
195
+
196
+ user_options.enable_app_telemetry = opts.application_telemetry.enabled;
197
+ if (opts.application_telemetry.enabled) {
198
+ user_options.app_telemetry_endpoint = opts.application_telemetry.endpoint;
199
+ user_options.app_telemetry_ping_interval = opts.application_telemetry.ping_interval;
200
+ user_options.app_telemetry_ping_timeout = opts.application_telemetry.ping_timeout;
201
+ user_options.app_telemetry_backoff_interval = opts.application_telemetry.backoff_interval;
202
+ }
203
+
195
204
  // connection string might override some user options
196
205
  return { auth, core::utils::parse_connection_string(connection_string, user_options) };
197
206
  }
@@ -523,6 +523,7 @@ public:
523
523
  options.cas,
524
524
  options.access_deleted,
525
525
  options.create_as_deleted,
526
+ false,
526
527
  options.expiry,
527
528
  options.store_semantics,
528
529
  specs,
@@ -558,6 +559,7 @@ public:
558
559
  options.cas,
559
560
  options.access_deleted,
560
561
  options.create_as_deleted,
562
+ false,
561
563
  options.expiry,
562
564
  options.store_semantics,
563
565
  specs,
@@ -35,6 +35,7 @@
35
35
  #include "core/error_context/transaction_op_error_context.hxx"
36
36
  #include "core/impl/internal_error_context.hxx"
37
37
  #include "core/transactions/exceptions.hxx"
38
+ #include "core/transactions/exceptions_fmt.hxx"
38
39
  #include "core/transactions/internal/exceptions_internal.hxx"
39
40
 
40
41
  #include <couchbase/error.hxx>
@@ -47,8 +47,59 @@ convert_log_level(couchbase::logger::log_level level) -> core::logger::level
47
47
  }
48
48
  return core::logger::level::off;
49
49
  }
50
+
51
+ auto
52
+ convert_log_level(core::logger::level level) -> couchbase::logger::log_level
53
+ {
54
+ switch (level) {
55
+ case core::logger::level::trace:
56
+ return log_level::trace;
57
+ case core::logger::level::debug:
58
+ return log_level::debug;
59
+ case core::logger::level::info:
60
+ return log_level::info;
61
+ case core::logger::level::warn:
62
+ return log_level::warn;
63
+ case core::logger::level::err:
64
+ return log_level::error;
65
+ case core::logger::level::critical:
66
+ return log_level::critical;
67
+ case core::logger::level::off:
68
+ default:
69
+ break;
70
+ }
71
+ return log_level::off;
72
+ }
73
+
74
+ auto
75
+ convert_log_location(const core::logger::log_location& location) -> couchbase::logger::log_location
76
+ {
77
+ return couchbase::logger::log_location{ location.file, location.function, location.line };
78
+ }
50
79
  } // namespace
51
80
 
81
+ void
82
+ register_log_callback(const log_callback& callback)
83
+ {
84
+ if (callback == nullptr) {
85
+ return;
86
+ }
87
+
88
+ auto core_callback = [callback](const std::string_view msg,
89
+ const core::logger::level level,
90
+ const core::logger::log_location& location) {
91
+ callback(msg, convert_log_level(level), convert_log_location(location));
92
+ };
93
+
94
+ couchbase::core::logger::register_log_callback(std::move(core_callback));
95
+ }
96
+
97
+ void
98
+ unregister_log_callback()
99
+ {
100
+ couchbase::core::logger::unregister_log_callback();
101
+ }
102
+
52
103
  void
53
104
  set_level(log_level level)
54
105
  {
@@ -29,7 +29,7 @@ effective_nodes(const document_id& id,
29
29
  const read_preference& preference,
30
30
  const std::string& preferred_server_group) -> std::vector<readable_node>
31
31
  {
32
- if (preference != read_preference::no_preference && preferred_server_group.empty()) {
32
+ if (preference == read_preference::selected_server_group && preferred_server_group.empty()) {
33
33
  CB_LOG_WARNING("Preferred server group is required for zone-aware replica reads");
34
34
  return {};
35
35
  }
@@ -0,0 +1,32 @@
1
+ /*
2
+ * Copyright 2021-Present Couchbase, Inc.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ #include <couchbase/transactions/transaction_get_multi_replicas_from_preferred_server_group_spec.hxx>
18
+
19
+ #include <couchbase/collection.hxx>
20
+
21
+ namespace couchbase::transactions
22
+ {
23
+ transaction_get_multi_replicas_from_preferred_server_group_spec::
24
+ transaction_get_multi_replicas_from_preferred_server_group_spec(const collection& collection,
25
+ std::string id)
26
+ : bucket_{ collection.bucket_name() }
27
+ , scope_{ collection.scope_name() }
28
+ , collection_{ collection.name() }
29
+ , id_{ std::move(id) }
30
+ {
31
+ }
32
+ } // namespace couchbase::transactions
@@ -0,0 +1,30 @@
1
+ /*
2
+ * Copyright 2021-Present Couchbase, Inc.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ #include <couchbase/transactions/transaction_get_multi_spec.hxx>
18
+
19
+ #include <couchbase/collection.hxx>
20
+
21
+ namespace couchbase::transactions
22
+ {
23
+ transaction_get_multi_spec::transaction_get_multi_spec(const collection& collection, std::string id)
24
+ : bucket_{ collection.bucket_name() }
25
+ , scope_{ collection.scope_name() }
26
+ , collection_{ collection.name() }
27
+ , id_{ std::move(id) }
28
+ {
29
+ }
30
+ } // namespace couchbase::transactions
@@ -70,6 +70,8 @@ struct transaction_op_error_category : std::error_category {
70
70
  return "transaction_already_aborted (1318)";
71
71
  case errc::transaction_op::transaction_already_committed:
72
72
  return "transaction_already_committed (1319)";
73
+ case errc::transaction_op::document_unretrievable:
74
+ return "document_unretrievable (1320)";
73
75
  case errc::transaction_op::transaction_op_failed:
74
76
  return "transaction_op_failed (1399)";
75
77
  }
@@ -99,8 +99,8 @@ public:
99
99
  {
100
100
  io::mcbp_session new_session =
101
101
  origin_.options().enable_tls
102
- ? io::mcbp_session(client_id_, ctx_, tls_, origin_, state_listener_)
103
- : io::mcbp_session(client_id_, ctx_, origin_, state_listener_);
102
+ ? io::mcbp_session(client_id_, {}, ctx_, tls_, origin_, state_listener_)
103
+ : io::mcbp_session(client_id_, {}, ctx_, origin_, state_listener_);
104
104
  #ifdef COUCHBASE_CXX_CLIENT_COLUMNAR
105
105
  new_session.add_background_bootstrap_listener(shared_from_this());
106
106
  #endif
@@ -395,8 +395,8 @@ private:
395
395
  origin_.credentials(), hostname, port, origin_.options());
396
396
  io::mcbp_session session =
397
397
  origin_.options().enable_tls
398
- ? io::mcbp_session(client_id_, ctx_, tls_, origin, state_listener_)
399
- : io::mcbp_session(client_id_, ctx_, origin, state_listener_);
398
+ ? io::mcbp_session(client_id_, node.node_uuid, ctx_, tls_, origin, state_listener_)
399
+ : io::mcbp_session(client_id_, node.node_uuid, ctx_, origin, state_listener_);
400
400
  CB_LOG_DEBUG(R"({} rev={}, add cluster session="{}", address="{}:{}")",
401
401
  log_prefix_,
402
402
  config.rev_str(),
@@ -500,8 +500,8 @@ private:
500
500
  origin_.credentials(), hostname, port, origin_.options());
501
501
  io::mcbp_session session =
502
502
  origin_.options().enable_tls
503
- ? io::mcbp_session(client_id_, ctx_, tls_, origin, state_listener_)
504
- : io::mcbp_session(client_id_, ctx_, origin, state_listener_);
503
+ ? io::mcbp_session(client_id_, node.node_uuid, ctx_, tls_, origin, state_listener_)
504
+ : io::mcbp_session(client_id_, node.node_uuid, ctx_, origin, state_listener_);
505
505
  CB_LOG_DEBUG(R"({} rev={}, restart cluster session="{}", address="{}:{}")",
506
506
  log_prefix_,
507
507
  config_->rev_str(),
@@ -19,6 +19,7 @@
19
19
 
20
20
  #include <couchbase/build_config.hxx>
21
21
 
22
+ #include "core/app_telemetry_meter.hxx"
22
23
  #include "core/impl/bootstrap_error.hxx"
23
24
  #include "core/metrics/meter_wrapper.hxx"
24
25
  #include "core/service_type_fmt.hxx"
@@ -52,6 +53,7 @@ struct http_command : public std::enable_shared_from_this<http_command<Request>>
52
53
  std::shared_ptr<tracing::tracer_wrapper> tracer_;
53
54
  std::shared_ptr<couchbase::tracing::request_span> span_{ nullptr };
54
55
  std::shared_ptr<metrics::meter_wrapper> meter_{};
56
+ std::shared_ptr<core::app_telemetry_meter> app_telemetry_meter_{ nullptr };
55
57
  std::shared_ptr<io::http_session> session_{};
56
58
  http_command_handler handler_{};
57
59
  std::chrono::milliseconds timeout_{};
@@ -65,12 +67,14 @@ struct http_command : public std::enable_shared_from_this<http_command<Request>>
65
67
  Request req,
66
68
  std::shared_ptr<tracing::tracer_wrapper> tracer,
67
69
  std::shared_ptr<metrics::meter_wrapper> meter,
70
+ std::shared_ptr<core::app_telemetry_meter> app_telemetry_meter,
68
71
  std::chrono::milliseconds default_timeout,
69
72
  std::chrono::milliseconds dispatch_timeout)
70
73
  : deadline(ctx)
71
74
  , request(req)
72
75
  , tracer_(std::move(tracer))
73
76
  , meter_(std::move(meter))
77
+ , app_telemetry_meter_(std::move(app_telemetry_meter))
74
78
  , timeout_(request.timeout.value_or(default_timeout))
75
79
  , client_context_id_(request.client_context_id.value_or(uuid::to_string(uuid::random())))
76
80
  , dispatch_timeout_(dispatch_timeout)
@@ -85,11 +89,13 @@ struct http_command : public std::enable_shared_from_this<http_command<Request>>
85
89
  Request req,
86
90
  std::shared_ptr<tracing::tracer_wrapper> tracer,
87
91
  std::shared_ptr<metrics::meter_wrapper> meter,
92
+ std::shared_ptr<core::app_telemetry_meter> app_telemetry_meter,
88
93
  std::chrono::milliseconds default_timeout)
89
94
  : deadline(ctx)
90
95
  , request(req)
91
96
  , tracer_(std::move(tracer))
92
97
  , meter_(std::move(meter))
98
+ , app_telemetry_meter_(std::move(app_telemetry_meter))
93
99
  , timeout_(request.timeout.value_or(default_timeout))
94
100
  , client_context_id_(request.client_context_id.value_or(uuid::to_string(uuid::random())))
95
101
  {
@@ -128,12 +134,9 @@ struct http_command : public std::enable_shared_from_this<http_command<Request>>
128
134
  if (ec == asio::error::operation_aborted) {
129
135
  return;
130
136
  }
131
- CB_LOG_DEBUG(
132
- R"(HTTP request timed out before dispatch: {}, method={}, path="{}", client_context_id="{}")",
133
- self->encoded.type,
134
- self->encoded.method,
135
- self->encoded.path,
136
- self->client_context_id_);
137
+ CB_LOG_DEBUG(R"(HTTP request timed out before dispatch: {}, client_context_id="{}")",
138
+ self->request.type,
139
+ self->client_context_id_);
137
140
  self->cancel(errc::common::unambiguous_timeout);
138
141
  });
139
142
  #endif
@@ -142,10 +145,8 @@ struct http_command : public std::enable_shared_from_this<http_command<Request>>
142
145
  if (ec == asio::error::operation_aborted) {
143
146
  return;
144
147
  }
145
- CB_LOG_DEBUG(R"(HTTP request timed out: {}, method={}, path="{}", client_context_id="{}")",
146
- self->encoded.type,
147
- self->encoded.method,
148
- self->encoded.path,
148
+ CB_LOG_DEBUG(R"(HTTP request timed out: {}, client_context_id="{}")",
149
+ self->request.type,
149
150
  self->client_context_id_);
150
151
  if constexpr (io::http_traits::supports_readonly_v<Request>) {
151
152
  if (self->request.readonly) {
@@ -176,6 +177,22 @@ struct http_command : public std::enable_shared_from_this<http_command<Request>>
176
177
  span_ = nullptr;
177
178
  }
178
179
  if (auto handler = std::move(handler_); handler) {
180
+ const auto& node_uuid = session_ ? session_->node_uuid() : "";
181
+ auto telemetry_recorder = app_telemetry_meter_->value_recorder(node_uuid, {});
182
+ telemetry_recorder->update_counter(total_counter_for_service_type(request.type));
183
+ #ifdef COUCHBASE_CXX_CLIENT_COLUMNAR
184
+ std::error_code ec{};
185
+ if (std::holds_alternative<std::error_code>(error)) {
186
+ ec = std::get<std::error_code>(error);
187
+ } else if (std::holds_alternative<impl::bootstrap_error>(error)) {
188
+ ec = std::get<impl::bootstrap_error>(error).ec;
189
+ }
190
+ #endif
191
+ if (ec == errc::common::ambiguous_timeout || ec == errc::common::unambiguous_timeout) {
192
+ telemetry_recorder->update_counter(timedout_counter_for_service_type(request.type));
193
+ } else if (ec == errc::common::request_canceled) {
194
+ telemetry_recorder->update_counter(canceled_counter_for_service_type(request.type));
195
+ }
179
196
  #ifdef COUCHBASE_CXX_CLIENT_COLUMNAR
180
197
  handler(error, std::move(msg));
181
198
  }
@@ -195,8 +212,9 @@ struct http_command : public std::enable_shared_from_this<http_command<Request>>
195
212
  if (!handler_) {
196
213
  return;
197
214
  }
198
- if (span_->uses_tags())
215
+ if (span_->uses_tags()) {
199
216
  span_->add_tag(tracing::attributes::local_id, session_->id());
217
+ }
200
218
  send();
201
219
  }
202
220
 
@@ -244,6 +262,12 @@ private:
244
262
  if (ec == asio::error::operation_aborted) {
245
263
  return self->invoke_handler(errc::common::ambiguous_timeout, std::move(msg));
246
264
  }
265
+
266
+ auto latency = std::chrono::duration_cast<std::chrono::milliseconds>(
267
+ std::chrono::steady_clock::now() - start);
268
+ self->app_telemetry_meter_->value_recorder(self->session_->node_uuid(), {})
269
+ ->record_latency(latency_for_service_type(self->request.type), latency);
270
+
247
271
  if (self->meter_) {
248
272
  metrics::metric_attributes attrs{
249
273
  self->request.type,
@@ -100,6 +100,7 @@ http_session_info::log_prefix() const -> const std::string&
100
100
 
101
101
  http_session::http_session(couchbase::core::service_type type,
102
102
  std::string client_id,
103
+ std::string node_uuid,
103
104
  asio::io_context& ctx,
104
105
  couchbase::core::cluster_credentials credentials,
105
106
  std::string hostname,
@@ -107,6 +108,7 @@ http_session::http_session(couchbase::core::service_type type,
107
108
  couchbase::core::http_context http_ctx)
108
109
  : type_(type)
109
110
  , client_id_(std::move(client_id))
111
+ , node_uuid_(std::move(node_uuid))
110
112
  , id_(uuid::to_string(uuid::random()))
111
113
  , ctx_(ctx)
112
114
  , resolver_(ctx_)
@@ -125,6 +127,7 @@ http_session::http_session(couchbase::core::service_type type,
125
127
 
126
128
  http_session::http_session(couchbase::core::service_type type,
127
129
  std::string client_id,
130
+ std::string node_uuid,
128
131
  asio::io_context& ctx,
129
132
  asio::ssl::context& tls,
130
133
  couchbase::core::cluster_credentials credentials,
@@ -133,6 +136,7 @@ http_session::http_session(couchbase::core::service_type type,
133
136
  couchbase::core::http_context http_ctx)
134
137
  : type_(type)
135
138
  , client_id_(std::move(client_id))
139
+ , node_uuid_(std::move(node_uuid))
136
140
  , id_(uuid::to_string(uuid::random()))
137
141
  , ctx_(ctx)
138
142
  , resolver_(ctx_)
@@ -207,6 +211,12 @@ http_session::id() const -> const std::string&
207
211
  return id_;
208
212
  }
209
213
 
214
+ auto
215
+ http_session::node_uuid() const -> const std::string&
216
+ {
217
+ return node_uuid_;
218
+ }
219
+
210
220
  auto
211
221
  http_session::credentials() const -> const cluster_credentials&
212
222
  {
@@ -71,6 +71,7 @@ class http_session : public std::enable_shared_from_this<http_session>
71
71
  public:
72
72
  http_session(service_type type,
73
73
  std::string client_id,
74
+ std::string node_uuid,
74
75
  asio::io_context& ctx,
75
76
  cluster_credentials credentials,
76
77
  std::string hostname,
@@ -79,6 +80,7 @@ public:
79
80
 
80
81
  http_session(service_type type,
81
82
  std::string client_id,
83
+ std::string node_uuid,
82
84
  asio::io_context& ctx,
83
85
  asio::ssl::context& tls,
84
86
  cluster_credentials credentials,
@@ -95,6 +97,7 @@ public:
95
97
  [[nodiscard]] auto diag_info() -> diag::endpoint_diag_info;
96
98
  [[nodiscard]] auto log_prefix() -> std::string;
97
99
  [[nodiscard]] auto id() const -> const std::string&;
100
+ [[nodiscard]] auto node_uuid() const -> const std::string&;
98
101
  [[nodiscard]] auto credentials() const -> const cluster_credentials&;
99
102
  [[nodiscard]] auto is_connected() const -> bool;
100
103
  [[nodiscard]] auto type() const -> service_type;
@@ -196,6 +199,7 @@ private:
196
199
 
197
200
  service_type type_{};
198
201
  std::string client_id_;
202
+ std::string node_uuid_;
199
203
  std::string id_;
200
204
  asio::io_context& ctx_;
201
205
  asio::ip::tcp::resolver resolver_;