couchbase 3.7.0 → 3.8.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 (286) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +3 -3
  3. data/ext/CMakeLists.txt +4 -1
  4. data/ext/cache/extconf_include.rb +4 -3
  5. data/ext/cache/mozilla-ca-bundle.crt +66 -93
  6. data/ext/cache/mozilla-ca-bundle.sha256 +1 -1
  7. data/ext/couchbase/CMakeLists.txt +24 -11
  8. data/ext/couchbase/cmake/APKBUILD.in +17 -1
  9. data/ext/couchbase/cmake/Bundler.cmake +9 -1
  10. data/ext/couchbase/cmake/Cache.cmake +48 -19
  11. data/ext/couchbase/cmake/CompilerOptions.cmake +3 -1
  12. data/ext/couchbase/cmake/OpenSSL.cmake +10 -2
  13. data/ext/couchbase/cmake/Packaging.cmake +48 -8
  14. data/ext/couchbase/cmake/ThirdPartyDependencies.cmake +43 -1
  15. data/ext/couchbase/cmake/build_config.hxx.in +2 -0
  16. data/ext/couchbase/cmake/couchbase-cxx-client.spec.in +18 -0
  17. data/ext/couchbase/cmake/tarball_glob.txt +10 -0
  18. data/ext/couchbase/core/app_telemetry_meter.cxx +1 -0
  19. data/ext/couchbase/core/app_telemetry_reporter.cxx +45 -43
  20. data/ext/couchbase/core/app_telemetry_reporter.hxx +4 -3
  21. data/ext/couchbase/core/bucket.cxx +128 -13
  22. data/ext/couchbase/core/bucket.hxx +12 -2
  23. data/ext/couchbase/core/cluster.cxx +304 -152
  24. data/ext/couchbase/core/cluster.hxx +32 -0
  25. data/ext/couchbase/core/cluster_credentials.cxx +25 -0
  26. data/ext/couchbase/core/cluster_credentials.hxx +5 -0
  27. data/ext/couchbase/core/cluster_label_listener.cxx +72 -0
  28. data/ext/couchbase/core/cluster_label_listener.hxx +46 -0
  29. data/ext/couchbase/core/cluster_options.hxx +4 -0
  30. data/ext/couchbase/core/deprecation_utils.hxx +26 -0
  31. data/ext/couchbase/core/error.hxx +27 -0
  32. data/ext/couchbase/core/free_form_http_request.hxx +0 -2
  33. data/ext/couchbase/core/http_component.cxx +12 -48
  34. data/ext/couchbase/core/impl/analytics.cxx +3 -2
  35. data/ext/couchbase/core/impl/analytics.hxx +2 -1
  36. data/ext/couchbase/core/impl/analytics_index_manager.cxx +249 -137
  37. data/ext/couchbase/core/impl/binary_collection.cxx +134 -58
  38. data/ext/couchbase/core/impl/bucket_manager.cxx +87 -35
  39. data/ext/couchbase/core/impl/collection.cxx +560 -245
  40. data/ext/couchbase/core/impl/collection_manager.cxx +89 -49
  41. data/ext/couchbase/core/impl/dns_srv_tracker.cxx +4 -4
  42. data/ext/couchbase/core/impl/error.cxx +20 -13
  43. data/ext/couchbase/core/impl/error.hxx +15 -10
  44. data/ext/couchbase/core/impl/get_all_replicas.hxx +1 -1
  45. data/ext/couchbase/core/impl/get_any_replica.hxx +2 -1
  46. data/ext/couchbase/core/impl/get_replica.hxx +2 -0
  47. data/ext/couchbase/core/impl/lookup_in_replica.hxx +1 -1
  48. data/ext/couchbase/core/impl/observability_recorder.cxx +161 -0
  49. data/ext/couchbase/core/impl/observability_recorder.hxx +77 -0
  50. data/ext/couchbase/core/impl/observe_seqno.hxx +2 -0
  51. data/ext/couchbase/core/impl/public_bucket.cxx +31 -7
  52. data/ext/couchbase/core/impl/public_cluster.cxx +107 -19
  53. data/ext/couchbase/core/impl/query.cxx +6 -3
  54. data/ext/couchbase/core/impl/query.hxx +3 -1
  55. data/ext/couchbase/core/impl/query_index_manager.cxx +267 -102
  56. data/ext/couchbase/core/impl/scope.cxx +53 -11
  57. data/ext/couchbase/core/impl/search.cxx +8 -4
  58. data/ext/couchbase/core/impl/search.hxx +6 -2
  59. data/ext/couchbase/core/impl/search_index_manager.cxx +131 -41
  60. data/ext/couchbase/core/impl/with_cancellation.hxx +75 -0
  61. data/ext/couchbase/core/io/config_tracker.cxx +9 -9
  62. data/ext/couchbase/core/io/config_tracker.hxx +2 -1
  63. data/ext/couchbase/core/io/http_command.hxx +98 -49
  64. data/ext/couchbase/core/io/http_context.hxx +2 -0
  65. data/ext/couchbase/core/io/http_session.cxx +23 -10
  66. data/ext/couchbase/core/io/http_session.hxx +17 -9
  67. data/ext/couchbase/core/io/http_session_manager.hxx +163 -228
  68. data/ext/couchbase/core/io/http_traits.hxx +0 -7
  69. data/ext/couchbase/core/io/mcbp_command.hxx +123 -44
  70. data/ext/couchbase/core/io/mcbp_session.cxx +251 -26
  71. data/ext/couchbase/core/io/mcbp_session.hxx +9 -1
  72. data/ext/couchbase/core/io/mcbp_traits.hxx +0 -8
  73. data/ext/couchbase/core/io/streams.cxx +3 -3
  74. data/ext/couchbase/core/io/streams.hxx +3 -2
  75. data/ext/couchbase/core/meta/features.hxx +15 -0
  76. data/ext/couchbase/core/meta/version.cxx +13 -0
  77. data/ext/couchbase/core/meta/version.hxx +3 -0
  78. data/ext/couchbase/core/metrics/constants.hxx +23 -0
  79. data/ext/couchbase/core/metrics/logging_meter.cxx +5 -5
  80. data/ext/couchbase/core/metrics/meter_wrapper.cxx +65 -63
  81. data/ext/couchbase/core/metrics/meter_wrapper.hxx +12 -10
  82. data/ext/couchbase/core/operations/document_analytics.hxx +0 -5
  83. data/ext/couchbase/core/operations/document_append.hxx +0 -4
  84. data/ext/couchbase/core/operations/document_decrement.hxx +0 -5
  85. data/ext/couchbase/core/operations/document_exists.hxx +0 -7
  86. data/ext/couchbase/core/operations/document_get.hxx +0 -7
  87. data/ext/couchbase/core/operations/document_get_all_replicas.hxx +77 -27
  88. data/ext/couchbase/core/operations/document_get_and_lock.hxx +0 -9
  89. data/ext/couchbase/core/operations/document_get_and_touch.hxx +0 -9
  90. data/ext/couchbase/core/operations/document_get_any_replica.hxx +83 -2
  91. data/ext/couchbase/core/operations/document_get_projected.hxx +0 -9
  92. data/ext/couchbase/core/operations/document_increment.hxx +0 -5
  93. data/ext/couchbase/core/operations/document_insert.hxx +0 -4
  94. data/ext/couchbase/core/operations/document_lookup_in.hxx +0 -9
  95. data/ext/couchbase/core/operations/document_lookup_in_all_replicas.hxx +46 -4
  96. data/ext/couchbase/core/operations/document_lookup_in_any_replica.hxx +121 -43
  97. data/ext/couchbase/core/operations/document_mutate_in.hxx +0 -5
  98. data/ext/couchbase/core/operations/document_prepend.hxx +0 -4
  99. data/ext/couchbase/core/operations/document_query.hxx +0 -4
  100. data/ext/couchbase/core/operations/document_remove.hxx +0 -4
  101. data/ext/couchbase/core/operations/document_replace.hxx +0 -4
  102. data/ext/couchbase/core/operations/document_search.hxx +0 -7
  103. data/ext/couchbase/core/operations/document_touch.hxx +0 -7
  104. data/ext/couchbase/core/operations/document_unlock.hxx +0 -6
  105. data/ext/couchbase/core/operations/document_upsert.hxx +0 -4
  106. data/ext/couchbase/core/operations/document_view.cxx +2 -0
  107. data/ext/couchbase/core/operations/document_view.hxx +10 -13
  108. data/ext/couchbase/core/operations/http_noop.hxx +2 -0
  109. data/ext/couchbase/core/operations/management/analytics_dataset_create.hxx +2 -0
  110. data/ext/couchbase/core/operations/management/analytics_dataset_drop.hxx +2 -0
  111. data/ext/couchbase/core/operations/management/analytics_dataset_get_all.hxx +2 -0
  112. data/ext/couchbase/core/operations/management/analytics_dataverse_create.hxx +2 -0
  113. data/ext/couchbase/core/operations/management/analytics_dataverse_drop.hxx +2 -0
  114. data/ext/couchbase/core/operations/management/analytics_get_pending_mutations.hxx +2 -0
  115. data/ext/couchbase/core/operations/management/analytics_index_create.hxx +2 -0
  116. data/ext/couchbase/core/operations/management/analytics_index_drop.hxx +2 -0
  117. data/ext/couchbase/core/operations/management/analytics_index_get_all.hxx +2 -0
  118. data/ext/couchbase/core/operations/management/analytics_link_connect.hxx +2 -0
  119. data/ext/couchbase/core/operations/management/analytics_link_create.hxx +2 -0
  120. data/ext/couchbase/core/operations/management/analytics_link_disconnect.hxx +2 -0
  121. data/ext/couchbase/core/operations/management/analytics_link_drop.hxx +2 -0
  122. data/ext/couchbase/core/operations/management/analytics_link_get_all.hxx +2 -0
  123. data/ext/couchbase/core/operations/management/analytics_link_replace.hxx +2 -0
  124. data/ext/couchbase/core/operations/management/bucket_create.hxx +2 -0
  125. data/ext/couchbase/core/operations/management/bucket_describe.hxx +2 -0
  126. data/ext/couchbase/core/operations/management/bucket_drop.hxx +2 -0
  127. data/ext/couchbase/core/operations/management/bucket_flush.hxx +2 -0
  128. data/ext/couchbase/core/operations/management/bucket_get.hxx +2 -0
  129. data/ext/couchbase/core/operations/management/bucket_get_all.hxx +2 -0
  130. data/ext/couchbase/core/operations/management/bucket_update.hxx +2 -0
  131. data/ext/couchbase/core/operations/management/change_password.hxx +2 -0
  132. data/ext/couchbase/core/operations/management/cluster_describe.hxx +2 -0
  133. data/ext/couchbase/core/operations/management/cluster_developer_preview_enable.hxx +2 -0
  134. data/ext/couchbase/core/operations/management/collection_create.hxx +2 -0
  135. data/ext/couchbase/core/operations/management/collection_drop.hxx +2 -0
  136. data/ext/couchbase/core/operations/management/collection_update.hxx +2 -0
  137. data/ext/couchbase/core/operations/management/collections_manifest_get.hxx +2 -0
  138. data/ext/couchbase/core/operations/management/error_utils.cxx +4 -1
  139. data/ext/couchbase/core/operations/management/eventing_deploy_function.hxx +2 -0
  140. data/ext/couchbase/core/operations/management/eventing_drop_function.hxx +2 -0
  141. data/ext/couchbase/core/operations/management/eventing_get_all_functions.hxx +2 -0
  142. data/ext/couchbase/core/operations/management/eventing_get_function.hxx +2 -0
  143. data/ext/couchbase/core/operations/management/eventing_get_status.hxx +2 -0
  144. data/ext/couchbase/core/operations/management/eventing_pause_function.hxx +2 -0
  145. data/ext/couchbase/core/operations/management/eventing_resume_function.hxx +2 -0
  146. data/ext/couchbase/core/operations/management/eventing_undeploy_function.hxx +2 -0
  147. data/ext/couchbase/core/operations/management/eventing_upsert_function.hxx +2 -0
  148. data/ext/couchbase/core/operations/management/freeform.hxx +2 -0
  149. data/ext/couchbase/core/operations/management/group_drop.hxx +2 -0
  150. data/ext/couchbase/core/operations/management/group_get.hxx +2 -0
  151. data/ext/couchbase/core/operations/management/group_get_all.hxx +2 -0
  152. data/ext/couchbase/core/operations/management/group_upsert.hxx +2 -0
  153. data/ext/couchbase/core/operations/management/query_index_build.hxx +2 -0
  154. data/ext/couchbase/core/operations/management/query_index_build_deferred.hxx +68 -30
  155. data/ext/couchbase/core/operations/management/query_index_create.hxx +2 -0
  156. data/ext/couchbase/core/operations/management/query_index_drop.hxx +2 -0
  157. data/ext/couchbase/core/operations/management/query_index_get_all.hxx +4 -3
  158. data/ext/couchbase/core/operations/management/query_index_get_all_deferred.hxx +2 -1
  159. data/ext/couchbase/core/operations/management/role_get_all.hxx +2 -0
  160. data/ext/couchbase/core/operations/management/scope_create.hxx +2 -0
  161. data/ext/couchbase/core/operations/management/scope_drop.hxx +2 -0
  162. data/ext/couchbase/core/operations/management/scope_get_all.hxx +2 -0
  163. data/ext/couchbase/core/operations/management/search_get_stats.hxx +2 -0
  164. data/ext/couchbase/core/operations/management/search_index_analyze_document.hxx +2 -0
  165. data/ext/couchbase/core/operations/management/search_index_control_ingest.hxx +2 -0
  166. data/ext/couchbase/core/operations/management/search_index_control_plan_freeze.hxx +2 -0
  167. data/ext/couchbase/core/operations/management/search_index_control_query.hxx +2 -0
  168. data/ext/couchbase/core/operations/management/search_index_drop.hxx +2 -0
  169. data/ext/couchbase/core/operations/management/search_index_get.hxx +2 -0
  170. data/ext/couchbase/core/operations/management/search_index_get_all.hxx +2 -0
  171. data/ext/couchbase/core/operations/management/search_index_get_documents_count.hxx +2 -0
  172. data/ext/couchbase/core/operations/management/search_index_get_stats.hxx +2 -0
  173. data/ext/couchbase/core/operations/management/search_index_upsert.hxx +2 -0
  174. data/ext/couchbase/core/operations/management/user_drop.hxx +2 -0
  175. data/ext/couchbase/core/operations/management/user_get.hxx +2 -0
  176. data/ext/couchbase/core/operations/management/user_get_all.hxx +2 -0
  177. data/ext/couchbase/core/operations/management/user_upsert.hxx +2 -0
  178. data/ext/couchbase/core/operations/management/view_index_drop.hxx +2 -0
  179. data/ext/couchbase/core/operations/management/view_index_get.hxx +2 -0
  180. data/ext/couchbase/core/operations/management/view_index_get_all.hxx +2 -0
  181. data/ext/couchbase/core/operations/management/view_index_upsert.hxx +2 -0
  182. data/ext/couchbase/core/operations/operation_traits.hxx +6 -0
  183. data/ext/couchbase/core/operations.hxx +0 -1
  184. data/ext/couchbase/core/operations_fwd.hxx +8 -0
  185. data/ext/couchbase/core/origin.cxx +67 -12
  186. data/ext/couchbase/core/origin.hxx +13 -8
  187. data/ext/couchbase/core/orphan_reporter.cxx +164 -0
  188. data/ext/couchbase/core/orphan_reporter.hxx +65 -0
  189. data/ext/couchbase/core/sasl/CMakeLists.txt +1 -0
  190. data/ext/couchbase/core/sasl/client.cc +6 -0
  191. data/ext/couchbase/core/sasl/mechanism.cc +2 -1
  192. data/ext/couchbase/core/sasl/mechanism.h +2 -1
  193. data/ext/couchbase/core/sasl/oauthbearer/oauthbearer.cc +41 -0
  194. data/ext/couchbase/core/sasl/oauthbearer/oauthbearer.h +47 -0
  195. data/ext/couchbase/core/tls_context_provider.cxx +44 -0
  196. data/ext/couchbase/core/tls_context_provider.hxx +44 -0
  197. data/ext/couchbase/core/tracing/attribute_helpers.hxx +45 -0
  198. data/ext/couchbase/core/tracing/constants.hxx +148 -68
  199. data/ext/couchbase/core/tracing/threshold_logging_options.hxx +0 -3
  200. data/ext/couchbase/core/tracing/threshold_logging_tracer.cxx +122 -170
  201. data/ext/couchbase/core/tracing/tracer_wrapper.cxx +17 -24
  202. data/ext/couchbase/core/tracing/tracer_wrapper.hxx +8 -10
  203. data/ext/couchbase/core/tracing/wrapper_sdk_tracer.cxx +114 -0
  204. data/ext/couchbase/core/tracing/wrapper_sdk_tracer.hxx +85 -0
  205. data/ext/couchbase/core/transactions/attempt_context_impl.cxx +16 -14
  206. data/ext/couchbase/core/transactions/attempt_context_impl.hxx +4 -4
  207. data/ext/couchbase/core/transactions/transactions.cxx +1 -1
  208. data/ext/couchbase/core/transactions/transactions_cleanup.cxx +1 -2
  209. data/ext/couchbase/core/utils/byteswap.hxx +12 -0
  210. data/ext/couchbase/core/utils/concurrent_fixed_priority_queue.hxx +102 -0
  211. data/ext/couchbase/core/utils/connection_string.cxx +2 -0
  212. data/ext/couchbase/couchbase/certificate_authenticator.hxx +1 -0
  213. data/ext/couchbase/couchbase/cluster.hxx +47 -0
  214. data/ext/couchbase/couchbase/cluster_options.hxx +16 -0
  215. data/ext/couchbase/couchbase/collection.hxx +60 -15
  216. data/ext/couchbase/couchbase/error_codes.hxx +48 -48
  217. data/ext/couchbase/couchbase/jwt_authenticator.hxx +52 -0
  218. data/ext/couchbase/couchbase/metrics/meter.hxx +2 -1
  219. data/ext/couchbase/couchbase/metrics/otel_meter.hxx +75 -80
  220. data/ext/couchbase/couchbase/network_options.hxx +19 -0
  221. data/ext/couchbase/couchbase/password_authenticator.hxx +1 -0
  222. data/ext/couchbase/couchbase/tracing/otel_tracer.hxx +15 -17
  223. data/ext/couchbase/couchbase/tracing/request_span.hxx +2 -2
  224. data/ext/couchbase.cxx +4 -0
  225. data/ext/extconf.rb +1 -0
  226. data/ext/rcb_analytics.cxx +157 -47
  227. data/ext/rcb_backend.cxx +118 -71
  228. data/ext/rcb_buckets.cxx +39 -16
  229. data/ext/rcb_collections.cxx +36 -12
  230. data/ext/rcb_crud.cxx +587 -294
  231. data/ext/rcb_hdr_histogram.cxx +219 -0
  232. data/ext/rcb_hdr_histogram.hxx +28 -0
  233. data/ext/rcb_multi.cxx +142 -59
  234. data/ext/rcb_observability.cxx +132 -0
  235. data/ext/rcb_observability.hxx +49 -0
  236. data/ext/rcb_query.cxx +77 -27
  237. data/ext/rcb_search.cxx +92 -31
  238. data/ext/rcb_users.cxx +69 -26
  239. data/ext/rcb_utils.cxx +91 -0
  240. data/ext/rcb_utils.hxx +141 -168
  241. data/ext/rcb_views.cxx +36 -12
  242. data/lib/active_support/cache/couchbase_store.rb +6 -6
  243. data/lib/couchbase/authenticator.rb +14 -0
  244. data/lib/couchbase/binary_collection.rb +37 -22
  245. data/lib/couchbase/bucket.rb +46 -31
  246. data/lib/couchbase/cluster.rb +146 -61
  247. data/lib/couchbase/collection.rb +257 -186
  248. data/lib/couchbase/datastructures/couchbase_list.rb +81 -50
  249. data/lib/couchbase/datastructures/couchbase_map.rb +86 -50
  250. data/lib/couchbase/datastructures/couchbase_queue.rb +64 -38
  251. data/lib/couchbase/datastructures/couchbase_set.rb +57 -41
  252. data/lib/couchbase/deprecations.rb +1 -1
  253. data/lib/couchbase/diagnostics.rb +8 -8
  254. data/lib/couchbase/errors.rb +6 -0
  255. data/lib/couchbase/management/analytics_index_manager.rb +90 -59
  256. data/lib/couchbase/management/bucket_manager.rb +73 -45
  257. data/lib/couchbase/management/collection_manager.rb +86 -43
  258. data/lib/couchbase/management/collection_query_index_manager.rb +56 -33
  259. data/lib/couchbase/management/query_index_manager.rb +88 -36
  260. data/lib/couchbase/management/scope_search_index_manager.rb +119 -52
  261. data/lib/couchbase/management/search_index_manager.rb +401 -178
  262. data/lib/couchbase/management/user_manager.rb +343 -174
  263. data/lib/couchbase/management/view_index_manager.rb +166 -73
  264. data/lib/couchbase/metrics/logging_meter.rb +108 -0
  265. data/lib/couchbase/metrics/logging_value_recorder.rb +50 -0
  266. data/lib/couchbase/metrics/meter.rb +27 -0
  267. data/lib/couchbase/metrics/noop_meter.rb +30 -0
  268. data/lib/couchbase/metrics/noop_value_recorder.rb +27 -0
  269. data/lib/couchbase/metrics/value_recorder.rb +25 -0
  270. data/lib/couchbase/options.rb +69 -3
  271. data/lib/couchbase/protostellar/cluster.rb +3 -0
  272. data/lib/couchbase/scope.rb +62 -48
  273. data/lib/couchbase/search_options.rb +18 -18
  274. data/lib/couchbase/tracing/noop_span.rb +29 -0
  275. data/lib/couchbase/tracing/noop_tracer.rb +29 -0
  276. data/lib/couchbase/tracing/request_span.rb +34 -0
  277. data/lib/couchbase/tracing/request_tracer.rb +28 -0
  278. data/lib/couchbase/tracing/threshold_logging_span.rb +112 -0
  279. data/lib/couchbase/tracing/threshold_logging_tracer.rb +231 -0
  280. data/lib/couchbase/utils/hdr_histogram.rb +55 -0
  281. data/lib/couchbase/utils/observability.rb +257 -0
  282. data/lib/couchbase/utils/observability_constants.rb +200 -0
  283. data/lib/couchbase/utils/stdlib_logger_adapter.rb +1 -3
  284. data/lib/couchbase/version.rb +1 -1
  285. data/lib/couchbase.rb +2 -2
  286. metadata +58 -6
