couchbase 4.6.1 → 4.7.0-dev.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 (312) hide show
  1. package/CMakeLists.txt +2 -1
  2. package/deps/couchbase-cxx-cache/mozilla-ca-bundle.crt +23 -5
  3. package/deps/couchbase-cxx-cache/mozilla-ca-bundle.sha256 +1 -1
  4. package/deps/couchbase-cxx-client/CMakeLists.txt +24 -11
  5. package/deps/couchbase-cxx-client/README.md +2 -2
  6. package/deps/couchbase-cxx-client/cmake/APKBUILD.in +17 -1
  7. package/deps/couchbase-cxx-client/cmake/Bundler.cmake +9 -1
  8. package/deps/couchbase-cxx-client/cmake/Cache.cmake +48 -19
  9. package/deps/couchbase-cxx-client/cmake/CompilerOptions.cmake +3 -1
  10. package/deps/couchbase-cxx-client/cmake/OpenSSL.cmake +10 -2
  11. package/deps/couchbase-cxx-client/cmake/Packaging.cmake +48 -8
  12. package/deps/couchbase-cxx-client/cmake/ThirdPartyDependencies.cmake +41 -0
  13. package/deps/couchbase-cxx-client/cmake/build_config.hxx.in +2 -0
  14. package/deps/couchbase-cxx-client/cmake/couchbase-cxx-client.spec.in +18 -0
  15. package/deps/couchbase-cxx-client/cmake/debian/control +6 -1
  16. package/deps/couchbase-cxx-client/cmake/debian/rules +1 -0
  17. package/deps/couchbase-cxx-client/cmake/tarball_glob.txt +10 -0
  18. package/deps/couchbase-cxx-client/core/app_telemetry_meter.cxx +1 -0
  19. package/deps/couchbase-cxx-client/core/app_telemetry_reporter.cxx +45 -43
  20. package/deps/couchbase-cxx-client/core/app_telemetry_reporter.hxx +4 -3
  21. package/deps/couchbase-cxx-client/core/bucket.cxx +128 -13
  22. package/deps/couchbase-cxx-client/core/bucket.hxx +12 -2
  23. package/deps/couchbase-cxx-client/core/cluster.cxx +304 -152
  24. package/deps/couchbase-cxx-client/core/cluster.hxx +32 -0
  25. package/deps/couchbase-cxx-client/core/cluster_credentials.cxx +25 -0
  26. package/deps/couchbase-cxx-client/core/cluster_credentials.hxx +5 -0
  27. package/deps/couchbase-cxx-client/core/cluster_label_listener.cxx +72 -0
  28. package/deps/couchbase-cxx-client/core/cluster_label_listener.hxx +46 -0
  29. package/deps/couchbase-cxx-client/core/cluster_options.hxx +4 -0
  30. package/deps/couchbase-cxx-client/core/deprecation_utils.hxx +26 -0
  31. package/deps/couchbase-cxx-client/core/error.hxx +27 -0
  32. package/deps/couchbase-cxx-client/core/free_form_http_request.hxx +0 -2
  33. package/deps/couchbase-cxx-client/core/http_component.cxx +12 -48
  34. package/deps/couchbase-cxx-client/core/impl/analytics.cxx +3 -2
  35. package/deps/couchbase-cxx-client/core/impl/analytics.hxx +2 -1
  36. package/deps/couchbase-cxx-client/core/impl/analytics_index_manager.cxx +249 -137
  37. package/deps/couchbase-cxx-client/core/impl/binary_collection.cxx +134 -58
  38. package/deps/couchbase-cxx-client/core/impl/bucket_manager.cxx +87 -35
  39. package/deps/couchbase-cxx-client/core/impl/collection.cxx +560 -245
  40. package/deps/couchbase-cxx-client/core/impl/collection_manager.cxx +89 -49
  41. package/deps/couchbase-cxx-client/core/impl/dns_srv_tracker.cxx +3 -3
  42. package/deps/couchbase-cxx-client/core/impl/error.cxx +20 -13
  43. package/deps/couchbase-cxx-client/core/impl/error.hxx +15 -10
  44. package/deps/couchbase-cxx-client/core/impl/get_all_replicas.hxx +1 -1
  45. package/deps/couchbase-cxx-client/core/impl/get_any_replica.hxx +2 -1
  46. package/deps/couchbase-cxx-client/core/impl/get_replica.hxx +2 -0
  47. package/deps/couchbase-cxx-client/core/impl/lookup_in_replica.hxx +1 -1
  48. package/deps/couchbase-cxx-client/core/impl/observability_recorder.cxx +161 -0
  49. package/deps/couchbase-cxx-client/core/impl/observability_recorder.hxx +77 -0
  50. package/deps/couchbase-cxx-client/core/impl/observe_seqno.hxx +2 -0
  51. package/deps/couchbase-cxx-client/core/impl/public_bucket.cxx +31 -7
  52. package/deps/couchbase-cxx-client/core/impl/public_cluster.cxx +107 -19
  53. package/deps/couchbase-cxx-client/core/impl/query.cxx +6 -3
  54. package/deps/couchbase-cxx-client/core/impl/query.hxx +3 -1
  55. package/deps/couchbase-cxx-client/core/impl/query_index_manager.cxx +267 -102
  56. package/deps/couchbase-cxx-client/core/impl/scope.cxx +53 -11
  57. package/deps/couchbase-cxx-client/core/impl/search.cxx +8 -4
  58. package/deps/couchbase-cxx-client/core/impl/search.hxx +6 -2
  59. package/deps/couchbase-cxx-client/core/impl/search_index_manager.cxx +131 -41
  60. package/deps/couchbase-cxx-client/core/impl/with_cancellation.hxx +75 -0
  61. package/deps/couchbase-cxx-client/core/io/config_tracker.cxx +9 -9
  62. package/deps/couchbase-cxx-client/core/io/config_tracker.hxx +2 -1
  63. package/deps/couchbase-cxx-client/core/io/http_command.hxx +98 -49
  64. package/deps/couchbase-cxx-client/core/io/http_context.hxx +2 -0
  65. package/deps/couchbase-cxx-client/core/io/http_session.cxx +23 -10
  66. package/deps/couchbase-cxx-client/core/io/http_session.hxx +17 -9
  67. package/deps/couchbase-cxx-client/core/io/http_session_manager.hxx +163 -228
  68. package/deps/couchbase-cxx-client/core/io/http_traits.hxx +0 -7
  69. package/deps/couchbase-cxx-client/core/io/mcbp_command.hxx +123 -44
  70. package/deps/couchbase-cxx-client/core/io/mcbp_session.cxx +251 -26
  71. package/deps/couchbase-cxx-client/core/io/mcbp_session.hxx +9 -1
  72. package/deps/couchbase-cxx-client/core/io/mcbp_traits.hxx +0 -8
  73. package/deps/couchbase-cxx-client/core/io/streams.cxx +3 -3
  74. package/deps/couchbase-cxx-client/core/io/streams.hxx +3 -2
  75. package/deps/couchbase-cxx-client/core/meta/features.hxx +15 -0
  76. package/deps/couchbase-cxx-client/core/meta/version.cxx +13 -0
  77. package/deps/couchbase-cxx-client/core/meta/version.hxx +3 -0
  78. package/deps/couchbase-cxx-client/core/metrics/constants.hxx +23 -0
  79. package/deps/couchbase-cxx-client/core/metrics/logging_meter.cxx +5 -5
  80. package/deps/couchbase-cxx-client/core/metrics/meter_wrapper.cxx +65 -63
  81. package/deps/couchbase-cxx-client/core/metrics/meter_wrapper.hxx +12 -10
  82. package/deps/couchbase-cxx-client/core/operations/document_analytics.hxx +0 -5
  83. package/deps/couchbase-cxx-client/core/operations/document_append.hxx +0 -4
  84. package/deps/couchbase-cxx-client/core/operations/document_decrement.hxx +0 -5
  85. package/deps/couchbase-cxx-client/core/operations/document_exists.hxx +0 -7
  86. package/deps/couchbase-cxx-client/core/operations/document_get.hxx +0 -7
  87. package/deps/couchbase-cxx-client/core/operations/document_get_all_replicas.hxx +77 -27
  88. package/deps/couchbase-cxx-client/core/operations/document_get_and_lock.hxx +0 -9
  89. package/deps/couchbase-cxx-client/core/operations/document_get_and_touch.hxx +0 -9
  90. package/deps/couchbase-cxx-client/core/operations/document_get_any_replica.hxx +83 -2
  91. package/deps/couchbase-cxx-client/core/operations/document_get_projected.hxx +0 -9
  92. package/deps/couchbase-cxx-client/core/operations/document_increment.hxx +0 -5
  93. package/deps/couchbase-cxx-client/core/operations/document_insert.hxx +0 -4
  94. package/deps/couchbase-cxx-client/core/operations/document_lookup_in.hxx +0 -9
  95. package/deps/couchbase-cxx-client/core/operations/document_lookup_in_all_replicas.hxx +46 -4
  96. package/deps/couchbase-cxx-client/core/operations/document_lookup_in_any_replica.hxx +121 -43
  97. package/deps/couchbase-cxx-client/core/operations/document_mutate_in.hxx +0 -5
  98. package/deps/couchbase-cxx-client/core/operations/document_prepend.hxx +0 -4
  99. package/deps/couchbase-cxx-client/core/operations/document_query.hxx +0 -4
  100. package/deps/couchbase-cxx-client/core/operations/document_remove.hxx +0 -4
  101. package/deps/couchbase-cxx-client/core/operations/document_replace.hxx +0 -4
  102. package/deps/couchbase-cxx-client/core/operations/document_search.hxx +0 -7
  103. package/deps/couchbase-cxx-client/core/operations/document_touch.hxx +0 -7
  104. package/deps/couchbase-cxx-client/core/operations/document_unlock.hxx +0 -6
  105. package/deps/couchbase-cxx-client/core/operations/document_upsert.hxx +0 -4
  106. package/deps/couchbase-cxx-client/core/operations/document_view.cxx +2 -0
  107. package/deps/couchbase-cxx-client/core/operations/document_view.hxx +10 -13
  108. package/deps/couchbase-cxx-client/core/operations/http_noop.hxx +2 -0
  109. package/deps/couchbase-cxx-client/core/operations/management/analytics_dataset_create.hxx +2 -0
  110. package/deps/couchbase-cxx-client/core/operations/management/analytics_dataset_drop.hxx +2 -0
  111. package/deps/couchbase-cxx-client/core/operations/management/analytics_dataset_get_all.hxx +2 -0
  112. package/deps/couchbase-cxx-client/core/operations/management/analytics_dataverse_create.hxx +2 -0
  113. package/deps/couchbase-cxx-client/core/operations/management/analytics_dataverse_drop.hxx +2 -0
  114. package/deps/couchbase-cxx-client/core/operations/management/analytics_get_pending_mutations.hxx +2 -0
  115. package/deps/couchbase-cxx-client/core/operations/management/analytics_index_create.hxx +2 -0
  116. package/deps/couchbase-cxx-client/core/operations/management/analytics_index_drop.hxx +2 -0
  117. package/deps/couchbase-cxx-client/core/operations/management/analytics_index_get_all.hxx +2 -0
  118. package/deps/couchbase-cxx-client/core/operations/management/analytics_link_connect.hxx +2 -0
  119. package/deps/couchbase-cxx-client/core/operations/management/analytics_link_create.hxx +2 -0
  120. package/deps/couchbase-cxx-client/core/operations/management/analytics_link_disconnect.hxx +2 -0
  121. package/deps/couchbase-cxx-client/core/operations/management/analytics_link_drop.hxx +2 -0
  122. package/deps/couchbase-cxx-client/core/operations/management/analytics_link_get_all.hxx +2 -0
  123. package/deps/couchbase-cxx-client/core/operations/management/analytics_link_replace.hxx +2 -0
  124. package/deps/couchbase-cxx-client/core/operations/management/bucket_create.hxx +2 -0
  125. package/deps/couchbase-cxx-client/core/operations/management/bucket_describe.hxx +2 -0
  126. package/deps/couchbase-cxx-client/core/operations/management/bucket_drop.hxx +2 -0
  127. package/deps/couchbase-cxx-client/core/operations/management/bucket_flush.hxx +2 -0
  128. package/deps/couchbase-cxx-client/core/operations/management/bucket_get.hxx +2 -0
  129. package/deps/couchbase-cxx-client/core/operations/management/bucket_get_all.hxx +2 -0
  130. package/deps/couchbase-cxx-client/core/operations/management/bucket_update.hxx +2 -0
  131. package/deps/couchbase-cxx-client/core/operations/management/change_password.hxx +2 -0
  132. package/deps/couchbase-cxx-client/core/operations/management/cluster_describe.hxx +2 -0
  133. package/deps/couchbase-cxx-client/core/operations/management/cluster_developer_preview_enable.hxx +2 -0
  134. package/deps/couchbase-cxx-client/core/operations/management/collection_create.hxx +2 -0
  135. package/deps/couchbase-cxx-client/core/operations/management/collection_drop.hxx +2 -0
  136. package/deps/couchbase-cxx-client/core/operations/management/collection_update.hxx +2 -0
  137. package/deps/couchbase-cxx-client/core/operations/management/collections_manifest_get.hxx +2 -0
  138. package/deps/couchbase-cxx-client/core/operations/management/error_utils.cxx +4 -1
  139. package/deps/couchbase-cxx-client/core/operations/management/eventing_deploy_function.hxx +2 -0
  140. package/deps/couchbase-cxx-client/core/operations/management/eventing_drop_function.hxx +2 -0
  141. package/deps/couchbase-cxx-client/core/operations/management/eventing_get_all_functions.hxx +2 -0
  142. package/deps/couchbase-cxx-client/core/operations/management/eventing_get_function.hxx +2 -0
  143. package/deps/couchbase-cxx-client/core/operations/management/eventing_get_status.hxx +2 -0
  144. package/deps/couchbase-cxx-client/core/operations/management/eventing_pause_function.hxx +2 -0
  145. package/deps/couchbase-cxx-client/core/operations/management/eventing_resume_function.hxx +2 -0
  146. package/deps/couchbase-cxx-client/core/operations/management/eventing_undeploy_function.hxx +2 -0
  147. package/deps/couchbase-cxx-client/core/operations/management/eventing_upsert_function.hxx +2 -0
  148. package/deps/couchbase-cxx-client/core/operations/management/freeform.hxx +2 -0
  149. package/deps/couchbase-cxx-client/core/operations/management/group_drop.hxx +2 -0
  150. package/deps/couchbase-cxx-client/core/operations/management/group_get.hxx +2 -0
  151. package/deps/couchbase-cxx-client/core/operations/management/group_get_all.hxx +2 -0
  152. package/deps/couchbase-cxx-client/core/operations/management/group_upsert.hxx +2 -0
  153. package/deps/couchbase-cxx-client/core/operations/management/query_index_build.hxx +2 -0
  154. package/deps/couchbase-cxx-client/core/operations/management/query_index_build_deferred.hxx +68 -30
  155. package/deps/couchbase-cxx-client/core/operations/management/query_index_create.hxx +2 -0
  156. package/deps/couchbase-cxx-client/core/operations/management/query_index_drop.hxx +2 -0
  157. package/deps/couchbase-cxx-client/core/operations/management/query_index_get_all.hxx +4 -3
  158. package/deps/couchbase-cxx-client/core/operations/management/query_index_get_all_deferred.hxx +2 -1
  159. package/deps/couchbase-cxx-client/core/operations/management/role_get_all.hxx +2 -0
  160. package/deps/couchbase-cxx-client/core/operations/management/scope_create.hxx +2 -0
  161. package/deps/couchbase-cxx-client/core/operations/management/scope_drop.hxx +2 -0
  162. package/deps/couchbase-cxx-client/core/operations/management/scope_get_all.hxx +2 -0
  163. package/deps/couchbase-cxx-client/core/operations/management/search_get_stats.hxx +2 -0
  164. package/deps/couchbase-cxx-client/core/operations/management/search_index_analyze_document.hxx +2 -0
  165. package/deps/couchbase-cxx-client/core/operations/management/search_index_control_ingest.hxx +2 -0
  166. package/deps/couchbase-cxx-client/core/operations/management/search_index_control_plan_freeze.hxx +2 -0
  167. package/deps/couchbase-cxx-client/core/operations/management/search_index_control_query.hxx +2 -0
  168. package/deps/couchbase-cxx-client/core/operations/management/search_index_drop.hxx +2 -0
  169. package/deps/couchbase-cxx-client/core/operations/management/search_index_get.hxx +2 -0
  170. package/deps/couchbase-cxx-client/core/operations/management/search_index_get_all.hxx +2 -0
  171. package/deps/couchbase-cxx-client/core/operations/management/search_index_get_documents_count.hxx +2 -0
  172. package/deps/couchbase-cxx-client/core/operations/management/search_index_get_stats.hxx +2 -0
  173. package/deps/couchbase-cxx-client/core/operations/management/search_index_upsert.hxx +2 -0
  174. package/deps/couchbase-cxx-client/core/operations/management/user_drop.hxx +2 -0
  175. package/deps/couchbase-cxx-client/core/operations/management/user_get.hxx +2 -0
  176. package/deps/couchbase-cxx-client/core/operations/management/user_get_all.hxx +2 -0
  177. package/deps/couchbase-cxx-client/core/operations/management/user_upsert.hxx +2 -0
  178. package/deps/couchbase-cxx-client/core/operations/management/view_index_drop.hxx +2 -0
  179. package/deps/couchbase-cxx-client/core/operations/management/view_index_get.hxx +2 -0
  180. package/deps/couchbase-cxx-client/core/operations/management/view_index_get_all.hxx +2 -0
  181. package/deps/couchbase-cxx-client/core/operations/management/view_index_upsert.hxx +2 -0
  182. package/deps/couchbase-cxx-client/core/operations/operation_traits.hxx +6 -0
  183. package/deps/couchbase-cxx-client/core/operations.hxx +0 -1
  184. package/deps/couchbase-cxx-client/core/operations_fwd.hxx +8 -0
  185. package/deps/couchbase-cxx-client/core/origin.cxx +67 -12
  186. package/deps/couchbase-cxx-client/core/origin.hxx +13 -8
  187. package/deps/couchbase-cxx-client/core/orphan_reporter.cxx +164 -0
  188. package/deps/couchbase-cxx-client/core/orphan_reporter.hxx +65 -0
  189. package/deps/couchbase-cxx-client/core/sasl/CMakeLists.txt +1 -0
  190. package/deps/couchbase-cxx-client/core/sasl/client.cc +6 -0
  191. package/deps/couchbase-cxx-client/core/sasl/mechanism.cc +2 -1
  192. package/deps/couchbase-cxx-client/core/sasl/mechanism.h +2 -1
  193. package/deps/couchbase-cxx-client/core/sasl/oauthbearer/oauthbearer.cc +41 -0
  194. package/deps/couchbase-cxx-client/core/sasl/oauthbearer/oauthbearer.h +47 -0
  195. package/deps/couchbase-cxx-client/core/tls_context_provider.cxx +44 -0
  196. package/deps/couchbase-cxx-client/core/tls_context_provider.hxx +44 -0
  197. package/deps/couchbase-cxx-client/core/tracing/attribute_helpers.hxx +45 -0
  198. package/deps/couchbase-cxx-client/core/tracing/constants.hxx +148 -68
  199. package/deps/couchbase-cxx-client/core/tracing/threshold_logging_options.hxx +0 -3
  200. package/deps/couchbase-cxx-client/core/tracing/threshold_logging_tracer.cxx +122 -170
  201. package/deps/couchbase-cxx-client/core/tracing/tracer_wrapper.cxx +17 -24
  202. package/deps/couchbase-cxx-client/core/tracing/tracer_wrapper.hxx +8 -10
  203. package/deps/couchbase-cxx-client/core/tracing/wrapper_sdk_tracer.cxx +114 -0
  204. package/deps/couchbase-cxx-client/core/tracing/wrapper_sdk_tracer.hxx +85 -0
  205. package/deps/couchbase-cxx-client/core/transactions/attempt_context_impl.cxx +16 -14
  206. package/deps/couchbase-cxx-client/core/transactions/attempt_context_impl.hxx +4 -4
  207. package/deps/couchbase-cxx-client/core/transactions/transactions.cxx +1 -1
  208. package/deps/couchbase-cxx-client/core/transactions/transactions_cleanup.cxx +1 -2
  209. package/deps/couchbase-cxx-client/core/utils/byteswap.hxx +12 -0
  210. package/deps/couchbase-cxx-client/core/utils/concurrent_fixed_priority_queue.hxx +102 -0
  211. package/deps/couchbase-cxx-client/core/utils/connection_string.cxx +2 -0
  212. package/deps/couchbase-cxx-client/couchbase/certificate_authenticator.hxx +1 -0
  213. package/deps/couchbase-cxx-client/couchbase/cluster.hxx +47 -0
  214. package/deps/couchbase-cxx-client/couchbase/cluster_options.hxx +16 -0
  215. package/deps/couchbase-cxx-client/couchbase/collection.hxx +60 -15
  216. package/deps/couchbase-cxx-client/couchbase/error_codes.hxx +48 -48
  217. package/deps/couchbase-cxx-client/couchbase/jwt_authenticator.hxx +52 -0
  218. package/deps/couchbase-cxx-client/couchbase/metrics/meter.hxx +2 -1
  219. package/deps/couchbase-cxx-client/couchbase/metrics/otel_meter.hxx +75 -80
  220. package/deps/couchbase-cxx-client/couchbase/network_options.hxx +19 -0
  221. package/deps/couchbase-cxx-client/couchbase/password_authenticator.hxx +1 -0
  222. package/deps/couchbase-cxx-client/couchbase/tracing/otel_tracer.hxx +15 -17
  223. package/deps/couchbase-cxx-client/couchbase/tracing/request_span.hxx +2 -2
  224. package/dist/analyticsexecutor.d.ts +15 -0
  225. package/dist/analyticsexecutor.js +79 -50
  226. package/dist/analyticsindexmanager.d.ts +66 -0
  227. package/dist/analyticsindexmanager.js +404 -277
  228. package/dist/analyticstypes.d.ts +5 -0
  229. package/dist/authenticators.d.ts +34 -1
  230. package/dist/authenticators.js +19 -1
  231. package/dist/binarycollection.d.ts +17 -0
  232. package/dist/binding.d.ts +245 -228
  233. package/dist/bindingutilities.js +1 -1
  234. package/dist/bucket.d.ts +8 -0
  235. package/dist/bucket.js +8 -0
  236. package/dist/bucketmanager.d.ts +30 -0
  237. package/dist/bucketmanager.js +128 -69
  238. package/dist/cluster.d.ts +45 -0
  239. package/dist/cluster.js +133 -21
  240. package/dist/collection.d.ts +75 -2
  241. package/dist/collection.js +772 -551
  242. package/dist/collectionmanager.d.ts +34 -0
  243. package/dist/collectionmanager.js +172 -89
  244. package/dist/couchbase.d.ts +5 -0
  245. package/dist/couchbase.js +5 -0
  246. package/dist/datastructures.js +310 -97
  247. package/dist/errors.d.ts +8 -0
  248. package/dist/errors.js +12 -1
  249. package/dist/eventingfunctionmanager.d.ts +42 -0
  250. package/dist/eventingfunctionmanager.js +172 -100
  251. package/dist/logger.d.ts +192 -0
  252. package/dist/logger.js +213 -0
  253. package/dist/loggingmeter.d.ts +120 -0
  254. package/dist/loggingmeter.js +226 -0
  255. package/dist/metrics.d.ts +33 -0
  256. package/dist/metrics.js +5 -0
  257. package/dist/observability.d.ts +60 -0
  258. package/dist/observability.js +86 -0
  259. package/dist/observabilityhandler.d.ts +176 -0
  260. package/dist/observabilityhandler.js +733 -0
  261. package/dist/observabilitytypes.d.ts +320 -0
  262. package/dist/observabilitytypes.js +362 -0
  263. package/dist/observabilityutilities.d.ts +60 -0
  264. package/dist/observabilityutilities.js +175 -0
  265. package/dist/otelmeter.d.ts +51 -0
  266. package/dist/otelmeter.js +100 -0
  267. package/dist/oteltracer.d.ts +69 -0
  268. package/dist/oteltracer.js +141 -0
  269. package/dist/queryexecutor.d.ts +16 -0
  270. package/dist/queryexecutor.js +128 -86
  271. package/dist/queryindexmanager.d.ts +29 -0
  272. package/dist/queryindexmanager.js +277 -150
  273. package/dist/querytypes.d.ts +5 -0
  274. package/dist/scope.js +2 -2
  275. package/dist/scopeeventingfunctionmanager.d.ts +5 -0
  276. package/dist/scopeeventingfunctionmanager.js +217 -119
  277. package/dist/scopesearchindexmanager.d.ts +5 -0
  278. package/dist/scopesearchindexmanager.js +295 -166
  279. package/dist/sdspecs.js +6 -1
  280. package/dist/searchexecutor.d.ts +15 -0
  281. package/dist/searchexecutor.js +54 -26
  282. package/dist/searchindexmanager.d.ts +54 -0
  283. package/dist/searchindexmanager.js +235 -142
  284. package/dist/searchtypes.d.ts +5 -0
  285. package/dist/thresholdlogging.d.ts +301 -0
  286. package/dist/thresholdlogging.js +657 -0
  287. package/dist/tracing.d.ts +55 -0
  288. package/dist/tracing.js +2 -0
  289. package/dist/usermanager.d.ts +46 -0
  290. package/dist/usermanager.js +199 -118
  291. package/dist/utilities.d.ts +4 -0
  292. package/dist/utilities.js +11 -1
  293. package/dist/version.d.ts +2 -0
  294. package/dist/version.js +7 -0
  295. package/dist/viewexecutor.d.ts +15 -0
  296. package/dist/viewexecutor.js +54 -29
  297. package/dist/viewindexmanager.d.ts +30 -0
  298. package/dist/viewindexmanager.js +129 -100
  299. package/dist/viewtypes.d.ts +5 -0
  300. package/package.json +19 -9
  301. package/scripts/prebuilds.js +1 -1
  302. package/scripts/updateVersion.js +26 -0
  303. package/src/connection.cpp +79 -98
  304. package/src/connection.hpp +46 -38
  305. package/src/connection_autogen.cpp +1236 -292
  306. package/src/jstocbpp_autogen.hpp +1117 -313
  307. package/src/jstocbpp_basic.hpp +73 -0
  308. package/src/jstocbpp_defs.hpp +37 -9
  309. package/src/jstocbpp_errors.hpp +37 -11
  310. package/tools/gen-bindings-js.js +100 -22
  311. package/tools/gen-bindings-json.py +40 -6
  312. package/src/transcoder.hpp +0 -96
