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.
- checksums.yaml +4 -4
- data/README.md +3 -3
- data/ext/CMakeLists.txt +4 -1
- data/ext/cache/extconf_include.rb +4 -3
- data/ext/cache/mozilla-ca-bundle.crt +66 -93
- data/ext/cache/mozilla-ca-bundle.sha256 +1 -1
- data/ext/couchbase/CMakeLists.txt +24 -11
- data/ext/couchbase/cmake/APKBUILD.in +17 -1
- data/ext/couchbase/cmake/Bundler.cmake +9 -1
- data/ext/couchbase/cmake/Cache.cmake +48 -19
- data/ext/couchbase/cmake/CompilerOptions.cmake +3 -1
- data/ext/couchbase/cmake/OpenSSL.cmake +10 -2
- data/ext/couchbase/cmake/Packaging.cmake +48 -8
- data/ext/couchbase/cmake/ThirdPartyDependencies.cmake +43 -1
- data/ext/couchbase/cmake/build_config.hxx.in +2 -0
- data/ext/couchbase/cmake/couchbase-cxx-client.spec.in +18 -0
- data/ext/couchbase/cmake/tarball_glob.txt +10 -0
- data/ext/couchbase/core/app_telemetry_meter.cxx +1 -0
- data/ext/couchbase/core/app_telemetry_reporter.cxx +45 -43
- data/ext/couchbase/core/app_telemetry_reporter.hxx +4 -3
- data/ext/couchbase/core/bucket.cxx +128 -13
- data/ext/couchbase/core/bucket.hxx +12 -2
- data/ext/couchbase/core/cluster.cxx +304 -152
- data/ext/couchbase/core/cluster.hxx +32 -0
- data/ext/couchbase/core/cluster_credentials.cxx +25 -0
- data/ext/couchbase/core/cluster_credentials.hxx +5 -0
- data/ext/couchbase/core/cluster_label_listener.cxx +72 -0
- data/ext/couchbase/core/cluster_label_listener.hxx +46 -0
- data/ext/couchbase/core/cluster_options.hxx +4 -0
- data/ext/couchbase/core/deprecation_utils.hxx +26 -0
- data/ext/couchbase/core/error.hxx +27 -0
- data/ext/couchbase/core/free_form_http_request.hxx +0 -2
- data/ext/couchbase/core/http_component.cxx +12 -48
- data/ext/couchbase/core/impl/analytics.cxx +3 -2
- data/ext/couchbase/core/impl/analytics.hxx +2 -1
- data/ext/couchbase/core/impl/analytics_index_manager.cxx +249 -137
- data/ext/couchbase/core/impl/binary_collection.cxx +134 -58
- data/ext/couchbase/core/impl/bucket_manager.cxx +87 -35
- data/ext/couchbase/core/impl/collection.cxx +560 -245
- data/ext/couchbase/core/impl/collection_manager.cxx +89 -49
- data/ext/couchbase/core/impl/dns_srv_tracker.cxx +4 -4
- data/ext/couchbase/core/impl/error.cxx +20 -13
- data/ext/couchbase/core/impl/error.hxx +15 -10
- data/ext/couchbase/core/impl/get_all_replicas.hxx +1 -1
- data/ext/couchbase/core/impl/get_any_replica.hxx +2 -1
- data/ext/couchbase/core/impl/get_replica.hxx +2 -0
- data/ext/couchbase/core/impl/lookup_in_replica.hxx +1 -1
- data/ext/couchbase/core/impl/observability_recorder.cxx +161 -0
- data/ext/couchbase/core/impl/observability_recorder.hxx +77 -0
- data/ext/couchbase/core/impl/observe_seqno.hxx +2 -0
- data/ext/couchbase/core/impl/public_bucket.cxx +31 -7
- data/ext/couchbase/core/impl/public_cluster.cxx +107 -19
- data/ext/couchbase/core/impl/query.cxx +6 -3
- data/ext/couchbase/core/impl/query.hxx +3 -1
- data/ext/couchbase/core/impl/query_index_manager.cxx +267 -102
- data/ext/couchbase/core/impl/scope.cxx +53 -11
- data/ext/couchbase/core/impl/search.cxx +8 -4
- data/ext/couchbase/core/impl/search.hxx +6 -2
- data/ext/couchbase/core/impl/search_index_manager.cxx +131 -41
- data/ext/couchbase/core/impl/with_cancellation.hxx +75 -0
- data/ext/couchbase/core/io/config_tracker.cxx +9 -9
- data/ext/couchbase/core/io/config_tracker.hxx +2 -1
- data/ext/couchbase/core/io/http_command.hxx +98 -49
- data/ext/couchbase/core/io/http_context.hxx +2 -0
- data/ext/couchbase/core/io/http_session.cxx +23 -10
- data/ext/couchbase/core/io/http_session.hxx +17 -9
- data/ext/couchbase/core/io/http_session_manager.hxx +163 -228
- data/ext/couchbase/core/io/http_traits.hxx +0 -7
- data/ext/couchbase/core/io/mcbp_command.hxx +123 -44
- data/ext/couchbase/core/io/mcbp_session.cxx +251 -26
- data/ext/couchbase/core/io/mcbp_session.hxx +9 -1
- data/ext/couchbase/core/io/mcbp_traits.hxx +0 -8
- data/ext/couchbase/core/io/streams.cxx +3 -3
- data/ext/couchbase/core/io/streams.hxx +3 -2
- data/ext/couchbase/core/meta/features.hxx +15 -0
- data/ext/couchbase/core/meta/version.cxx +13 -0
- data/ext/couchbase/core/meta/version.hxx +3 -0
- data/ext/couchbase/core/metrics/constants.hxx +23 -0
- data/ext/couchbase/core/metrics/logging_meter.cxx +5 -5
- data/ext/couchbase/core/metrics/meter_wrapper.cxx +65 -63
- data/ext/couchbase/core/metrics/meter_wrapper.hxx +12 -10
- data/ext/couchbase/core/operations/document_analytics.hxx +0 -5
- data/ext/couchbase/core/operations/document_append.hxx +0 -4
- data/ext/couchbase/core/operations/document_decrement.hxx +0 -5
- data/ext/couchbase/core/operations/document_exists.hxx +0 -7
- data/ext/couchbase/core/operations/document_get.hxx +0 -7
- data/ext/couchbase/core/operations/document_get_all_replicas.hxx +77 -27
- data/ext/couchbase/core/operations/document_get_and_lock.hxx +0 -9
- data/ext/couchbase/core/operations/document_get_and_touch.hxx +0 -9
- data/ext/couchbase/core/operations/document_get_any_replica.hxx +83 -2
- data/ext/couchbase/core/operations/document_get_projected.hxx +0 -9
- data/ext/couchbase/core/operations/document_increment.hxx +0 -5
- data/ext/couchbase/core/operations/document_insert.hxx +0 -4
- data/ext/couchbase/core/operations/document_lookup_in.hxx +0 -9
- data/ext/couchbase/core/operations/document_lookup_in_all_replicas.hxx +46 -4
- data/ext/couchbase/core/operations/document_lookup_in_any_replica.hxx +121 -43
- data/ext/couchbase/core/operations/document_mutate_in.hxx +0 -5
- data/ext/couchbase/core/operations/document_prepend.hxx +0 -4
- data/ext/couchbase/core/operations/document_query.hxx +0 -4
- data/ext/couchbase/core/operations/document_remove.hxx +0 -4
- data/ext/couchbase/core/operations/document_replace.hxx +0 -4
- data/ext/couchbase/core/operations/document_search.hxx +0 -7
- data/ext/couchbase/core/operations/document_touch.hxx +0 -7
- data/ext/couchbase/core/operations/document_unlock.hxx +0 -6
- data/ext/couchbase/core/operations/document_upsert.hxx +0 -4
- data/ext/couchbase/core/operations/document_view.cxx +2 -0
- data/ext/couchbase/core/operations/document_view.hxx +10 -13
- data/ext/couchbase/core/operations/http_noop.hxx +2 -0
- data/ext/couchbase/core/operations/management/analytics_dataset_create.hxx +2 -0
- data/ext/couchbase/core/operations/management/analytics_dataset_drop.hxx +2 -0
- data/ext/couchbase/core/operations/management/analytics_dataset_get_all.hxx +2 -0
- data/ext/couchbase/core/operations/management/analytics_dataverse_create.hxx +2 -0
- data/ext/couchbase/core/operations/management/analytics_dataverse_drop.hxx +2 -0
- data/ext/couchbase/core/operations/management/analytics_get_pending_mutations.hxx +2 -0
- data/ext/couchbase/core/operations/management/analytics_index_create.hxx +2 -0
- data/ext/couchbase/core/operations/management/analytics_index_drop.hxx +2 -0
- data/ext/couchbase/core/operations/management/analytics_index_get_all.hxx +2 -0
- data/ext/couchbase/core/operations/management/analytics_link_connect.hxx +2 -0
- data/ext/couchbase/core/operations/management/analytics_link_create.hxx +2 -0
- data/ext/couchbase/core/operations/management/analytics_link_disconnect.hxx +2 -0
- data/ext/couchbase/core/operations/management/analytics_link_drop.hxx +2 -0
- data/ext/couchbase/core/operations/management/analytics_link_get_all.hxx +2 -0
- data/ext/couchbase/core/operations/management/analytics_link_replace.hxx +2 -0
- data/ext/couchbase/core/operations/management/bucket_create.hxx +2 -0
- data/ext/couchbase/core/operations/management/bucket_describe.hxx +2 -0
- data/ext/couchbase/core/operations/management/bucket_drop.hxx +2 -0
- data/ext/couchbase/core/operations/management/bucket_flush.hxx +2 -0
- data/ext/couchbase/core/operations/management/bucket_get.hxx +2 -0
- data/ext/couchbase/core/operations/management/bucket_get_all.hxx +2 -0
- data/ext/couchbase/core/operations/management/bucket_update.hxx +2 -0
- data/ext/couchbase/core/operations/management/change_password.hxx +2 -0
- data/ext/couchbase/core/operations/management/cluster_describe.hxx +2 -0
- data/ext/couchbase/core/operations/management/cluster_developer_preview_enable.hxx +2 -0
- data/ext/couchbase/core/operations/management/collection_create.hxx +2 -0
- data/ext/couchbase/core/operations/management/collection_drop.hxx +2 -0
- data/ext/couchbase/core/operations/management/collection_update.hxx +2 -0
- data/ext/couchbase/core/operations/management/collections_manifest_get.hxx +2 -0
- data/ext/couchbase/core/operations/management/error_utils.cxx +4 -1
- data/ext/couchbase/core/operations/management/eventing_deploy_function.hxx +2 -0
- data/ext/couchbase/core/operations/management/eventing_drop_function.hxx +2 -0
- data/ext/couchbase/core/operations/management/eventing_get_all_functions.hxx +2 -0
- data/ext/couchbase/core/operations/management/eventing_get_function.hxx +2 -0
- data/ext/couchbase/core/operations/management/eventing_get_status.hxx +2 -0
- data/ext/couchbase/core/operations/management/eventing_pause_function.hxx +2 -0
- data/ext/couchbase/core/operations/management/eventing_resume_function.hxx +2 -0
- data/ext/couchbase/core/operations/management/eventing_undeploy_function.hxx +2 -0
- data/ext/couchbase/core/operations/management/eventing_upsert_function.hxx +2 -0
- data/ext/couchbase/core/operations/management/freeform.hxx +2 -0
- data/ext/couchbase/core/operations/management/group_drop.hxx +2 -0
- data/ext/couchbase/core/operations/management/group_get.hxx +2 -0
- data/ext/couchbase/core/operations/management/group_get_all.hxx +2 -0
- data/ext/couchbase/core/operations/management/group_upsert.hxx +2 -0
- data/ext/couchbase/core/operations/management/query_index_build.hxx +2 -0
- data/ext/couchbase/core/operations/management/query_index_build_deferred.hxx +68 -30
- data/ext/couchbase/core/operations/management/query_index_create.hxx +2 -0
- data/ext/couchbase/core/operations/management/query_index_drop.hxx +2 -0
- data/ext/couchbase/core/operations/management/query_index_get_all.hxx +4 -3
- data/ext/couchbase/core/operations/management/query_index_get_all_deferred.hxx +2 -1
- data/ext/couchbase/core/operations/management/role_get_all.hxx +2 -0
- data/ext/couchbase/core/operations/management/scope_create.hxx +2 -0
- data/ext/couchbase/core/operations/management/scope_drop.hxx +2 -0
- data/ext/couchbase/core/operations/management/scope_get_all.hxx +2 -0
- data/ext/couchbase/core/operations/management/search_get_stats.hxx +2 -0
- data/ext/couchbase/core/operations/management/search_index_analyze_document.hxx +2 -0
- data/ext/couchbase/core/operations/management/search_index_control_ingest.hxx +2 -0
- data/ext/couchbase/core/operations/management/search_index_control_plan_freeze.hxx +2 -0
- data/ext/couchbase/core/operations/management/search_index_control_query.hxx +2 -0
- data/ext/couchbase/core/operations/management/search_index_drop.hxx +2 -0
- data/ext/couchbase/core/operations/management/search_index_get.hxx +2 -0
- data/ext/couchbase/core/operations/management/search_index_get_all.hxx +2 -0
- data/ext/couchbase/core/operations/management/search_index_get_documents_count.hxx +2 -0
- data/ext/couchbase/core/operations/management/search_index_get_stats.hxx +2 -0
- data/ext/couchbase/core/operations/management/search_index_upsert.hxx +2 -0
- data/ext/couchbase/core/operations/management/user_drop.hxx +2 -0
- data/ext/couchbase/core/operations/management/user_get.hxx +2 -0
- data/ext/couchbase/core/operations/management/user_get_all.hxx +2 -0
- data/ext/couchbase/core/operations/management/user_upsert.hxx +2 -0
- data/ext/couchbase/core/operations/management/view_index_drop.hxx +2 -0
- data/ext/couchbase/core/operations/management/view_index_get.hxx +2 -0
- data/ext/couchbase/core/operations/management/view_index_get_all.hxx +2 -0
- data/ext/couchbase/core/operations/management/view_index_upsert.hxx +2 -0
- data/ext/couchbase/core/operations/operation_traits.hxx +6 -0
- data/ext/couchbase/core/operations.hxx +0 -1
- data/ext/couchbase/core/operations_fwd.hxx +8 -0
- data/ext/couchbase/core/origin.cxx +67 -12
- data/ext/couchbase/core/origin.hxx +13 -8
- data/ext/couchbase/core/orphan_reporter.cxx +164 -0
- data/ext/couchbase/core/orphan_reporter.hxx +65 -0
- data/ext/couchbase/core/sasl/CMakeLists.txt +1 -0
- data/ext/couchbase/core/sasl/client.cc +6 -0
- data/ext/couchbase/core/sasl/mechanism.cc +2 -1
- data/ext/couchbase/core/sasl/mechanism.h +2 -1
- data/ext/couchbase/core/sasl/oauthbearer/oauthbearer.cc +41 -0
- data/ext/couchbase/core/sasl/oauthbearer/oauthbearer.h +47 -0
- data/ext/couchbase/core/tls_context_provider.cxx +44 -0
- data/ext/couchbase/core/tls_context_provider.hxx +44 -0
- data/ext/couchbase/core/tracing/attribute_helpers.hxx +45 -0
- data/ext/couchbase/core/tracing/constants.hxx +148 -68
- data/ext/couchbase/core/tracing/threshold_logging_options.hxx +0 -3
- data/ext/couchbase/core/tracing/threshold_logging_tracer.cxx +122 -170
- data/ext/couchbase/core/tracing/tracer_wrapper.cxx +17 -24
- data/ext/couchbase/core/tracing/tracer_wrapper.hxx +8 -10
- data/ext/couchbase/core/tracing/wrapper_sdk_tracer.cxx +114 -0
- data/ext/couchbase/core/tracing/wrapper_sdk_tracer.hxx +85 -0
- data/ext/couchbase/core/transactions/attempt_context_impl.cxx +16 -14
- data/ext/couchbase/core/transactions/attempt_context_impl.hxx +4 -4
- data/ext/couchbase/core/transactions/transactions.cxx +1 -1
- data/ext/couchbase/core/transactions/transactions_cleanup.cxx +1 -2
- data/ext/couchbase/core/utils/byteswap.hxx +12 -0
- data/ext/couchbase/core/utils/concurrent_fixed_priority_queue.hxx +102 -0
- data/ext/couchbase/core/utils/connection_string.cxx +2 -0
- data/ext/couchbase/couchbase/certificate_authenticator.hxx +1 -0
- data/ext/couchbase/couchbase/cluster.hxx +47 -0
- data/ext/couchbase/couchbase/cluster_options.hxx +16 -0
- data/ext/couchbase/couchbase/collection.hxx +60 -15
- data/ext/couchbase/couchbase/error_codes.hxx +48 -48
- data/ext/couchbase/couchbase/jwt_authenticator.hxx +52 -0
- data/ext/couchbase/couchbase/metrics/meter.hxx +2 -1
- data/ext/couchbase/couchbase/metrics/otel_meter.hxx +75 -80
- data/ext/couchbase/couchbase/network_options.hxx +19 -0
- data/ext/couchbase/couchbase/password_authenticator.hxx +1 -0
- data/ext/couchbase/couchbase/tracing/otel_tracer.hxx +15 -17
- data/ext/couchbase/couchbase/tracing/request_span.hxx +2 -2
- data/ext/couchbase.cxx +4 -0
- data/ext/extconf.rb +1 -0
- data/ext/rcb_analytics.cxx +157 -47
- data/ext/rcb_backend.cxx +118 -71
- data/ext/rcb_buckets.cxx +39 -16
- data/ext/rcb_collections.cxx +36 -12
- data/ext/rcb_crud.cxx +587 -294
- data/ext/rcb_hdr_histogram.cxx +219 -0
- data/ext/rcb_hdr_histogram.hxx +28 -0
- data/ext/rcb_multi.cxx +142 -59
- data/ext/rcb_observability.cxx +132 -0
- data/ext/rcb_observability.hxx +49 -0
- data/ext/rcb_query.cxx +77 -27
- data/ext/rcb_search.cxx +92 -31
- data/ext/rcb_users.cxx +69 -26
- data/ext/rcb_utils.cxx +91 -0
- data/ext/rcb_utils.hxx +141 -168
- data/ext/rcb_views.cxx +36 -12
- data/lib/active_support/cache/couchbase_store.rb +6 -6
- data/lib/couchbase/authenticator.rb +14 -0
- data/lib/couchbase/binary_collection.rb +37 -22
- data/lib/couchbase/bucket.rb +46 -31
- data/lib/couchbase/cluster.rb +146 -61
- data/lib/couchbase/collection.rb +257 -186
- data/lib/couchbase/datastructures/couchbase_list.rb +81 -50
- data/lib/couchbase/datastructures/couchbase_map.rb +86 -50
- data/lib/couchbase/datastructures/couchbase_queue.rb +64 -38
- data/lib/couchbase/datastructures/couchbase_set.rb +57 -41
- data/lib/couchbase/deprecations.rb +1 -1
- data/lib/couchbase/diagnostics.rb +8 -8
- data/lib/couchbase/errors.rb +6 -0
- data/lib/couchbase/management/analytics_index_manager.rb +90 -59
- data/lib/couchbase/management/bucket_manager.rb +73 -45
- data/lib/couchbase/management/collection_manager.rb +86 -43
- data/lib/couchbase/management/collection_query_index_manager.rb +56 -33
- data/lib/couchbase/management/query_index_manager.rb +88 -36
- data/lib/couchbase/management/scope_search_index_manager.rb +119 -52
- data/lib/couchbase/management/search_index_manager.rb +401 -178
- data/lib/couchbase/management/user_manager.rb +343 -174
- data/lib/couchbase/management/view_index_manager.rb +166 -73
- data/lib/couchbase/metrics/logging_meter.rb +108 -0
- data/lib/couchbase/metrics/logging_value_recorder.rb +50 -0
- data/lib/couchbase/metrics/meter.rb +27 -0
- data/lib/couchbase/metrics/noop_meter.rb +30 -0
- data/lib/couchbase/metrics/noop_value_recorder.rb +27 -0
- data/lib/couchbase/metrics/value_recorder.rb +25 -0
- data/lib/couchbase/options.rb +69 -3
- data/lib/couchbase/protostellar/cluster.rb +3 -0
- data/lib/couchbase/scope.rb +62 -48
- data/lib/couchbase/search_options.rb +18 -18
- data/lib/couchbase/tracing/noop_span.rb +29 -0
- data/lib/couchbase/tracing/noop_tracer.rb +29 -0
- data/lib/couchbase/tracing/request_span.rb +34 -0
- data/lib/couchbase/tracing/request_tracer.rb +28 -0
- data/lib/couchbase/tracing/threshold_logging_span.rb +112 -0
- data/lib/couchbase/tracing/threshold_logging_tracer.rb +231 -0
- data/lib/couchbase/utils/hdr_histogram.rb +55 -0
- data/lib/couchbase/utils/observability.rb +257 -0
- data/lib/couchbase/utils/observability_constants.rb +200 -0
- data/lib/couchbase/utils/stdlib_logger_adapter.rb +1 -3
- data/lib/couchbase/version.rb +1 -1
- data/lib/couchbase.rb +2 -2
- metadata +58 -6
data/lib/couchbase/options.rb
CHANGED
|
@@ -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
|
data/lib/couchbase/scope.rb
CHANGED
|
@@ -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
|
-
|
|
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
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
if resp[:meta][:
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
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
|
|
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
|
-
|
|
149
|
-
|
|
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
|
-
|
|
161
|
-
|
|
162
|
-
|
|
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(*
|
|
88
|
-
to_h.to_json(*
|
|
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(*
|
|
1132
|
-
to_h.to_json(*
|
|
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(*
|
|
1177
|
-
{by: :score, desc: desc}.to_json(*
|
|
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(*
|
|
1193
|
-
{by: :id, desc: desc}.to_json(*
|
|
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(*
|
|
1223
|
-
{by: :field, field: field, desc: desc, type: type, missing: missing, mode: mode}.to_json(*
|
|
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(*
|
|
1257
|
-
{by: :geo_distance, field: field, desc: desc, location: [longitude, latitude], unit: unit}.to_json(*
|
|
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(*
|
|
1296
|
-
{field: field, size: size}.to_json(*
|
|
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(*
|
|
1323
|
-
{field: field, size: size, numeric_ranges: @ranges}.to_json(*
|
|
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(*
|
|
1355
|
-
{field: field, size: size, date_ranges: @ranges}.to_json(*
|
|
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
|