@@ -1672,7 +1672,7 @@ module Couchbase
1672
1672
  # @see .Cluster
1673
1673
  #
1674
1674
  class Cluster
1675
- attr_accessor :authenticator # @return [PasswordAuthenticator, CertificateAuthenticator]
1675
+ attr_accessor :authenticator # @return [PasswordAuthenticator, CertificateAuthenticator, JWTAuthenticator]
1676
1676
 
1677
1677
  attr_accessor :preferred_server_group # @return [String]
1678
1678
 
@@ -1706,6 +1706,13 @@ module Couchbase
1706
1706
  attr_accessor :config_idle_redial_timeout # @return [nil, Integer, #in_milliseconds]
1707
1707
  attr_accessor :idle_http_connection_timeout # @return [nil, Integer, #in_milliseconds]
1708
1708
 
1709
+ # @return [ApplicationTelemetry]
1710
+ # @!macro volatile
1711
+ attr_accessor :application_telemetry
1712
+
1713
+ attr_accessor :tracer # @return [nil, Tracing::RequestTracer]
1714
+ attr_accessor :meter # @return [nil, Metrics::Meter]
1715
+
1709
1716
  # Creates an instance of options for {Couchbase::Cluster.connect}
1710
1717
  #
1711
1718
  # @param [PasswordAuthenticator, CertificateAuthenticator] authenticator