@@ -0,0 +1,657 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ThresholdLoggingTracer = exports.ThresholdLoggingSpan = void 0;
4
+ const generaltypes_1 = require("./generaltypes");
5
+ const observabilitytypes_1 = require("./observabilitytypes");
6
+ const observabilityutilities_1 = require("./observabilityutilities");
7
+ /* eslint-disable jsdoc/require-jsdoc */
8
+ /**
9
+ * @internal
10
+ */
11
+ var ThresholdLoggingAttributeName;
12
+ (function (ThresholdLoggingAttributeName) {
13
+ ThresholdLoggingAttributeName["EncodeDuration"] = "encode_duration_us";
14
+ ThresholdLoggingAttributeName["OperationName"] = "operation_name";
15
+ ThresholdLoggingAttributeName["OperationId"] = "operation_id";
16
+ ThresholdLoggingAttributeName["LastDispatchDuration"] = "last_dispatch_duration_us";
17
+ ThresholdLoggingAttributeName["LastLocalId"] = "last_local_id";
18
+ ThresholdLoggingAttributeName["LastLocalSocket"] = "last_local_socket";
19
+ ThresholdLoggingAttributeName["LastRemoteSocket"] = "last_remote_socket";
20
+ ThresholdLoggingAttributeName["LastServerDuration"] = "last_server_duration_us";
21
+ ThresholdLoggingAttributeName["Timeout"] = "timeout_ms";
22
+ ThresholdLoggingAttributeName["TotalDuration"] = "total_duration_us";
23
+ ThresholdLoggingAttributeName["TotalDispatchDuration"] = "total_dispatch_duration_us";
24
+ ThresholdLoggingAttributeName["TotalServerDuration"] = "total_server_duration_us";
25
+ })(ThresholdLoggingAttributeName || (ThresholdLoggingAttributeName = {}));
26
+ /**
27
+ * @internal
28
+ */
29
+ var IgnoredParentSpan;
30
+ (function (IgnoredParentSpan) {
31
+ IgnoredParentSpan["ListGetAll"] = "list_get_all";
32
+ IgnoredParentSpan["ListGetAt"] = "list_get_at";
33
+ IgnoredParentSpan["ListIndexOf"] = "list_index_of";
34
+ IgnoredParentSpan["ListPush"] = "list_push";
35
+ IgnoredParentSpan["ListRemoveAt"] = "list_remove_at";
36
+ IgnoredParentSpan["ListSize"] = "list_size";
37
+ IgnoredParentSpan["ListUnshift"] = "list_unshift";
38
+ IgnoredParentSpan["MapExists"] = "map_exists";
39
+ IgnoredParentSpan["MapGet"] = "map_get";
40
+ IgnoredParentSpan["MapGetAll"] = "map_get_all";
41
+ IgnoredParentSpan["MapKeys"] = "map_keys";
42
+ IgnoredParentSpan["MapRemove"] = "map_remove";
43
+ IgnoredParentSpan["MapSet"] = "map_set";
44
+ IgnoredParentSpan["MapSize"] = "map_size";
45
+ IgnoredParentSpan["MapValues"] = "map_values";
46
+ IgnoredParentSpan["QueuePop"] = "queue_pop";
47
+ IgnoredParentSpan["QueuePush"] = "queue_push";
48
+ IgnoredParentSpan["QueueSize"] = "queue_size";
49
+ IgnoredParentSpan["SetAdd"] = "set_add";
50
+ IgnoredParentSpan["SetContains"] = "set_contains";
51
+ IgnoredParentSpan["SetRemove"] = "set_remove";
52
+ IgnoredParentSpan["SetSize"] = "set_size";
53
+ IgnoredParentSpan["SetValues"] = "set_values";
54
+ })(IgnoredParentSpan || (IgnoredParentSpan = {}));
55
+ const IGNORED_PARENT_SPAN_VALUES = new Set(Object.values(IgnoredParentSpan));
56
+ class ThresholdLoggingSpanSnapshot {
57
+ constructor(span) {
58
+ this.name = span.name;
59
+ this.serviceType = span.serviceType;
60
+ this.totalDuration = span.totalDuration;
61
+ this.encodeDuration = span.encodeDuration;
62
+ this.dispatchDuration = span.dispatchDuration;
63
+ this.totalDispatchDuration = span.totalDispatchDuration;
64
+ this.serverDuration = span.serverDuration;
65
+ this.totalServerDuration = span.totalServerDuration;
66
+ this.localId = span.localId;
67
+ this.operationId = span.operationId;
68
+ this.localSocket = span.localSocket;
69
+ this.remoteSocket = span.remoteSocket;
70
+ }
71
+ }
72
+ /**
73
+ * @internal
74
+ */
75
+ class PriorityQueue {
76
+ constructor(capacity) {
77
+ this._capacity = capacity !== null && capacity !== void 0 ? capacity : 10;
78
+ this._queue = new Array(this._capacity);
79
+ this._size = 0;
80
+ this._droppedCount = 0;
81
+ }
82
+ get droppedCount() {
83
+ return this._droppedCount;
84
+ }
85
+ _getInsertIndex(priority) {
86
+ let left = 0;
87
+ let right = this._size;
88
+ while (left < right) {
89
+ const mid = (left + right) >>> 1; // Math.floor((left + right) / 2) but slightly better
90
+ if (this._queue[mid].priority < priority) {
91
+ left = mid + 1;
92
+ }
93
+ else {
94
+ right = mid;
95
+ }
96
+ }
97
+ return left;
98
+ }
99
+ enqueue(item, priority) {
100
+ if (this._size >= this._capacity) {
101
+ const lowestPriority = this._queue[0].priority;
102
+ if (lowestPriority >= priority) {
103
+ this._droppedCount++;
104
+ return false;
105
+ }
106
+ // shift the queue left
107
+ for (let i = 0; i < this._size - 1; i++) {
108
+ this._queue[i] = this._queue[i + 1];
109
+ }
110
+ this._size--;
111
+ this._droppedCount++;
112
+ }
113
+ const insertIdx = this._getInsertIndex(priority);
114
+ // shift items > insertIdx right
115
+ for (let i = this._size; i > insertIdx; i--) {
116
+ this._queue[i] = this._queue[i - 1];
117
+ }
118
+ this._queue[insertIdx] = { item: item, priority: priority };
119
+ this._size++;
120
+ return true;
121
+ }
122
+ peek() {
123
+ return this._size > 0 ? this._queue[0].item : undefined;
124
+ }
125
+ drain() {
126
+ const items = [];
127
+ for (let i = 0; i < this._size; i++) {
128
+ items.push(this._queue[i].item);
129
+ }
130
+ const droppedCount = this._droppedCount;
131
+ this._size = 0;
132
+ this._droppedCount = 0;
133
+ // Return items in descending priority order (highest duration first)
134
+ items.reverse();
135
+ return [items, droppedCount];
136
+ }
137
+ }
138
+ /**
139
+ * @internal
140
+ */
141
+ class ThresholdLoggingReporter {
142
+ constructor(logger, interval, capacity) {
143
+ this._logger = logger;
144
+ this._interval = interval;
145
+ this._thresholdQueues = new Map();
146
+ this._thresholdQueues.set(generaltypes_1.ServiceType.KeyValue, new PriorityQueue(capacity));
147
+ this._thresholdQueues.set(generaltypes_1.ServiceType.Query, new PriorityQueue(capacity));
148
+ this._thresholdQueues.set(generaltypes_1.ServiceType.Search, new PriorityQueue(capacity));
149
+ this._thresholdQueues.set(generaltypes_1.ServiceType.Analytics, new PriorityQueue(capacity));
150
+ this._thresholdQueues.set(generaltypes_1.ServiceType.Views, new PriorityQueue(capacity));
151
+ this._thresholdQueues.set(generaltypes_1.ServiceType.Management, new PriorityQueue(capacity));
152
+ this._thresholdQueues.set(generaltypes_1.ServiceType.Eventing, new PriorityQueue(capacity));
153
+ this._stopped = false;
154
+ }
155
+ addLogRecord(serviceType, item, totalDuration) {
156
+ var _a;
157
+ (_a = this._thresholdQueues.get(serviceType)) === null || _a === void 0 ? void 0 : _a.enqueue(item, totalDuration);
158
+ }
159
+ start() {
160
+ this._timerId = setInterval(this.report.bind(this), this._interval);
161
+ // let the process exit even if the reporter has not been shutdown
162
+ this._timerId.unref();
163
+ this._stopped = false;
164
+ }
165
+ stop() {
166
+ if (this._stopped) {
167
+ return;
168
+ }
169
+ this._stopped = true;
170
+ clearInterval(this._timerId);
171
+ }
172
+ report(returnReport) {
173
+ const report = {};
174
+ for (const [serviceType, queue] of this._thresholdQueues) {
175
+ const [items, droppedCount] = queue.drain();
176
+ if (items.length > 0) {
177
+ report[serviceType] = {
178
+ total_count: items.length + droppedCount,
179
+ top_requests: items.map((item) => Object.fromEntries(item)),
180
+ };
181
+ }
182
+ }
183
+ if (returnReport) {
184
+ return report;
185
+ }
186
+ else {
187
+ if (Object.keys(report).length > 0) {
188
+ this._logger.info(JSON.stringify(report));
189
+ }
190
+ }
191
+ }
192
+ }
193
+ /**
194
+ * @internal
195
+ */
196
+ function serviceTypeFromString(serviceType) {
197
+ switch (serviceType.toLocaleLowerCase()) {
198
+ case 'kv':
199
+ case 'keyValue':
200
+ return generaltypes_1.ServiceType.KeyValue;
201
+ case 'query':
202
+ return generaltypes_1.ServiceType.Query;
203
+ case 'search':
204
+ return generaltypes_1.ServiceType.Search;
205
+ case 'analytics':
206
+ return generaltypes_1.ServiceType.Analytics;
207
+ case 'views':
208
+ return generaltypes_1.ServiceType.Views;
209
+ case 'management':
210
+ return generaltypes_1.ServiceType.Management;
211
+ case 'eventing':
212
+ return generaltypes_1.ServiceType.Eventing;
213
+ default:
214
+ throw new Error('Unrecognized service type.');
215
+ }
216
+ }
217
+ /**
218
+ * A RequestSpan implementation that tracks operation timing for threshold logging.
219
+ *
220
+ * Works with {@link ThresholdLoggingTracer} to identify and log slow operations
221
+ * that exceed configured thresholds.
222
+ *
223
+ */
224
+ class ThresholdLoggingSpan {
225
+ /**
226
+ * Creates a new threshold logging span.
227
+ *
228
+ * @param name - The name of the operation being traced.
229
+ * @param tracer - The span's tracer.
230
+ * @param parentSpan - Optional parent span for hierarchical tracing.
231
+ * @param startTime - Optional start time; defaults to current time if not provided.
232
+ */
233
+ constructor(name, tracer, parentSpan, startTime) {
234
+ this._attributes = {};
235
+ this._status = { code: observabilitytypes_1.SpanStatusCode.UNSET };
236
+ this._name = name;
237
+ this._tracer = tracer;
238
+ this._parentSpan = parentSpan;
239
+ this._startTime = this._getTime(startTime);
240
+ this._totalDuration = 0;
241
+ this._totalDispatchDuration = 0;
242
+ this._totalServerDuration = 0;
243
+ this._totalEncodeDuration = 0;
244
+ }
245
+ /**
246
+ * Gets the dispatch duration of the request, in microseconds.
247
+ *
248
+ * @internal
249
+ */
250
+ get dispatchDuration() {
251
+ return this._dispatchDuration;
252
+ }
253
+ /**
254
+ * Sets the dispatch duration of the request, in microseconds.
255
+ *
256
+ * @internal
257
+ */
258
+ set dispatchDuration(duration) {
259
+ this._dispatchDuration = duration;
260
+ this._totalDispatchDuration += this._dispatchDuration;
261
+ if (this._parentSpan) {
262
+ this._parentSpan.dispatchDuration = duration;
263
+ }
264
+ }
265
+ /**
266
+ * Gets the duration spent encoding the request, in microseconds.
267
+ *
268
+ * @internal
269
+ */
270
+ get encodeDuration() {
271
+ return this._encodeDuration;
272
+ }
273
+ /**
274
+ * Sets the duration spent encoding the request, in microseconds.
275
+ *
276
+ * @internal
277
+ */
278
+ set encodeDuration(duration) {
279
+ this._encodeDuration = duration;
280
+ this._totalEncodeDuration += this._encodeDuration;
281
+ if (this._parentSpan) {
282
+ this._parentSpan.encodeDuration = duration;
283
+ }
284
+ }
285
+ /**
286
+ * Gets the local ID of the request's dispatch span.
287
+ *
288
+ * @internal
289
+ */
290
+ get localId() {
291
+ return this._localId;
292
+ }
293
+ /**
294
+ * Gets the local socket of the request's dispatch span.
295
+ *
296
+ * @internal
297
+ */
298
+ get localSocket() {
299
+ var _a, _b;
300
+ if (this._peerAddress !== undefined || this._peerPort !== undefined) {
301
+ const address = (_a = this._peerAddress) !== null && _a !== void 0 ? _a : '';
302
+ const port = (_b = this._peerPort) !== null && _b !== void 0 ? _b : '';
303
+ return `${address}:${port}`;
304
+ }
305
+ }
306
+ /**
307
+ * Gets the name of the span.
308
+ */
309
+ get name() {
310
+ return this._name;
311
+ }
312
+ /**
313
+ * Gets the operation ID of the request's dispatch span.
314
+ *
315
+ * @internal
316
+ */
317
+ get operationId() {
318
+ return this._operationId;
319
+ }
320
+ /**
321
+ * Gets the peer address of the request's dispatch span.
322
+ *
323
+ * @internal
324
+ */
325
+ get peerAddress() {
326
+ return this._peerAddress;
327
+ }
328
+ /**
329
+ * Gets the peer port of the request's dispatch span.
330
+ *
331
+ * @internal
332
+ */
333
+ get peerPort() {
334
+ return this._peerPort;
335
+ }
336
+ /**
337
+ * Gets the remote socket of the request's dispatch span.
338
+ *
339
+ * @internal
340
+ */
341
+ get remoteSocket() {
342
+ var _a, _b;
343
+ if (this._remoteAddress !== undefined || this._remotePort !== undefined) {
344
+ const address = (_a = this._remoteAddress) !== null && _a !== void 0 ? _a : '';
345
+ const port = (_b = this._remotePort) !== null && _b !== void 0 ? _b : '';
346
+ return `${address}:${port}`;
347
+ }
348
+ }
349
+ /**
350
+ * Gets the server duration of the request, in microseconds.
351
+ *
352
+ * @internal
353
+ */
354
+ get serverDuration() {
355
+ return this._serverDuration;
356
+ }
357
+ /**
358
+ * Gets the Couchbase service type handling this operation.
359
+ *
360
+ * @internal
361
+ */
362
+ get serviceType() {
363
+ return this._serviceType;
364
+ }
365
+ /**
366
+ * Gets the snapshot of the span containing all relevant information for threshold logging.
367
+ *
368
+ * @internal
369
+ */
370
+ get snapshot() {
371
+ return this._snapshot;
372
+ }
373
+ /**
374
+ * Gets the total dispatch duration of the request, in microseconds.
375
+ *
376
+ * @internal
377
+ */
378
+ get totalDispatchDuration() {
379
+ return this._totalDispatchDuration;
380
+ }
381
+ /**
382
+ * Gets the total encoding duration of the request, in microseconds.
383
+ *
384
+ * @internal
385
+ */
386
+ get totalEncodeDuration() {
387
+ return this._totalEncodeDuration;
388
+ }
389
+ /**
390
+ * Gets the total duration of the request, in microseconds.
391
+ *
392
+ * @internal
393
+ */
394
+ get totalDuration() {
395
+ return this._totalDuration;
396
+ }
397
+ /**
398
+ * Gets the total server duration of the request, in microseconds.
399
+ *
400
+ * @internal
401
+ */
402
+ get totalServerDuration() {
403
+ return this._totalServerDuration;
404
+ }
405
+ /**
406
+ * Sets a single attribute on the span.
407
+ *
408
+ * @param key - The attribute key.
409
+ * @param value - The attribute value.
410
+ */
411
+ setAttribute(key, value) {
412
+ let propagatedToParent = true;
413
+ if (key === observabilitytypes_1.OpAttributeName.Service) {
414
+ this._serviceType = serviceTypeFromString(value);
415
+ }
416
+ else if (key === observabilitytypes_1.DispatchAttributeName.ServerDuration) {
417
+ this._serverDuration = value;
418
+ this._totalServerDuration += this._serverDuration;
419
+ }
420
+ else if (key === observabilitytypes_1.DispatchAttributeName.LocalId) {
421
+ this._localId = value;
422
+ }
423
+ else if (key === observabilitytypes_1.DispatchAttributeName.OperationId) {
424
+ this._operationId = value;
425
+ }
426
+ else if (key === observabilitytypes_1.DispatchAttributeName.PeerAddress) {
427
+ this._peerAddress = value;
428
+ }
429
+ else if (key === observabilitytypes_1.DispatchAttributeName.PeerPort) {
430
+ this._peerPort = value;
431
+ }
432
+ else if (key === observabilitytypes_1.DispatchAttributeName.ServerAddress) {
433
+ this._remoteAddress = value;
434
+ }
435
+ else if (key === observabilitytypes_1.DispatchAttributeName.ServerPort) {
436
+ this._remotePort = value;
437
+ }
438
+ else {
439
+ this._attributes[key] = value;
440
+ propagatedToParent = false;
441
+ }
442
+ if (propagatedToParent && this._parentSpan) {
443
+ this._parentSpan.setAttribute(key, value);
444
+ }
445
+ }
446
+ /**
447
+ * Adds a timestamped event to the span.
448
+ */
449
+ addEvent() { }
450
+ /**
451
+ * Sets the status of the span.
452
+ *
453
+ * @param status - The span status containing code and optional message.
454
+ */
455
+ setStatus(status) {
456
+ this._status = status;
457
+ }
458
+ /**
459
+ * Marks the span as complete and calculates the total duration.
460
+ *
461
+ * The total duration is computed from the start time to the end time
462
+ * and stored in microseconds.
463
+ *
464
+ * @param endTime - Optional end time; defaults to current time if not provided.
465
+ */
466
+ end(endTime) {
467
+ if (this._endTime) {
468
+ // prevent ending the span multiple times
469
+ return;
470
+ }
471
+ this._endTime = this._getTime(endTime);
472
+ this._totalDuration = (0, observabilityutilities_1.hiResTimeToMicros)((0, observabilityutilities_1.getHiResTimeDelta)(this._startTime, this._endTime));
473
+ this._snapshot = new ThresholdLoggingSpanSnapshot(this);
474
+ if (this._name == observabilitytypes_1.OpAttributeName.EncodingSpanName) {
475
+ this.encodeDuration = this._totalDuration;
476
+ }
477
+ else if (this._name == observabilitytypes_1.OpAttributeName.DispatchSpanName) {
478
+ this.dispatchDuration = this._totalDuration;
479
+ }
480
+ else if (this._parentSpan &&
481
+ IGNORED_PARENT_SPAN_VALUES.has(this._parentSpan.name)) {
482
+ this._tracer.checkThreshold(this._snapshot);
483
+ }
484
+ else if (!this._parentSpan &&
485
+ !IGNORED_PARENT_SPAN_VALUES.has(this._name)) {
486
+ this._tracer.checkThreshold(this._snapshot);
487
+ }
488
+ }
489
+ /**
490
+ * Converts various time input formats to HiResTime.
491
+ *
492
+ * @param input - Time input (Date, number, HiResTime, or undefined for current time).
493
+ * @returns {HiResTime} High-resolution time value.
494
+ */
495
+ _getTime(input) {
496
+ if (typeof input === 'undefined') {
497
+ return (0, observabilityutilities_1.timeInputToHiResTime)();
498
+ }
499
+ else if (input instanceof Date) {
500
+ return (0, observabilityutilities_1.millisToHiResTime)(input.getTime());
501
+ }
502
+ else if (typeof input === 'number') {
503
+ // TODO: is this accurate?
504
+ return (0, observabilityutilities_1.millisToHiResTime)(input);
505
+ }
506
+ return input;
507
+ }
508
+ }
509
+ exports.ThresholdLoggingSpan = ThresholdLoggingSpan;
510
+ /**
511
+ * A RequestTracer implementation that identifies and logs slow operations.
512
+ */
513
+ class ThresholdLoggingTracer {
514
+ /**
515
+ * Creates a new threshold logging tracer.
516
+ *
517
+ * @param logger - The logger to be used by the ThresholdLoggingReporter.
518
+ * @param config - Tracing configuration with thresholds and reporting settings.
519
+ * If null, default values are used for all settings.
520
+ */
521
+ constructor(logger, config) {
522
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
523
+ this._emitInterval = (_a = config === null || config === void 0 ? void 0 : config.emitInterval) !== null && _a !== void 0 ? _a : 10000;
524
+ this._sampleSize = (_b = config === null || config === void 0 ? void 0 : config.sampleSize) !== null && _b !== void 0 ? _b : 10;
525
+ this._serviceThresholds = new Map();
526
+ this._serviceThresholds.set(generaltypes_1.ServiceType.KeyValue, (_c = config === null || config === void 0 ? void 0 : config.kvThreshold) !== null && _c !== void 0 ? _c : 500);
527
+ this._serviceThresholds.set(generaltypes_1.ServiceType.Query, (_d = config === null || config === void 0 ? void 0 : config.queryThreshold) !== null && _d !== void 0 ? _d : 1000);
528
+ this._serviceThresholds.set(generaltypes_1.ServiceType.Search, (_e = config === null || config === void 0 ? void 0 : config.searchThreshold) !== null && _e !== void 0 ? _e : 1000);
529
+ this._serviceThresholds.set(generaltypes_1.ServiceType.Analytics, (_f = config === null || config === void 0 ? void 0 : config.analyticsThreshold) !== null && _f !== void 0 ? _f : 1000);
530
+ this._serviceThresholds.set(generaltypes_1.ServiceType.Views, (_g = config === null || config === void 0 ? void 0 : config.viewsThreshold) !== null && _g !== void 0 ? _g : 1000);
531
+ this._serviceThresholds.set(generaltypes_1.ServiceType.Management, (_h = config === null || config === void 0 ? void 0 : config.managementThreshold) !== null && _h !== void 0 ? _h : 1000);
532
+ this._serviceThresholds.set(generaltypes_1.ServiceType.Eventing, (_j = config === null || config === void 0 ? void 0 : config.eventingThreshold) !== null && _j !== void 0 ? _j : 1000);
533
+ this._reporter = new ThresholdLoggingReporter(logger, this._emitInterval, this._sampleSize);
534
+ this._reporter.start();
535
+ }
536
+ /**
537
+ * Gets the tracer's ThresholdLoggingReporter.
538
+ *
539
+ * @internal
540
+ */
541
+ get reporter() {
542
+ return this._reporter;
543
+ }
544
+ /**
545
+ * Gets the tracer's service thresholds.
546
+ *
547
+ * @internal
548
+ */
549
+ get serviceThresholds() {
550
+ return this._serviceThresholds;
551
+ }
552
+ /**
553
+ * Stops the threshold logging reporter and cleans up resources.
554
+ *
555
+ * This method should be called when shutting down the application or when
556
+ * the tracer is no longer needed to ensure the periodic reporting timer
557
+ * is properly cleared.
558
+ */
559
+ cleanup() {
560
+ this._reporter.stop();
561
+ }
562
+ /**
563
+ * Creates a new threshold logging span to trace an operation.
564
+ *
565
+ * @param name - The name of the operation being traced.
566
+ * @param parentSpan - Optional parent span for hierarchical tracing.
567
+ * @param startTime - Optional start time; defaults to current time if not provided.
568
+ * @returns {ThresholdLoggingSpan} A new ThresholdLoggingSpan instance.
569
+ */
570
+ requestSpan(name, parentSpan, startTime) {
571
+ return new ThresholdLoggingSpan(name, this, parentSpan, startTime);
572
+ }
573
+ /**
574
+ * Checks if an operation exceeded its threshold and collects diagnostic information.
575
+ *
576
+ * If the operation's duration exceeds the configured threshold for its service type,
577
+ * detailed timing and connection information is extracted from the span and its
578
+ * associated core spans (network dispatch spans) and added to the reporter's queue.
579
+ *
580
+ * @param span - The completed threshold logging span to check.
581
+ * @param coreSpans - Optional array of low-level network dispatch spans containing.
582
+ * detailed timing and connection information.
583
+ *
584
+ * @internal
585
+ */
586
+ checkThreshold(spanSnapshot) {
587
+ var _a;
588
+ if (typeof spanSnapshot.serviceType === 'undefined') {
589
+ return;
590
+ }
591
+ const serviceThreshold = this._getServiceTypeThreshold(spanSnapshot.serviceType);
592
+ const spanTotalDuration = (_a = spanSnapshot.totalDuration) !== null && _a !== void 0 ? _a : 0;
593
+ if (!serviceThreshold || spanTotalDuration <= serviceThreshold) {
594
+ return;
595
+ }
596
+ const thresholdLogRecord = this._buildThresholdLogRecord(spanSnapshot, spanTotalDuration);
597
+ this._reporter.addLogRecord(spanSnapshot.serviceType, thresholdLogRecord, spanTotalDuration);
598
+ }
599
+ /**
600
+ * Converts the request span and all child spans into single ThresholdLogRecord.
601
+ *
602
+ * @param requestSpan - The request span.
603
+ * @param spanTotalDuration - The request spans duration.
604
+ * @returns {ThresholdLogRecord} The converted spans to a single ThresholdLogRecord.
605
+ *
606
+ * @internal
607
+ */
608
+ _buildThresholdLogRecord(spanSnapshot, spanTotalDuration) {
609
+ const thresholdLogRecord = new Map();
610
+ thresholdLogRecord.set(ThresholdLoggingAttributeName.OperationName, spanSnapshot.name);
611
+ thresholdLogRecord.set(ThresholdLoggingAttributeName.TotalDuration, spanTotalDuration);
612
+ if (spanSnapshot.encodeDuration) {
613
+ thresholdLogRecord.set(ThresholdLoggingAttributeName.EncodeDuration, spanSnapshot.encodeDuration);
614
+ }
615
+ const isKeyValueOp = spanSnapshot.serviceType == generaltypes_1.ServiceType.KeyValue;
616
+ if (spanSnapshot.totalDispatchDuration) {
617
+ thresholdLogRecord.set(ThresholdLoggingAttributeName.TotalDispatchDuration, spanSnapshot.totalDispatchDuration);
618
+ }
619
+ if (isKeyValueOp && spanSnapshot.totalServerDuration) {
620
+ thresholdLogRecord.set(ThresholdLoggingAttributeName.TotalServerDuration, spanSnapshot.totalServerDuration);
621
+ }
622
+ if (spanSnapshot.dispatchDuration) {
623
+ thresholdLogRecord.set(ThresholdLoggingAttributeName.LastDispatchDuration, spanSnapshot.dispatchDuration);
624
+ }
625
+ if (isKeyValueOp && spanSnapshot.serverDuration) {
626
+ thresholdLogRecord.set(ThresholdLoggingAttributeName.LastServerDuration, spanSnapshot.serverDuration);
627
+ }
628
+ if (spanSnapshot.localId) {
629
+ thresholdLogRecord.set(ThresholdLoggingAttributeName.LastLocalId, spanSnapshot.localId);
630
+ }
631
+ if (spanSnapshot.operationId) {
632
+ thresholdLogRecord.set(ThresholdLoggingAttributeName.OperationId, spanSnapshot.operationId);
633
+ }
634
+ if (spanSnapshot.localSocket) {
635
+ thresholdLogRecord.set(ThresholdLoggingAttributeName.LastLocalSocket, spanSnapshot.localSocket);
636
+ }
637
+ if (spanSnapshot.remoteSocket) {
638
+ thresholdLogRecord.set(ThresholdLoggingAttributeName.LastRemoteSocket, spanSnapshot.remoteSocket);
639
+ }
640
+ return thresholdLogRecord;
641
+ }
642
+ /**
643
+ * Gets the configured threshold for a specific service type.
644
+ *
645
+ * @param serviceType - The Couchbase service type.
646
+ * @returns The threshold in microseconds (millisecond config value * 1000).
647
+ *
648
+ * @internal
649
+ */
650
+ _getServiceTypeThreshold(serviceType) {
651
+ var _a;
652
+ const baseThreshold = (_a = this._serviceThresholds.get(serviceType)) !== null && _a !== void 0 ? _a : 0;
653
+ // convert to micros
654
+ return baseThreshold * 1000;
655
+ }
656
+ }
657
+ exports.ThresholdLoggingTracer = ThresholdLoggingTracer;