couchbase 3.1.1 → 3.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (220) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +2 -2
  3. data/ext/CMakeLists.txt +3 -1
  4. data/ext/build_version.hxx.in +1 -1
  5. data/ext/cmake/Testing.cmake +1 -0
  6. data/ext/cmake/ThirdPartyDependencies.cmake +6 -0
  7. data/ext/cmake/VersionInfo.cmake +3 -0
  8. data/ext/couchbase/bucket.hxx +47 -28
  9. data/ext/couchbase/cbsasl/client.h +1 -1
  10. data/ext/couchbase/cbsasl/context.cc +1 -1
  11. data/ext/couchbase/cbsasl/context.h +3 -3
  12. data/ext/couchbase/cbsasl/mechanism.cc +5 -8
  13. data/ext/couchbase/cbsasl/mechanism.h +1 -4
  14. data/ext/couchbase/cbsasl/plain/plain.cc +1 -1
  15. data/ext/couchbase/cbsasl/scram-sha/scram-sha.cc +30 -36
  16. data/ext/couchbase/cluster.hxx +40 -22
  17. data/ext/couchbase/cluster_options.hxx +7 -1
  18. data/ext/couchbase/configuration.hxx +37 -16
  19. data/ext/couchbase/couchbase.cxx +1145 -291
  20. data/ext/couchbase/error_map.hxx +1 -1
  21. data/ext/couchbase/errors.hxx +25 -17
  22. data/ext/couchbase/io/dns_client.hxx +3 -3
  23. data/ext/couchbase/io/dns_codec.hxx +4 -5
  24. data/ext/couchbase/io/dns_config.hxx +5 -6
  25. data/ext/couchbase/io/dns_message.hxx +3 -3
  26. data/ext/couchbase/io/http_command.hxx +70 -35
  27. data/ext/couchbase/io/http_session.hxx +4 -3
  28. data/ext/couchbase/io/http_session_manager.hxx +28 -19
  29. data/ext/couchbase/io/mcbp_command.hxx +51 -19
  30. data/ext/couchbase/io/mcbp_context.hxx +1 -1
  31. data/ext/couchbase/io/mcbp_parser.hxx +4 -4
  32. data/ext/couchbase/io/mcbp_session.hxx +91 -101
  33. data/ext/couchbase/io/query_cache.hxx +2 -2
  34. data/ext/couchbase/io/retry_orchestrator.hxx +2 -4
  35. data/ext/couchbase/io/retry_reason.hxx +2 -2
  36. data/ext/couchbase/io/retry_strategy.hxx +1 -6
  37. data/ext/couchbase/io/streams.hxx +7 -7
  38. data/ext/couchbase/metrics/logging_meter.hxx +228 -0
  39. data/ext/couchbase/metrics/logging_meter_options.hxx +28 -0
  40. data/ext/couchbase/metrics/meter.hxx +49 -0
  41. data/ext/couchbase/metrics/noop_meter.hxx +43 -0
  42. data/ext/couchbase/operations/analytics_dataset_create.hxx +16 -12
  43. data/ext/couchbase/operations/analytics_dataset_drop.hxx +11 -11
  44. data/ext/couchbase/operations/analytics_dataset_get_all.hxx +6 -6
  45. data/ext/couchbase/operations/analytics_dataverse_create.hxx +10 -11
  46. data/ext/couchbase/operations/analytics_dataverse_drop.hxx +10 -11
  47. data/ext/couchbase/operations/analytics_get_pending_mutations.hxx +9 -11
  48. data/ext/couchbase/operations/analytics_index_create.hxx +14 -13
  49. data/ext/couchbase/operations/analytics_index_drop.hxx +18 -12
  50. data/ext/couchbase/operations/analytics_index_get_all.hxx +8 -6
  51. data/ext/couchbase/operations/analytics_link.hxx +39 -0
  52. data/ext/couchbase/operations/analytics_link_azure_blob_external.hxx +145 -0
  53. data/ext/couchbase/operations/analytics_link_connect.hxx +14 -12
  54. data/ext/couchbase/operations/analytics_link_couchbase_remote.hxx +220 -0
  55. data/ext/couchbase/operations/analytics_link_create.hxx +128 -0
  56. data/ext/couchbase/operations/analytics_link_disconnect.hxx +11 -12
  57. data/ext/couchbase/operations/analytics_link_drop.hxx +130 -0
  58. data/ext/couchbase/operations/analytics_link_get_all.hxx +160 -0
  59. data/ext/couchbase/operations/analytics_link_replace.hxx +128 -0
  60. data/ext/couchbase/operations/analytics_link_s3_external.hxx +122 -0
  61. data/ext/couchbase/operations/bucket_create.hxx +8 -8
  62. data/ext/couchbase/operations/bucket_drop.hxx +5 -5
  63. data/ext/couchbase/operations/bucket_flush.hxx +5 -5
  64. data/ext/couchbase/operations/bucket_get.hxx +7 -7
  65. data/ext/couchbase/operations/bucket_get_all.hxx +7 -5
  66. data/ext/couchbase/operations/bucket_settings.hxx +40 -49
  67. data/ext/couchbase/operations/bucket_update.hxx +8 -8
  68. data/ext/couchbase/operations/cluster_developer_preview_enable.hxx +7 -7
  69. data/ext/couchbase/operations/collection_create.hxx +11 -11
  70. data/ext/couchbase/operations/collection_drop.hxx +12 -10
  71. data/ext/couchbase/operations/collections_manifest_get.hxx +3 -3
  72. data/ext/couchbase/operations/design_document.hxx +2 -2
  73. data/ext/couchbase/operations/document_analytics.hxx +29 -36
  74. data/ext/couchbase/operations/document_append.hxx +3 -3
  75. data/ext/couchbase/operations/document_decrement.hxx +3 -3
  76. data/ext/couchbase/operations/document_exists.hxx +2 -2
  77. data/ext/couchbase/operations/document_get.hxx +3 -3
  78. data/ext/couchbase/operations/document_get_and_lock.hxx +5 -3
  79. data/ext/couchbase/operations/document_get_and_touch.hxx +5 -3
  80. data/ext/couchbase/operations/document_get_projected.hxx +10 -11
  81. data/ext/couchbase/operations/document_increment.hxx +3 -3
  82. data/ext/couchbase/operations/document_insert.hxx +3 -3
  83. data/ext/couchbase/operations/document_lookup_in.hxx +12 -18
  84. data/ext/couchbase/operations/document_mutate_in.hxx +13 -18
  85. data/ext/couchbase/operations/document_prepend.hxx +3 -3
  86. data/ext/couchbase/operations/document_query.hxx +39 -41
  87. data/ext/couchbase/operations/document_remove.hxx +3 -3
  88. data/ext/couchbase/operations/document_replace.hxx +3 -3
  89. data/ext/couchbase/operations/document_search.hxx +56 -61
  90. data/ext/couchbase/operations/document_touch.hxx +3 -3
  91. data/ext/couchbase/operations/document_unlock.hxx +3 -3
  92. data/ext/couchbase/operations/document_upsert.hxx +3 -3
  93. data/ext/couchbase/operations/document_view.hxx +23 -23
  94. data/ext/couchbase/operations/group_drop.hxx +5 -5
  95. data/ext/couchbase/operations/group_get.hxx +7 -7
  96. data/ext/couchbase/operations/group_get_all.hxx +6 -6
  97. data/ext/couchbase/operations/group_upsert.hxx +11 -11
  98. data/ext/couchbase/operations/http_noop.hxx +6 -6
  99. data/ext/couchbase/operations/mcbp_noop.hxx +3 -3
  100. data/ext/couchbase/operations/query_index_build_deferred.hxx +6 -6
  101. data/ext/couchbase/operations/query_index_create.hxx +10 -8
  102. data/ext/couchbase/operations/query_index_drop.hxx +8 -8
  103. data/ext/couchbase/operations/query_index_get_all.hxx +43 -39
  104. data/ext/couchbase/operations/rbac.hxx +40 -63
  105. data/ext/couchbase/operations/role_get_all.hxx +6 -6
  106. data/ext/couchbase/operations/scope_create.hxx +10 -10
  107. data/ext/couchbase/operations/scope_drop.hxx +9 -9
  108. data/ext/couchbase/operations/scope_get_all.hxx +8 -8
  109. data/ext/couchbase/operations/search_get_stats.hxx +5 -3
  110. data/ext/couchbase/operations/search_index.hxx +6 -15
  111. data/ext/couchbase/operations/search_index_analyze_document.hxx +11 -11
  112. data/ext/couchbase/operations/search_index_control_ingest.hxx +9 -9
  113. data/ext/couchbase/operations/search_index_control_plan_freeze.hxx +9 -9
  114. data/ext/couchbase/operations/search_index_control_query.hxx +9 -9
  115. data/ext/couchbase/operations/search_index_drop.hxx +11 -9
  116. data/ext/couchbase/operations/search_index_get.hxx +11 -9
  117. data/ext/couchbase/operations/search_index_get_all.hxx +11 -11
  118. data/ext/couchbase/operations/search_index_get_documents_count.hxx +10 -10
  119. data/ext/couchbase/operations/search_index_get_stats.hxx +10 -8
  120. data/ext/couchbase/operations/search_index_upsert.hxx +12 -10
  121. data/ext/couchbase/operations/user_drop.hxx +5 -5
  122. data/ext/couchbase/operations/user_get.hxx +7 -7
  123. data/ext/couchbase/operations/user_get_all.hxx +6 -6
  124. data/ext/couchbase/operations/user_upsert.hxx +9 -9
  125. data/ext/couchbase/operations/view_index_drop.hxx +10 -10
  126. data/ext/couchbase/operations/view_index_get.hxx +13 -15
  127. data/ext/couchbase/operations/view_index_get_all.hxx +17 -20
  128. data/ext/couchbase/operations/view_index_upsert.hxx +9 -7
  129. data/ext/couchbase/operations.hxx +4 -0
  130. data/ext/couchbase/origin.hxx +14 -10
  131. data/ext/couchbase/platform/backtrace.c +1 -1
  132. data/ext/couchbase/platform/base64.cc +5 -5
  133. data/ext/couchbase/platform/base64.h +2 -5
  134. data/ext/couchbase/protocol/client_opcode.hxx +7 -4
  135. data/ext/couchbase/protocol/client_request.hxx +2 -2
  136. data/ext/couchbase/protocol/client_response.hxx +41 -16
  137. data/ext/couchbase/protocol/cmd_append.hxx +17 -16
  138. data/ext/couchbase/protocol/cmd_cluster_map_change_notification.hxx +4 -4
  139. data/ext/couchbase/protocol/cmd_decrement.hxx +10 -11
  140. data/ext/couchbase/protocol/cmd_exists.hxx +12 -15
  141. data/ext/couchbase/protocol/cmd_get.hxx +11 -14
  142. data/ext/couchbase/protocol/cmd_get_and_lock.hxx +10 -12
  143. data/ext/couchbase/protocol/cmd_get_and_touch.hxx +10 -12
  144. data/ext/couchbase/protocol/cmd_get_cluster_config.hxx +13 -18
  145. data/ext/couchbase/protocol/cmd_get_collection_id.hxx +12 -15
  146. data/ext/couchbase/protocol/cmd_get_collections_manifest.hxx +12 -16
  147. data/ext/couchbase/protocol/cmd_get_error_map.hxx +14 -17
  148. data/ext/couchbase/protocol/cmd_hello.hxx +8 -10
  149. data/ext/couchbase/protocol/cmd_increment.hxx +9 -10
  150. data/ext/couchbase/protocol/cmd_insert.hxx +9 -9
  151. data/ext/couchbase/protocol/cmd_lookup_in.hxx +12 -13
  152. data/ext/couchbase/protocol/cmd_mutate_in.hxx +11 -11
  153. data/ext/couchbase/protocol/cmd_noop.hxx +16 -20
  154. data/ext/couchbase/protocol/cmd_prepend.hxx +9 -10
  155. data/ext/couchbase/protocol/cmd_remove.hxx +10 -13
  156. data/ext/couchbase/protocol/cmd_replace.hxx +7 -7
  157. data/ext/couchbase/protocol/cmd_sasl_auth.hxx +8 -10
  158. data/ext/couchbase/protocol/cmd_sasl_list_mechs.hxx +10 -15
  159. data/ext/couchbase/protocol/cmd_sasl_step.hxx +10 -12
  160. data/ext/couchbase/protocol/cmd_select_bucket.hxx +14 -18
  161. data/ext/couchbase/protocol/cmd_touch.hxx +8 -11
  162. data/ext/couchbase/protocol/cmd_unlock.hxx +10 -14
  163. data/ext/couchbase/protocol/cmd_upsert.hxx +8 -8
  164. data/ext/couchbase/protocol/datatype.hxx +3 -3
  165. data/ext/couchbase/protocol/durability_level.hxx +2 -2
  166. data/ext/couchbase/protocol/frame_info_id.hxx +4 -4
  167. data/ext/couchbase/protocol/hello_feature.hxx +2 -2
  168. data/ext/couchbase/protocol/magic.hxx +2 -2
  169. data/ext/couchbase/protocol/server_opcode.hxx +2 -2
  170. data/ext/couchbase/protocol/server_request.hxx +1 -1
  171. data/ext/couchbase/protocol/status.hxx +4 -7
  172. data/ext/couchbase/protocol/unsigned_leb128.h +5 -20
  173. data/ext/couchbase/service_type.hxx +4 -4
  174. data/ext/couchbase/tracing/constants.hxx +261 -0
  175. data/ext/couchbase/tracing/noop_tracer.hxx +50 -0
  176. data/ext/couchbase/tracing/request_tracer.hxx +77 -0
  177. data/ext/couchbase/tracing/threshold_logging_options.hxx +64 -0
  178. data/ext/couchbase/tracing/threshold_logging_tracer.hxx +366 -0
  179. data/ext/couchbase/utils/byteswap.hxx +1 -1
  180. data/ext/couchbase/utils/connection_string.hxx +21 -1
  181. data/ext/couchbase/utils/name_codec.hxx +41 -0
  182. data/ext/couchbase/utils/url_codec.hxx +236 -0
  183. data/ext/couchbase/version.hxx +1 -1
  184. data/ext/test/CMakeLists.txt +1 -0
  185. data/ext/test/test_native_trivial_query.cxx +60 -0
  186. data/ext/third_party/hdr_histogram_c/CMakeLists.txt +84 -0
  187. data/ext/third_party/hdr_histogram_c/COPYING.txt +121 -0
  188. data/ext/third_party/hdr_histogram_c/LICENSE.txt +41 -0
  189. data/ext/third_party/hdr_histogram_c/config.cmake.in +6 -0
  190. data/ext/third_party/hdr_histogram_c/src/CMakeLists.txt +83 -0
  191. data/ext/third_party/hdr_histogram_c/src/hdr_atomic.h +146 -0
  192. data/ext/third_party/hdr_histogram_c/src/hdr_encoding.c +322 -0
  193. data/ext/third_party/hdr_histogram_c/src/hdr_encoding.h +79 -0
  194. data/ext/third_party/hdr_histogram_c/src/hdr_endian.h +116 -0
  195. data/ext/third_party/hdr_histogram_c/src/hdr_histogram.c +1196 -0
  196. data/ext/third_party/hdr_histogram_c/src/hdr_histogram.h +516 -0
  197. data/ext/third_party/hdr_histogram_c/src/hdr_histogram_log.c +1290 -0
  198. data/ext/third_party/hdr_histogram_c/src/hdr_histogram_log.h +236 -0
  199. data/ext/third_party/hdr_histogram_c/src/hdr_histogram_log_no_op.c +171 -0
  200. data/ext/third_party/hdr_histogram_c/src/hdr_interval_recorder.c +227 -0
  201. data/ext/third_party/hdr_histogram_c/src/hdr_interval_recorder.h +109 -0
  202. data/ext/third_party/hdr_histogram_c/src/hdr_malloc.h +19 -0
  203. data/ext/third_party/hdr_histogram_c/src/hdr_tests.h +22 -0
  204. data/ext/third_party/hdr_histogram_c/src/hdr_thread.c +108 -0
  205. data/ext/third_party/hdr_histogram_c/src/hdr_thread.h +55 -0
  206. data/ext/third_party/hdr_histogram_c/src/hdr_time.c +98 -0
  207. data/ext/third_party/hdr_histogram_c/src/hdr_time.h +49 -0
  208. data/ext/third_party/hdr_histogram_c/src/hdr_writer_reader_phaser.c +143 -0
  209. data/ext/third_party/hdr_histogram_c/src/hdr_writer_reader_phaser.h +51 -0
  210. data/lib/couchbase/cluster.rb +1 -0
  211. data/lib/couchbase/errors.rb +3 -0
  212. data/lib/couchbase/management/analytics_index_manager.rb +920 -226
  213. data/lib/couchbase/management/bucket_manager.rb +207 -69
  214. data/lib/couchbase/management/collection_manager.rb +173 -61
  215. data/lib/couchbase/management/query_index_manager.rb +357 -169
  216. data/lib/couchbase/options.rb +75 -3
  217. data/lib/couchbase/scope.rb +102 -0
  218. data/lib/couchbase/utils/time.rb +4 -0
  219. data/lib/couchbase/version.rb +6 -6
  220. metadata +50 -7