@@ -1720,7 +1727,7 @@ module Couchbase
1720
1727
  # @see .Cluster
1721
1728
  #
1722
1729
  # @yieldparam [Cluster] self
1723
- def initialize(authenticator: nil,
1730
+ def initialize(authenticator: nil, # rubocop:disable Metrics/ParameterLists
1724
1731
  preferred_server_group: nil,
1725
1732
  enable_metrics: nil,
1726
1733
  metrics_emit_interval: nil,
@@ -1749,7 +1756,10 @@ module Couchbase
1749
1756
  config_poll_interval: nil,
1750
1757
  config_poll_floor: nil,
1751
1758
  config_idle_redial_timeout: nil,
1752
- idle_http_connection_timeout: nil)
1759
+ idle_http_connection_timeout: nil,
1760
+ tracer: nil,
1761
+ meter: nil,
1762
+ application_telemetry: ApplicationTelemetry.new)
1753
1763
  @authenticator = authenticator
1754
1764
  @preferred_server_group = preferred_server_group
1755
1765
  @enable_metrics = enable_metrics
@@ -1780,6 +1790,10 @@ module Couchbase
1780
1790
  @config_poll_floor = config_poll_floor
1781
1791
  @config_idle_redial_timeout = config_idle_redial_timeout
1782
1792
  @idle_http_connection_timeout = idle_http_connection_timeout
1793
+ @tracer = tracer
1794
+ @meter = meter
1795
+ @application_telemetry = application_telemetry
1796
+
1783
1797
  yield self if block_given?
1784
1798
  end
1785
1799
 
@@ -1826,8 +1840,60 @@ module Couchbase
1826
1840
  config_poll_floor: Utils::Time.extract_duration(@config_poll_floor),
1827
1841
  config_idle_redial_timeout: Utils::Time.extract_duration(@config_idle_redial_timeout),
1828
1842
  idle_http_connection_timeout: Utils::Time.extract_duration(@idle_http_connection_timeout),
1843
+ application_telemetry: @application_telemetry.to_backend,
1829
1844
  }
1830
1845
  end
1846
+
1847
+ # Application Telemetry Options for {Couchbase::Cluster.connect}. Part of {Couchbase::Options::Cluster}
1848
+ #
1849
+ # @see Options::Cluster#application_telemetry
1850
+ #
1851
+ # @!macro volatile
1852
+ class ApplicationTelemetry
1853
+ attr_accessor :enable # @return [nil, Boolean]
1854
+ attr_accessor :override_endpoint # @return [nil, String]
1855
+ attr_accessor :backoff # @return [nil, Integer, #in_milliseconds]
1856
+ attr_accessor :ping_interval # @return [nil, Integer, #in_milliseconds]
1857
+ attr_accessor :ping_timeout # @return [nil, Integer, #in_milliseconds]
1858
+
1859
+ # Creates an instance of app telemetry options for {Couchbase::Cluster.connect}.
1860
+ # Part of {Couchbase::Options::Cluster}.
1861
+ #
1862
+ # @param [nil, Boolean] enable whether to enable application telemetry capture.
1863
+ # Application telemetry is enabled by default.
1864
+ # @param [nil, String] override_endpoint overrides the default endpoint used for application service telemetry
1865
+ # The endpoint must use the WebSocket protocol and the string should start with `ws://`.
1866
+ # @param [nil, Integer, #in_milliseconds] backoff specifies the duration to wait between connection attempts
1867
+ # to an application telemetry endpoint
1868
+ # @param [nil, Integer, #in_milliseconds] ping_interval specifies how often the SDK should ping the application
1869
+ # service telemetry collector
1870
+ # @param [nil, Integer, #in_milliseconds] ping_timeout specifies how long the SDK should wait for a ping
1871
+ # response (pong) from the application service collector, before closing the connection and attempting to reconnect
1872
+ def initialize(enable: nil,
1873
+ override_endpoint: nil,
1874
+ backoff: nil,
1875
+ ping_interval: nil,
1876
+ ping_timeout: nil)
1877
+ @enable = enable
1878
+ @override_endpoint = override_endpoint
1879
+ @backoff = backoff
1880
+ @ping_interval = ping_interval
1881
+ @ping_timeout = ping_timeout
1882
+
1883
+ yield self if block_given?
1884
+ end
1885
+
1886
+ # @api private
1887
+ def to_backend
1888
+ {
1889
+ enable: @enable,
1890
+ override_endpoint: @override_endpoint,
1891
+ backoff: Utils::Time.extract_duration(@backoff),
1892
+ ping_interval: Utils::Time.extract_duration(@ping_interval),
1893
+ ping_timeout: Utils::Time.extract_duration(@ping_timeout),
1894
+ }
1895
+ end
1896
+ end
1831
1897
  end