@@ -152,10 +152,10 @@ enum class hello_feature : uint16_t {
152
152
  subdoc_document_macro_support = 0x18,
153
153
  };
154
154
 
155
- constexpr inline bool
155
+ constexpr bool
156
156
  is_valid_hello_feature(uint16_t code)
157
157
  {
158
- switch (static_cast<hello_feature>(code)) {
158
+ switch (hello_feature(code)) {
159
159
  case hello_feature::tls:
160
160
  case hello_feature::tcp_nodelay:
161
161
  case hello_feature::mutation_seqno:
@@ -36,10 +36,10 @@ enum class magic : uint8_t {
36
36
  server_response = 0x83
37
37
  };
38
38
 
39
- constexpr inline bool
39
+ constexpr bool
40
40
  is_valid_magic(uint8_t code)
41
41
  {
42
- switch (static_cast<magic>(code)) {
42
+ switch (magic(code)) {
43
43
  case magic::client_request:
44
44
  case magic::alt_client_request:
45
45
  case magic::client_response:
@@ -24,10 +24,10 @@ enum class server_opcode : uint8_t {
24
24
  invalid = 0xff,
25
25
  };
26
26
 
27
- constexpr inline bool
27
+ constexpr bool
28
28
  is_valid_server_request_opcode(uint8_t code)
29
29
  {
30
- switch (static_cast<server_opcode>(code)) {
30
+ switch (server_opcode(code)) {
31
31
  case server_opcode::cluster_map_change_notification:
32
32
  return true;
33
33
  case server_opcode::invalid:
@@ -96,7 +96,7 @@ class server_request
96
96
  {
97
97
  Expects(header_[0] == static_cast<std::uint8_t>(magic_));
98
98
  Expects(header_[1] == static_cast<std::uint8_t>(Body::opcode));
99
- opcode_ = static_cast<server_opcode>(header_[1]);
99
+ opcode_ = server_opcode(header_[1]);
100
100
  data_type_ = header_[5];
101
101
 
102
102
  uint32_t field = 0;
@@ -17,9 +17,7 @@
17
17
 
18
18
  #pragma once
19
19
 
20
- namespace couchbase
21
- {
22
- namespace protocol
20
+ namespace couchbase::protocol
23
21
  {
24
22
  enum class status : uint16_t {
25
23
  success = 0x00,
@@ -81,10 +79,10 @@ enum class status : uint16_t {
81
79
  subdoc_invalid_xattr_order = 0xd4,
82
80
  };
83
81
 
84
- constexpr inline bool
82
+ constexpr bool
85
83
  is_valid_status(uint16_t code)
86
84
  {
87
- switch (static_cast<status>(code)) {
85
+ switch (status(code)) {
88
86
  case status::success:
89
87
  case status::not_found:
90
88
  case status::exists:
@@ -156,8 +154,7 @@ status_to_string(uint16_t code)
156
154
  return fmt::format("{} (unknown)", code);
157
155
  }
158
156
 
159
- } // namespace protocol
160
- } // namespace couchbase
157
+ } // namespace couchbase::protocol
161
158
 
162
159
  template<>
163
160
  struct fmt::formatter<couchbase::protocol::status> : formatter<string_view> {
@@ -46,8 +46,8 @@ struct Leb128NoThrow {
46
46
  * leb128 data.
47
47
  */
48
48
  template<class T>
49
- typename std::enable_if<std::is_unsigned<T>::value, std::pair<T, std::string_view>>::type
50
- decode_unsigned_leb128(std::string_view buf, struct Leb128NoThrow)
49
+ typename std::enable_if_t<std::is_unsigned_v<T>, std::pair<T, std::string_view>>
50
+ decode_unsigned_leb128(std::string_view buf, struct Leb128NoThrow /* unused */)
51
51
  {
52
52
  T rv = static_cast<uint8_t>(buf[0]) & 0x7fULL;
53
53
  size_t end = 0;
@@ -83,7 +83,7 @@ decode_unsigned_leb128(std::string_view buf, struct Leb128NoThrow)
83
83
  * a stop byte.
84
84
  */
85
85
  template<class T>
86
- typename std::enable_if<std::is_unsigned<T>::value, std::pair<T, std::string_view>>::type
86
+ typename std::enable_if_t<std::is_unsigned_v<T>, std::pair<T, std::string_view>>
87
87
  decode_unsigned_leb128(std::string_view buf)
88
88
  {
89
89
  if (buf.size() > 0) {
@@ -99,27 +99,12 @@ decode_unsigned_leb128(std::string_view buf)
99
99
  * @return a buffer to the data after the leb128 prefix
100
100
  */
101
101
  template<class T>
102
- typename std::enable_if<std::is_unsigned<T>::value, std::string_view>::type
102
+ typename std::enable_if_t<std::is_unsigned_v<T>, std::string_view>
103
103
  skip_unsigned_leb128(std::string_view buf)
104
104
  {
105
105
  return decode_unsigned_leb128<T>(buf).second;
106
106
  }
107
107
 
108
- /// @return the index of the stop byte within buf
109
- static inline std::optional<size_t>
110
- unsigned_leb128_get_stop_byte_index(std::string_view buf)
111
- {
112
- // If buf does not contain a stop-byte, invalid
113
- size_t stopByte = 0;
114
- for (auto c : buf) {
115
- if ((static_cast<uint8_t>(c) & 0x80ULL) == 0) {
116
- return stopByte;
117
- }
118
- stopByte++;
119
- }
120
- return {};
121
- }
122
-
123
108
  // Empty, non specialised version of the decoder class
124
109
  template<class T, class Enable = void>
125
110
  class unsigned_leb128
@@ -131,7 +116,7 @@ class unsigned_leb128
131
116
  * provides a const_byte_buffer for access to the encoded
132
117
  */
133
118
  template<class T>
134
- class unsigned_leb128<T, typename std::enable_if<std::is_unsigned<T>::value>::type>
119
+ class unsigned_leb128<T, typename std::enable_if_t<std::is_unsigned_v<T>>>
135
120
  {
136
121
  public:
137
122
  explicit unsigned_leb128(T in)
@@ -20,11 +20,11 @@
20
20
  namespace couchbase
21
21
  {
22
22
  enum class service_type {
23
- kv,
23
+ key_value = 0,
24
24
  query,
25
25
  analytics,
26
26
  search,
27
- views,
27
+ view,
28
28
  management,
29
29
  };
30
30
  } // namespace couchbase
@@ -36,7 +36,7 @@ struct fmt::formatter<couchbase::service_type> : formatter<std::string_view> {
36
36
  {
37
37
  string_view name = "unknown";
38
38
  switch (type) {
39
- case couchbase::service_type::kv:
39
+ case couchbase::service_type::key_value:
40
40
  name = "kv";
41
41
  break;
42
42
  case couchbase::service_type::query:
@@ -48,7 +48,7 @@ struct fmt::formatter<couchbase::service_type> : formatter<std::string_view> {
48
48
  case couchbase::service_type::search:
49
49
  name = "search";
50
50
  break;
51
- case couchbase::service_type::views:
51
+ case couchbase::service_type::view:
52
52
  name = "views";
53
53
  break;
54
54
  case couchbase::service_type::management:
@@ -0,0 +1,261 @@
1
+ /* -*- Mode: C++; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */
2
+ /*
3
+ * Copyright 2020-2021 Couchbase, Inc.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+
18
+ #pragma once
19
+
20
+ #include <string_view>
21
+
22
+ #include <protocol/client_opcode.hxx>
23
+ #include <service_type.hxx>
24
+
25
+ namespace couchbase::tracing
26
+ {
27
+ namespace operation
28
+ {
29
+ constexpr auto step_dispatch = "cb.dispatch_to_server";
30
+ constexpr auto step_request_encoding = "cb.request_encoding";
31
+ constexpr auto http_query = "cb.query";
32
+ constexpr auto http_analytics = "cb.analytics";
33
+ constexpr auto http_search = "cb.search";
34
+ constexpr auto http_views = "cb.views";
35
+ constexpr auto http_manager = "cb.manager";
36
+ constexpr auto http_manager_analytics = "cb.manager_analytics";
37
+ constexpr auto http_manager_query = "cb.manager_query";
38
+ constexpr auto http_manager_buckets = "cb.manager_buckets";
39
+ constexpr auto http_manager_collections = "cb.manager_collections";
40
+ constexpr auto http_manager_search = "cb.manager_search";
41
+ constexpr auto http_manager_users = "cb.manager_users";
42
+ constexpr auto http_manager_views = "cb.manager_views";
43
+ constexpr auto mcbp_get = "cb.get";
44
+ constexpr auto mcbp_get_replica = "cb.get_replica";
45
+ constexpr auto mcbp_upsert = "cb.upsert";
46
+ constexpr auto mcbp_replace = "cb.replace";
47
+ constexpr auto mcbp_insert = "cb.insert";
48
+ constexpr auto mcbp_remove = "cb.remove";
49
+ constexpr auto mcbp_get_and_lock = "cb.get_and_lock";
50
+ constexpr auto mcbp_get_and_touch = "cb.get_and_touch";
51
+ constexpr auto mcbp_exists = "cb.exists";
52
+ constexpr auto mcbp_touch = "cb.touch";
53
+ constexpr auto mcbp_unlock = "cb.unlock";
54
+ constexpr auto mcbp_lookup_in = "cb.lookup_in";
55
+ constexpr auto mcbp_mutate_in = "cb.mutate_in";
56
+ constexpr auto mcbp_append = "cb.append";
57
+ constexpr auto mcbp_prepend = "cb.prepend";
58
+ constexpr auto mcbp_increment = "cb.increment";
59
+ constexpr auto mcbp_decrement = "cb.decrement";
60
+ constexpr auto mcbp_observe = "cb.observe";
61
+ /* multi-command operations */
62
+ constexpr auto mcbp_get_all_replicas = "cb.get_all_replicas";
63
+ constexpr auto mcbp_get_any_replica = "cb.get_any_replica";
64
+ constexpr auto mcbp_list = "cb.list";
65
+ constexpr auto mcbp_set = "cb.set";
66
+ constexpr auto mcbp_map = "cb.map";
67
+ constexpr auto mcbp_queue = "cb.queue";
68
+ constexpr auto mcbp_ping = "cb.ping";
69
+ } // namespace operation
70
+
71
+ namespace attributes
72
+ {
73
+ constexpr auto system = "db.system";
74
+ constexpr auto span_kind = "span.kind";
75
+ constexpr auto component = "db.couchbase.component";
76
+ constexpr auto instance = "db.instance";
77
+
78
+ constexpr auto orphan = "cb.orphan";
79
+ constexpr auto service = "cb.service";
80
+ constexpr auto operation_id = "cb.operation_id";
81
+
82
+ constexpr auto server_duration = "cb.server_duration";
83
+ constexpr auto local_id = "cb.local_id";
84
+ constexpr auto local_socket = "cb.local_socket";
85
+ constexpr auto remote_socket = "cb.remote_socket";
86
+ } // namespace attributes
87
+
88
+ namespace service
89
+ {
90
+ constexpr auto key_value = "kv";
91
+ constexpr auto query = "query";
92
+ constexpr auto search = "search";
93
+ constexpr auto view = "views";
94
+ constexpr auto analytics = "analytics";
95
+ constexpr auto management = "management";
96
+ } // namespace service
97
+
98
+ auto
99
+ span_name_for_http_service(service_type type)
100
+ {
101
+ switch (type) {
102
+ case service_type::query:
103
+ return operation::http_query;
104
+
105
+ case service_type::analytics:
106
+ return operation::http_analytics;
107
+
108
+ case service_type::search:
109
+ return operation::http_search;
110
+
111
+ case service_type::view:
112
+ return operation::http_views;
113
+
114
+ case service_type::management:
115
+ return operation::http_manager;
116
+
117
+ case service_type::key_value:
118
+ Expects(false);
119
+ }
120
+ Expects(false);
121
+ }
122
+
123
+ auto
124
+ service_name_for_http_service(service_type type)
125
+ {
126
+ switch (type) {
127
+ case service_type::query:
128
+ return service::query;
129
+
130
+ case service_type::analytics:
131
+ return service::analytics;
132
+
133
+ case service_type::search:
134
+ return service::search;
135
+
136
+ case service_type::view:
137
+ return service::view;
138
+
139
+ case service_type::management:
140
+ return service::management;
141
+
142
+ case service_type::key_value:
143
+ Expects(false);
144
+ }
145
+ Expects(false);
146
+ }
147
+
148
+ auto
149
+ span_name_for_mcbp_command(protocol::client_opcode opcode)
150
+ {
151
+ switch (opcode) {
152
+ case protocol::client_opcode::get:
153
+ return operation::mcbp_get;
154
+
155
+ case protocol::client_opcode::upsert:
156
+ return operation::mcbp_upsert;
157
+
158
+ case protocol::client_opcode::insert:
159
+ return operation::mcbp_insert;
160
+
161
+ case protocol::client_opcode::replace:
162
+ return operation::mcbp_replace;
163
+
164
+ case protocol::client_opcode::remove:
165
+ return operation::mcbp_remove;
166
+
167
+ case protocol::client_opcode::increment:
168
+ return operation::mcbp_increment;
169
+
170
+ case protocol::client_opcode::decrement:
171
+ return operation::mcbp_decrement;
172
+
173
+ case protocol::client_opcode::append:
174
+ return operation::mcbp_append;
175
+
176
+ case protocol::client_opcode::prepend:
177
+ return operation::mcbp_prepend;
178
+
179
+ case protocol::client_opcode::touch:
180
+ return operation::mcbp_touch;
181
+
182
+ case protocol::client_opcode::get_and_touch:
183
+ return operation::mcbp_get_and_touch;
184
+
185
+ case protocol::client_opcode::get_replica:
186
+ return operation::mcbp_get_replica;
187
+
188
+ case protocol::client_opcode::get_and_lock:
189
+ return operation::mcbp_get_and_lock;
190
+
191
+ case protocol::client_opcode::unlock:
192
+ return operation::mcbp_unlock;
193
+
194
+ case protocol::client_opcode::subdoc_multi_lookup:
195
+ return operation::mcbp_lookup_in;
196
+
197
+ case protocol::client_opcode::subdoc_multi_mutation:
198
+ return operation::mcbp_mutate_in;
199
+
200
+ case protocol::client_opcode::observe:
201
+ return operation::mcbp_exists;
202
+
203
+ case protocol::client_opcode::noop:
204
+ case protocol::client_opcode::version:
205
+ case protocol::client_opcode::stat:
206
+ case protocol::client_opcode::verbosity:
207
+ case protocol::client_opcode::hello:
208
+ case protocol::client_opcode::sasl_list_mechs:
209
+ case protocol::client_opcode::sasl_auth:
210
+ case protocol::client_opcode::sasl_step:
211
+ case protocol::client_opcode::get_all_vbucket_seqnos:
212
+ case protocol::client_opcode::dcp_open:
213
+ case protocol::client_opcode::dcp_add_stream:
214
+ case protocol::client_opcode::dcp_close_stream:
215
+ case protocol::client_opcode::dcp_stream_request:
216
+ case protocol::client_opcode::dcp_get_failover_log:
217
+ case protocol::client_opcode::dcp_stream_end:
218
+ case protocol::client_opcode::dcp_snapshot_marker:
219
+ case protocol::client_opcode::dcp_mutation:
220
+ case protocol::client_opcode::dcp_deletion:
221
+ case protocol::client_opcode::dcp_expiration:
222
+ case protocol::client_opcode::dcp_set_vbucket_state:
223
+ case protocol::client_opcode::dcp_noop:
224
+ case protocol::client_opcode::dcp_buffer_acknowledgement:
225
+ case protocol::client_opcode::dcp_control:
226
+ case protocol::client_opcode::dcp_system_event:
227
+ case protocol::client_opcode::dcp_prepare:
228
+ case protocol::client_opcode::dcp_seqno_acknowledged:
229
+ case protocol::client_opcode::dcp_commit:
230
+ case protocol::client_opcode::dcp_abort:
231
+ case protocol::client_opcode::dcp_seqno_advanced:
232
+ case protocol::client_opcode::dcp_oso_snapshot:
233
+ case protocol::client_opcode::list_buckets:
234
+ case protocol::client_opcode::select_bucket:
235
+ case protocol::client_opcode::observe_seqno:
236
+ case protocol::client_opcode::evict_key:
237
+ case protocol::client_opcode::get_failover_log:
238
+ case protocol::client_opcode::last_closed_checkpoint:
239
+ case protocol::client_opcode::get_meta:
240
+ case protocol::client_opcode::upsert_with_meta:
241
+ case protocol::client_opcode::insert_with_meta:
242
+ case protocol::client_opcode::remove_with_meta:
243
+ case protocol::client_opcode::create_checkpoint:
244
+ case protocol::client_opcode::checkpoint_persistence:
245
+ case protocol::client_opcode::return_meta:
246
+ case protocol::client_opcode::get_random_key:
247
+ case protocol::client_opcode::seqno_persistence:
248
+ case protocol::client_opcode::get_keys:
249
+ case protocol::client_opcode::set_collections_manifest:
250
+ case protocol::client_opcode::get_collections_manifest:
251
+ case protocol::client_opcode::get_collection_id:
252
+ case protocol::client_opcode::get_scope_id:
253
+ case protocol::client_opcode::get_cluster_config:
254
+ case protocol::client_opcode::get_error_map:
255
+ case protocol::client_opcode::invalid:
256
+ Expects(false);
257
+ }
258
+ Expects(false);
259
+ }
260
+
261
+ } // namespace couchbase::tracing
@@ -0,0 +1,50 @@
1
+ /* -*- Mode: C++; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */
2
+ /*
3
+ * Copyright 2021 Couchbase, Inc.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+
18
+ #pragma once
19
+
20
+ #include "request_tracer.hxx"
21
+
22
+ namespace couchbase::tracing
23
+ {
24
+
25
+ class noop_span : public request_span
26
+ {
27
+ void add_tag(const std::string& /* name */, std::uint64_t /* value */) override
28
+ {
29
+ }
30
+
31
+ void add_tag(const std::string& /* name */, const std::string& /* value */) override
32
+ {
33
+ }
34
+
35
+ void end() override
36
+ {
37
+ }
38
+ };
39
+
40
+ class noop_tracer : public request_tracer
41
+ {
42
+ public:
43
+ request_span* start_span(std::string /* name */, request_span* /* parent */) override
44
+ {
45
+ static noop_span instance{};
46
+ return &instance;
47
+ }
48
+ };
49
+
50
+ } // namespace couchbase::tracing