1832
1898
 
1833
1899
  # Options for {Couchbase::Cluster#diagnostics}
@@ -79,6 +79,9 @@ module Couchbase
79
79
  when Couchbase::CertificateAuthenticator
80
80
  raise Couchbase::Error::FeatureNotAvailable,
81
81
  "The #{Couchbase::Protostellar::NAME} protocol does not support the CertificateAuthenticator"
82
+ when Couchbase::JWTAuthenticator
83
+ raise Couchbase::Error::FeatureNotAvailable,
84
+ "The #{Couchbase::Protostellar::NAME} protocol does not support the JWTAuthenticator"
82
85
  else
83
86
  raise ArgumentError, "options must have authenticator configured"
84
87
  end
@@ -29,10 +29,11 @@ module Couchbase
29
29
  # @param [Couchbase::Backend] backend
30
30
  # @param [String] bucket_name name of the bucket
31
31
  # @param [String] scope_name name of the scope
32
- def initialize(backend, bucket_name, scope_name)
32
+ def initialize(backend, bucket_name, scope_name, observability)
33
33
  @backend = backend
34
34
  @bucket_name = bucket_name
35
35
  @name = scope_name
36
+ @observability = observability
36
37
  end
37
38
 
38
39
  # Opens the default collection for this scope
@@ -41,7 +42,7 @@ module Couchbase
41
42
  #
42
43
  # @return [Collection]
43
44
  def collection(collection_name)
44
- Collection.new(@backend, @bucket_name, @name, collection_name)
45
+ Collection.new(@backend, @bucket_name, @name, collection_name, @observability)
45
46
  end
46
47
 
47
48
  # Performs a query against the query (N1QL) services.
@@ -60,30 +61,34 @@ module Couchbase
60
61
  #
61
62
  # @return [QueryResult]
62
63
  def query(statement, options = Options::Query::DEFAULT)
63
- resp = @backend.document_query(statement, options.to_backend(scope_name: @name, bucket_name: @bucket_name))
64
+ @observability.record_operation(Observability::OP_QUERY, options.parent_span, self, :query) do |obs_handler|
65
+ obs_handler.add_query_statement(statement, options)
64
66
 
65
- Cluster::QueryResult.new do |res|
66
- res.meta_data = Cluster::QueryMetaData.new do |meta|
67
- meta.status = resp[:meta][:status]
68
- meta.request_id = resp[:meta][:request_id]
69
- meta.client_context_id = resp[:meta][:client_context_id]
70
- meta.signature = JSON.parse(resp[:meta][:signature]) if resp[:meta][:signature]
71
- meta.profile = JSON.parse(resp[:meta][:profile]) if resp[:meta][:profile]
72
- meta.metrics = Cluster::QueryMetrics.new do |metrics|
73
- if resp[:meta][:metrics]
74
- metrics.elapsed_time = resp[:meta][:metrics][:elapsed_time]
75
- metrics.execution_time = resp[:meta][:metrics][:execution_time]
76
- metrics.sort_count = resp[:meta][:metrics][:sort_count]
77
- metrics.result_count = resp[:meta][:metrics][:result_count]
78
- metrics.result_size = resp[:meta][:metrics][:result_size]
79
- metrics.mutation_count = resp[:meta][:metrics][:mutation_count]
80
- metrics.error_count = resp[:meta][:metrics][:error_count]
81
- metrics.warning_count = resp[:meta][:metrics][:warning_count]
67
+ resp = @backend.document_query(statement, options.to_backend(scope_name: @name, bucket_name: @bucket_name), obs_handler)
68
+
69
+ Cluster::QueryResult.new do |res|
70
+ res.meta_data = Cluster::QueryMetaData.new do |meta|
71
+ meta.status = resp[:meta][:status]
72
+ meta.request_id = resp[:meta][:request_id]
73
+ meta.client_context_id = resp[:meta][:client_context_id]
74
+ meta.signature = JSON.parse(resp[:meta][:signature]) if resp[:meta][:signature]
75
+ meta.profile = JSON.parse(resp[:meta][:profile]) if resp[:meta][:profile]
76
+ meta.metrics = Cluster::QueryMetrics.new do |metrics|
77
+ if resp[:meta][:metrics]
78
+ metrics.elapsed_time = resp[:meta][:metrics][:elapsed_time]
79
+ metrics.execution_time = resp[:meta][:metrics][:execution_time]
80
+ metrics.sort_count = resp[:meta][:metrics][:sort_count]
81
+ metrics.result_count = resp[:meta][:metrics][:result_count]
82
+ metrics.result_size = resp[:meta][:metrics][:result_size]
83
+ metrics.mutation_count = resp[:meta][:metrics][:mutation_count]
84
+ metrics.error_count = resp[:meta][:metrics][:error_count]
85
+ metrics.warning_count = resp[:meta][:metrics][:warning_count]
86
+ end
82
87
  end
88
+ meta.warnings = resp[:warnings].map { |warn| Cluster::QueryWarning.new(warn[:code], warn[:message]) } if resp[:warnings]
83
89
  end
84
- meta.warnings = resp[:warnings].map { |warn| Cluster::QueryWarning.new(warn[:code], warn[:message]) } if resp[:warnings]
90
+ res.instance_variable_set(:@rows, resp[:rows])
85
91
  end
86
- res.instance_variable_set(:@rows, resp[:rows])
87
92
  end
88
93
  end
89
94
 
@@ -100,30 +105,34 @@ module Couchbase
100
105
  #
101
106
  # @return [AnalyticsResult]
102
107
  def analytics_query(statement, options = Options::Analytics::DEFAULT)
103
- resp = @backend.document_analytics(statement, options.to_backend(scope_name: @name, bucket_name: @bucket_name))
108
+ @observability.record_operation(Observability::OP_ANALYTICS_QUERY, options.parent_span, self, :analytics) do |obs_handler|
109
+ obs_handler.add_query_statement(statement, options)
110
+
111
+ resp = @backend.document_analytics(statement, options.to_backend(scope_name: @name, bucket_name: @bucket_name))
104
112
 
105
- Cluster::AnalyticsResult.new do |res|
106
- res.transcoder = options.transcoder
107
- res.meta_data = Cluster::AnalyticsMetaData.new do |meta|
108
- meta.status = resp[:meta][:status]
109
- meta.request_id = resp[:meta][:request_id]
110
- meta.client_context_id = resp[:meta][:client_context_id]
111
- meta.signature = JSON.parse(resp[:meta][:signature]) if resp[:meta][:signature]
112
- meta.profile = JSON.parse(resp[:meta][:profile]) if resp[:meta][:profile]
113
- meta.metrics = Cluster::AnalyticsMetrics.new do |metrics|
114
- if resp[:meta][:metrics]
115
- metrics.elapsed_time = resp[:meta][:metrics][:elapsed_time]
116
- metrics.execution_time = resp[:meta][:metrics][:execution_time]
117
- metrics.result_count = resp[:meta][:metrics][:result_count]
118
- metrics.result_size = resp[:meta][:metrics][:result_size]
119
- metrics.error_count = resp[:meta][:metrics][:error_count]
120
- metrics.warning_count = resp[:meta][:metrics][:warning_count]
121
- metrics.processed_objects = resp[:meta][:metrics][:processed_objects]
113
+ Cluster::AnalyticsResult.new do |res|
114
+ res.transcoder = options.transcoder
115
+ res.meta_data = Cluster::AnalyticsMetaData.new do |meta|
116
+ meta.status = resp[:meta][:status]
117
+ meta.request_id = resp[:meta][:request_id]
118
+ meta.client_context_id = resp[:meta][:client_context_id]
119
+ meta.signature = JSON.parse(resp[:meta][:signature]) if resp[:meta][:signature]
120
+ meta.profile = JSON.parse(resp[:meta][:profile]) if resp[:meta][:profile]
121
+ meta.metrics = Cluster::AnalyticsMetrics.new do |metrics|
122
+ if resp[:meta][:metrics]
123
+ metrics.elapsed_time = resp[:meta][:metrics][:elapsed_time]
124
+ metrics.execution_time = resp[:meta][:metrics][:execution_time]
125
+ metrics.result_count = resp[:meta][:metrics][:result_count]
126
+ metrics.result_size = resp[:meta][:metrics][:result_size]
127
+ metrics.error_count = resp[:meta][:metrics][:error_count]
128
+ metrics.warning_count = resp[:meta][:metrics][:warning_count]
129
+ metrics.processed_objects = resp[:meta][:metrics][:processed_objects]
130
+ end
122
131
  end
132
+ res[:warnings] = resp[:warnings].map { |warn| Cluster::AnalyticsWarning.new(warn[:code], warn[:message]) } if resp[:warnings]
123
133
  end
124
- res[:warnings] = resp[:warnings].map { |warn| Cluster::AnalyticsWarning.new(warn[:code], warn[:message]) } if resp[:warnings]
134
+ res.instance_variable_set(:@rows, resp[:rows])
125
135
  end
126
- res.instance_variable_set(:@rows, resp[:rows])
127
136
  end
128
137
  end
129
138
 
@@ -145,8 +154,10 @@ module Couchbase
145
154
  #
146
155
  # @return [SearchResult]
147
156
  def search_query(index_name, query, options = Options::Search::DEFAULT)
148
- resp = @backend.document_search(@bucket_name, @name, index_name, JSON.generate(query), {}, options.to_backend)
149
- convert_search_result(resp, options)
157
+ @observability.record_operation(Observability::OP_SEARCH_QUERY, options.parent_span, self, :search) do |obs_handler|
158
+ resp = @backend.document_search(@bucket_name, @name, index_name, JSON.generate(query), {}, options.to_backend, obs_handler)
159
+ convert_search_result(resp, options)
160
+ end
150
161
  end
151
162
 
152
163
  # Performs a request against the Full Text Search (FTS) service.
@@ -157,14 +168,17 @@ module Couchbase
157
168
  #
158
169
  # @return [SearchResult]
159
170
  def search(index_name, search_request, options = Options::Search::DEFAULT)
160
- encoded_query, encoded_req = search_request.to_backend
161
- resp = @backend.document_search(@bucket_name, @name, index_name, encoded_query, encoded_req, options.to_backend(show_request: false))
162
- convert_search_result(resp, options)
171
+ @observability.record_operation(Observability::OP_SEARCH_QUERY, options.parent_span, self, :search) do |obs_handler|
172
+ encoded_query, encoded_req = search_request.to_backend
173
+ resp = @backend.document_search(@bucket_name, @name, index_name, encoded_query, encoded_req,
174
+ options.to_backend(show_request: false), obs_handler)
175
+ convert_search_result(resp, options)
176
+ end
163
177
  end
164
178
 
165
179
  # @return [Management::ScopeSearchIndexManager]
166
180
  def search_indexes
167
- Management::ScopeSearchIndexManager.new(@backend, @bucket_name, @name)
181
+ Management::ScopeSearchIndexManager.new(@backend, @bucket_name, @name, @observability)
168
182
  end
169
183
 
170
184
  private
@@ -84,8 +84,8 @@ module Couchbase
84
84
  end
85
85
 
86
86
  # @return [String]
87
- def to_json(*args)
88
- to_h.to_json(*args)
87
+ def to_json(*)
88
+ to_h.to_json(*)
89
89
  end
90
90
 
91
91
  # Prepare {MatchQuery} body
@@ -1128,8 +1128,8 @@ module Couchbase
1128
1128
  end
1129
1129
 
1130
1130
  # @api private
1131
- def to_json(*args)
1132
- to_h.to_json(*args)
1131
+ def to_json(*)
1132
+ to_h.to_json(*)
1133
1133
  end
1134
1134
  end
1135
1135
 
@@ -1173,8 +1173,8 @@ module Couchbase
1173
1173
  end
1174
1174
 
1175
1175
  # @api private
1176
- def to_json(*args)
1177
- {by: :score, desc: desc}.to_json(*args)
1176
+ def to_json(*)
1177
+ {by: :score, desc: desc}.to_json(*)
1178
1178
  end
1179
1179
  end
1180
1180
 
@@ -1189,8 +1189,8 @@ module Couchbase
1189
1189
  end
1190
1190
 
1191
1191
  # @api private
1192
- def to_json(*args)
1193
- {by: :id, desc: desc}.to_json(*args)
1192
+ def to_json(*)
1193
+ {by: :id, desc: desc}.to_json(*)
1194
1194
  end
1195
1195
  end
1196
1196
 
@@ -1219,8 +1219,8 @@ module Couchbase
1219
1219
  end
1220
1220
 
1221
1221
  # @api private
1222
- def to_json(*args)
1223
- {by: :field, field: field, desc: desc, type: type, missing: missing, mode: mode}.to_json(*args)
1222
+ def to_json(*)
1223
+ {by: :field, field: field, desc: desc, type: type, missing: missing, mode: mode}.to_json(*)
1224
1224
  end
1225
1225
  end
1226
1226
 
@@ -1253,8 +1253,8 @@ module Couchbase
1253
1253
  end
1254
1254
 
1255
1255
  # @api private
1256
- def to_json(*args)
1257
- {by: :geo_distance, field: field, desc: desc, location: [longitude, latitude], unit: unit}.to_json(*args)
1256
+ def to_json(*)
1257
+ {by: :geo_distance, field: field, desc: desc, location: [longitude, latitude], unit: unit}.to_json(*)
1258
1258
  end
1259
1259
  end
1260
1260
  end
@@ -1292,8 +1292,8 @@ module Couchbase
1292
1292
  end
1293
1293
 
1294
1294
  # @api private
1295
- def to_json(*args)
1296
- {field: field, size: size}.to_json(*args)
1295
+ def to_json(*)
1296
+ {field: field, size: size}.to_json(*)
1297
1297
  end
1298
1298
  end
1299
1299
 
@@ -1319,8 +1319,8 @@ module Couchbase
1319
1319
  end
1320
1320
 
1321
1321
  # @api private
1322
- def to_json(*args)
1323
- {field: field, size: size, numeric_ranges: @ranges}.to_json(*args)
1322
+ def to_json(*)
1323
+ {field: field, size: size, numeric_ranges: @ranges}.to_json(*)
1324
1324
  end
1325
1325
  end
1326
1326
 
@@ -1351,8 +1351,8 @@ module Couchbase
1351
1351
  end
1352
1352
 
1353
1353
  # @api private
1354
- def to_json(*args)
1355
- {field: field, size: size, date_ranges: @ranges}.to_json(*args)
1354
+ def to_json(*)
1355
+ {field: field, size: size, date_ranges: @ranges}.to_json(*)
1356
1356
  end
1357
1357
  end
1358
1358
  end
@@ -0,0 +1,29 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright 2025-Present 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
+ require_relative 'request_span'
18
+
19
+ module Couchbase
20
+ module Tracing
21
+ class NoopSpan < RequestSpan
22
+ def set_attribute(*); end
23
+
24
+ def status=(*); end
25
+
26
+ def finish(*); end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,29 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright 2025-Present 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
+ require_relative 'noop_span'
18
+
19
+ module Couchbase
20
+ module Tracing
21
+ class NoopTracer < RequestTracer
22
+ def request_span(*)
23
+ SPAN_INSTANCE
24
+ end
25
+
26
+ SPAN_INSTANCE = NoopSpan.new.freeze
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,34 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright 2025-Present 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
+ module Couchbase
18
+ module Tracing
19
+ # @!macro volatile
20
+ class RequestSpan
21
+ def set_attribute(key, value)
22
+ raise NotImplementedError, "The RequestSpan does not implement #set_attribute"
23
+ end
24
+
25
+ def status=(status_code)
26
+ raise NotImplementedError, "The RequestSpan does not implement #status="
27
+ end
28
+
29
+ def finish(end_timestamp: nil)
30
+ raise NotImplementedError, "The RequestSpan does not implement #finish"
31
+ end
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,28 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright 2025-Present 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
+ module Couchbase
18
+ module Tracing
19
+ # @!macro volatile
20
+ class RequestTracer
21
+ def request_span(name, parent: nil, start_timestamp: nil)
22
+ raise NotImplementedError, "The tracer does not implement #request_span"
23
+ end
24
+
25
+ def close; end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,112 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright 2025-Present 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
+ require 'couchbase/tracing/request_span'
18
+ require 'couchbase/utils/observability_constants'
19
+
20
+ module Couchbase
21
+ module Tracing
22
+ class ThresholdLoggingSpan < RequestSpan
23
+ attr_accessor :name
24
+ attr_accessor :should_report
25
+ attr_accessor :service
26
+ attr_accessor :encode_duration_us
27
+ attr_accessor :last_dispatch_duration_us
28
+ attr_accessor :total_dispatch_duration_us
29
+ attr_accessor :last_server_duration_us
30
+ attr_accessor :total_server_duration_us
31
+ attr_accessor :last_local_id
32
+ attr_accessor :operation_id
33
+ attr_accessor :last_peer_address
34
+ attr_accessor :last_peer_port
35
+
36
+ def initialize(name, start_timestamp: nil, parent: nil, tracer: nil)
37
+ super()
38
+ @name = name
39
+ @parent = parent
40
+ @tracer = tracer
41
+
42
+ @start_timestamp = if start_timestamp.nil?
43
+ Time.now
44
+ else
45
+ start_timestamp
46
+ end
47
+ end
48
+
49
+ def set_attribute(key, value)
50
+ case key
51
+ when Observability::ATTR_OPERATION_ID
52
+ @operation_id = value
53
+ when Observability::ATTR_LOCAL_ID
54
+ @last_local_id = value
55
+ when Observability::ATTR_PEER_ADDRESS
56
+ @last_peer_address = value
57
+ when Observability::ATTR_PEER_PORT
58
+ @last_peer_port = value
59
+ when Observability::ATTR_SERVICE
60
+ @service = value
61
+ when Observability::ATTR_SERVER_DURATION
62
+ @last_server_duration_us = value
63
+ end
64
+ end
65
+
66
+ def status=(*); end
67
+
68
+ def finish(end_timestamp: nil)
69
+ duration_us = (((end_timestamp || Time.now) - @start_timestamp) * 1_000_000).round
70
+ case name
71
+ when Observability::STEP_REQUEST_ENCODING
72
+ return if @parent.nil?
73
+
74
+ @parent.should_report = true
75
+ @parent.encode_duration_us = duration_us
76
+ when Observability::STEP_DISPATCH_TO_SERVER
77
+ return if @parent.nil?
78
+
79
+ @parent.should_report = true
80
+ @parent.last_dispatch_duration_us = duration_us
81
+ @parent.total_dispatch_duration_us = 0 if @parent.total_dispatch_duration_us.nil?
82
+ @parent.total_dispatch_duration_us += duration_us
83
+ unless @last_server_duration_us.nil?
84
+ @parent.last_server_duration_us = @last_server_duration_us
85
+ @parent.total_server_duration_us = 0 if @parent.total_server_duration_us.nil?
86
+ @parent.total_server_duration_us += @last_server_duration_us
87
+ end
88
+ @parent.last_local_id = @last_local_id
89
+ @parent.operation_id = @operation_id
90
+ @parent.last_peer_address = @last_peer_address
91
+ @parent.last_peer_port = @last_peer_port
92
+ else
93
+ @should_report ||= @parent.nil?
94
+ return unless @should_report && !@service.nil?
95
+
96
+ @tracer.record_operation(@service, ThresholdLoggingTracer::Item.new(
97
+ total_duration_us: duration_us,
98
+ encode_duration_us: @encode_duration_us,
99
+ last_dispatch_duration_us: @last_dispatch_duration_us,
100
+ total_dispatch_duration_us: @total_dispatch_duration_us,
101
+ last_server_duration_us: @last_server_duration_us,
102
+ total_server_duration_us: @total_server_duration_us,
103
+ operation_name: @name,
104
+ last_local_id: @last_local_id,
105
+ operation_id: @operation_id,
106
+ last_remote_socket: "#{@last_peer_address}:#{@last_peer_port}",
107
+ ))
108
+ end
109
+ end
110
+ end
111
+ end
112
+ end