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.
- package/CMakeLists.txt +2 -1
- package/deps/couchbase-cxx-cache/mozilla-ca-bundle.crt +23 -5
- package/deps/couchbase-cxx-cache/mozilla-ca-bundle.sha256 +1 -1
- package/deps/couchbase-cxx-client/CMakeLists.txt +24 -11
- package/deps/couchbase-cxx-client/README.md +2 -2
- package/deps/couchbase-cxx-client/cmake/APKBUILD.in +17 -1
- package/deps/couchbase-cxx-client/cmake/Bundler.cmake +9 -1
- package/deps/couchbase-cxx-client/cmake/Cache.cmake +48 -19
- package/deps/couchbase-cxx-client/cmake/CompilerOptions.cmake +3 -1
- package/deps/couchbase-cxx-client/cmake/OpenSSL.cmake +10 -2
- package/deps/couchbase-cxx-client/cmake/Packaging.cmake +48 -8
- package/deps/couchbase-cxx-client/cmake/ThirdPartyDependencies.cmake +41 -0
- package/deps/couchbase-cxx-client/cmake/build_config.hxx.in +2 -0
- package/deps/couchbase-cxx-client/cmake/couchbase-cxx-client.spec.in +18 -0
- package/deps/couchbase-cxx-client/cmake/debian/control +6 -1
- package/deps/couchbase-cxx-client/cmake/debian/rules +1 -0
- package/deps/couchbase-cxx-client/cmake/tarball_glob.txt +10 -0
- package/deps/couchbase-cxx-client/core/app_telemetry_meter.cxx +1 -0
- package/deps/couchbase-cxx-client/core/app_telemetry_reporter.cxx +45 -43
- package/deps/couchbase-cxx-client/core/app_telemetry_reporter.hxx +4 -3
- package/deps/couchbase-cxx-client/core/bucket.cxx +128 -13
- package/deps/couchbase-cxx-client/core/bucket.hxx +12 -2
- package/deps/couchbase-cxx-client/core/cluster.cxx +304 -152
- package/deps/couchbase-cxx-client/core/cluster.hxx +32 -0
- package/deps/couchbase-cxx-client/core/cluster_credentials.cxx +25 -0
- package/deps/couchbase-cxx-client/core/cluster_credentials.hxx +5 -0
- package/deps/couchbase-cxx-client/core/cluster_label_listener.cxx +72 -0
- package/deps/couchbase-cxx-client/core/cluster_label_listener.hxx +46 -0
- package/deps/couchbase-cxx-client/core/cluster_options.hxx +4 -0
- package/deps/couchbase-cxx-client/core/deprecation_utils.hxx +26 -0
- package/deps/couchbase-cxx-client/core/error.hxx +27 -0
- package/deps/couchbase-cxx-client/core/free_form_http_request.hxx +0 -2
- package/deps/couchbase-cxx-client/core/http_component.cxx +12 -48
- package/deps/couchbase-cxx-client/core/impl/analytics.cxx +3 -2
- package/deps/couchbase-cxx-client/core/impl/analytics.hxx +2 -1
- package/deps/couchbase-cxx-client/core/impl/analytics_index_manager.cxx +249 -137
- package/deps/couchbase-cxx-client/core/impl/binary_collection.cxx +134 -58
- package/deps/couchbase-cxx-client/core/impl/bucket_manager.cxx +87 -35
- package/deps/couchbase-cxx-client/core/impl/collection.cxx +560 -245
- package/deps/couchbase-cxx-client/core/impl/collection_manager.cxx +89 -49
- package/deps/couchbase-cxx-client/core/impl/dns_srv_tracker.cxx +3 -3
- package/deps/couchbase-cxx-client/core/impl/error.cxx +20 -13
- package/deps/couchbase-cxx-client/core/impl/error.hxx +15 -10
- package/deps/couchbase-cxx-client/core/impl/get_all_replicas.hxx +1 -1
- package/deps/couchbase-cxx-client/core/impl/get_any_replica.hxx +2 -1
- package/deps/couchbase-cxx-client/core/impl/get_replica.hxx +2 -0
- package/deps/couchbase-cxx-client/core/impl/lookup_in_replica.hxx +1 -1
- package/deps/couchbase-cxx-client/core/impl/observability_recorder.cxx +161 -0
- package/deps/couchbase-cxx-client/core/impl/observability_recorder.hxx +77 -0
- package/deps/couchbase-cxx-client/core/impl/observe_seqno.hxx +2 -0
- package/deps/couchbase-cxx-client/core/impl/public_bucket.cxx +31 -7
- package/deps/couchbase-cxx-client/core/impl/public_cluster.cxx +107 -19
- package/deps/couchbase-cxx-client/core/impl/query.cxx +6 -3
- package/deps/couchbase-cxx-client/core/impl/query.hxx +3 -1
- package/deps/couchbase-cxx-client/core/impl/query_index_manager.cxx +267 -102
- package/deps/couchbase-cxx-client/core/impl/scope.cxx +53 -11
- package/deps/couchbase-cxx-client/core/impl/search.cxx +8 -4
- package/deps/couchbase-cxx-client/core/impl/search.hxx +6 -2
- package/deps/couchbase-cxx-client/core/impl/search_index_manager.cxx +131 -41
- package/deps/couchbase-cxx-client/core/impl/with_cancellation.hxx +75 -0
- package/deps/couchbase-cxx-client/core/io/config_tracker.cxx +9 -9
- package/deps/couchbase-cxx-client/core/io/config_tracker.hxx +2 -1
- package/deps/couchbase-cxx-client/core/io/http_command.hxx +98 -49
- package/deps/couchbase-cxx-client/core/io/http_context.hxx +2 -0
- package/deps/couchbase-cxx-client/core/io/http_session.cxx +23 -10
- package/deps/couchbase-cxx-client/core/io/http_session.hxx +17 -9
- package/deps/couchbase-cxx-client/core/io/http_session_manager.hxx +163 -228
- package/deps/couchbase-cxx-client/core/io/http_traits.hxx +0 -7
- package/deps/couchbase-cxx-client/core/io/mcbp_command.hxx +123 -44
- package/deps/couchbase-cxx-client/core/io/mcbp_session.cxx +251 -26
- package/deps/couchbase-cxx-client/core/io/mcbp_session.hxx +9 -1
- package/deps/couchbase-cxx-client/core/io/mcbp_traits.hxx +0 -8
- package/deps/couchbase-cxx-client/core/io/streams.cxx +3 -3
- package/deps/couchbase-cxx-client/core/io/streams.hxx +3 -2
- package/deps/couchbase-cxx-client/core/meta/features.hxx +15 -0
- package/deps/couchbase-cxx-client/core/meta/version.cxx +13 -0
- package/deps/couchbase-cxx-client/core/meta/version.hxx +3 -0
- package/deps/couchbase-cxx-client/core/metrics/constants.hxx +23 -0
- package/deps/couchbase-cxx-client/core/metrics/logging_meter.cxx +5 -5
- package/deps/couchbase-cxx-client/core/metrics/meter_wrapper.cxx +65 -63
- package/deps/couchbase-cxx-client/core/metrics/meter_wrapper.hxx +12 -10
- package/deps/couchbase-cxx-client/core/operations/document_analytics.hxx +0 -5
- package/deps/couchbase-cxx-client/core/operations/document_append.hxx +0 -4
- package/deps/couchbase-cxx-client/core/operations/document_decrement.hxx +0 -5
- package/deps/couchbase-cxx-client/core/operations/document_exists.hxx +0 -7
- package/deps/couchbase-cxx-client/core/operations/document_get.hxx +0 -7
- package/deps/couchbase-cxx-client/core/operations/document_get_all_replicas.hxx +77 -27
- package/deps/couchbase-cxx-client/core/operations/document_get_and_lock.hxx +0 -9
- package/deps/couchbase-cxx-client/core/operations/document_get_and_touch.hxx +0 -9
- package/deps/couchbase-cxx-client/core/operations/document_get_any_replica.hxx +83 -2
- package/deps/couchbase-cxx-client/core/operations/document_get_projected.hxx +0 -9
- package/deps/couchbase-cxx-client/core/operations/document_increment.hxx +0 -5
- package/deps/couchbase-cxx-client/core/operations/document_insert.hxx +0 -4
- package/deps/couchbase-cxx-client/core/operations/document_lookup_in.hxx +0 -9
- package/deps/couchbase-cxx-client/core/operations/document_lookup_in_all_replicas.hxx +46 -4
- package/deps/couchbase-cxx-client/core/operations/document_lookup_in_any_replica.hxx +121 -43
- package/deps/couchbase-cxx-client/core/operations/document_mutate_in.hxx +0 -5
- package/deps/couchbase-cxx-client/core/operations/document_prepend.hxx +0 -4
- package/deps/couchbase-cxx-client/core/operations/document_query.hxx +0 -4
- package/deps/couchbase-cxx-client/core/operations/document_remove.hxx +0 -4
- package/deps/couchbase-cxx-client/core/operations/document_replace.hxx +0 -4
- package/deps/couchbase-cxx-client/core/operations/document_search.hxx +0 -7
- package/deps/couchbase-cxx-client/core/operations/document_touch.hxx +0 -7
- package/deps/couchbase-cxx-client/core/operations/document_unlock.hxx +0 -6
- package/deps/couchbase-cxx-client/core/operations/document_upsert.hxx +0 -4
- package/deps/couchbase-cxx-client/core/operations/document_view.cxx +2 -0
- package/deps/couchbase-cxx-client/core/operations/document_view.hxx +10 -13
- package/deps/couchbase-cxx-client/core/operations/http_noop.hxx +2 -0
- package/deps/couchbase-cxx-client/core/operations/management/analytics_dataset_create.hxx +2 -0
- package/deps/couchbase-cxx-client/core/operations/management/analytics_dataset_drop.hxx +2 -0
- package/deps/couchbase-cxx-client/core/operations/management/analytics_dataset_get_all.hxx +2 -0
- package/deps/couchbase-cxx-client/core/operations/management/analytics_dataverse_create.hxx +2 -0
- package/deps/couchbase-cxx-client/core/operations/management/analytics_dataverse_drop.hxx +2 -0
- package/deps/couchbase-cxx-client/core/operations/management/analytics_get_pending_mutations.hxx +2 -0
- package/deps/couchbase-cxx-client/core/operations/management/analytics_index_create.hxx +2 -0
- package/deps/couchbase-cxx-client/core/operations/management/analytics_index_drop.hxx +2 -0
- package/deps/couchbase-cxx-client/core/operations/management/analytics_index_get_all.hxx +2 -0
- package/deps/couchbase-cxx-client/core/operations/management/analytics_link_connect.hxx +2 -0
- package/deps/couchbase-cxx-client/core/operations/management/analytics_link_create.hxx +2 -0
- package/deps/couchbase-cxx-client/core/operations/management/analytics_link_disconnect.hxx +2 -0
- package/deps/couchbase-cxx-client/core/operations/management/analytics_link_drop.hxx +2 -0
- package/deps/couchbase-cxx-client/core/operations/management/analytics_link_get_all.hxx +2 -0
- package/deps/couchbase-cxx-client/core/operations/management/analytics_link_replace.hxx +2 -0
- package/deps/couchbase-cxx-client/core/operations/management/bucket_create.hxx +2 -0
- package/deps/couchbase-cxx-client/core/operations/management/bucket_describe.hxx +2 -0
- package/deps/couchbase-cxx-client/core/operations/management/bucket_drop.hxx +2 -0
- package/deps/couchbase-cxx-client/core/operations/management/bucket_flush.hxx +2 -0
- package/deps/couchbase-cxx-client/core/operations/management/bucket_get.hxx +2 -0
- package/deps/couchbase-cxx-client/core/operations/management/bucket_get_all.hxx +2 -0
- package/deps/couchbase-cxx-client/core/operations/management/bucket_update.hxx +2 -0
- package/deps/couchbase-cxx-client/core/operations/management/change_password.hxx +2 -0
- package/deps/couchbase-cxx-client/core/operations/management/cluster_describe.hxx +2 -0
- package/deps/couchbase-cxx-client/core/operations/management/cluster_developer_preview_enable.hxx +2 -0
- package/deps/couchbase-cxx-client/core/operations/management/collection_create.hxx +2 -0
- package/deps/couchbase-cxx-client/core/operations/management/collection_drop.hxx +2 -0
- package/deps/couchbase-cxx-client/core/operations/management/collection_update.hxx +2 -0
- package/deps/couchbase-cxx-client/core/operations/management/collections_manifest_get.hxx +2 -0
- package/deps/couchbase-cxx-client/core/operations/management/error_utils.cxx +4 -1
- package/deps/couchbase-cxx-client/core/operations/management/eventing_deploy_function.hxx +2 -0
- package/deps/couchbase-cxx-client/core/operations/management/eventing_drop_function.hxx +2 -0
- package/deps/couchbase-cxx-client/core/operations/management/eventing_get_all_functions.hxx +2 -0
- package/deps/couchbase-cxx-client/core/operations/management/eventing_get_function.hxx +2 -0
- package/deps/couchbase-cxx-client/core/operations/management/eventing_get_status.hxx +2 -0
- package/deps/couchbase-cxx-client/core/operations/management/eventing_pause_function.hxx +2 -0
- package/deps/couchbase-cxx-client/core/operations/management/eventing_resume_function.hxx +2 -0
- package/deps/couchbase-cxx-client/core/operations/management/eventing_undeploy_function.hxx +2 -0
- package/deps/couchbase-cxx-client/core/operations/management/eventing_upsert_function.hxx +2 -0
- package/deps/couchbase-cxx-client/core/operations/management/freeform.hxx +2 -0
- package/deps/couchbase-cxx-client/core/operations/management/group_drop.hxx +2 -0
- package/deps/couchbase-cxx-client/core/operations/management/group_get.hxx +2 -0
- package/deps/couchbase-cxx-client/core/operations/management/group_get_all.hxx +2 -0
- package/deps/couchbase-cxx-client/core/operations/management/group_upsert.hxx +2 -0
- package/deps/couchbase-cxx-client/core/operations/management/query_index_build.hxx +2 -0
- package/deps/couchbase-cxx-client/core/operations/management/query_index_build_deferred.hxx +68 -30
- package/deps/couchbase-cxx-client/core/operations/management/query_index_create.hxx +2 -0
- package/deps/couchbase-cxx-client/core/operations/management/query_index_drop.hxx +2 -0
- package/deps/couchbase-cxx-client/core/operations/management/query_index_get_all.hxx +4 -3
- package/deps/couchbase-cxx-client/core/operations/management/query_index_get_all_deferred.hxx +2 -1
- package/deps/couchbase-cxx-client/core/operations/management/role_get_all.hxx +2 -0
- package/deps/couchbase-cxx-client/core/operations/management/scope_create.hxx +2 -0
- package/deps/couchbase-cxx-client/core/operations/management/scope_drop.hxx +2 -0
- package/deps/couchbase-cxx-client/core/operations/management/scope_get_all.hxx +2 -0
- package/deps/couchbase-cxx-client/core/operations/management/search_get_stats.hxx +2 -0
- package/deps/couchbase-cxx-client/core/operations/management/search_index_analyze_document.hxx +2 -0
- package/deps/couchbase-cxx-client/core/operations/management/search_index_control_ingest.hxx +2 -0
- package/deps/couchbase-cxx-client/core/operations/management/search_index_control_plan_freeze.hxx +2 -0
- package/deps/couchbase-cxx-client/core/operations/management/search_index_control_query.hxx +2 -0
- package/deps/couchbase-cxx-client/core/operations/management/search_index_drop.hxx +2 -0
- package/deps/couchbase-cxx-client/core/operations/management/search_index_get.hxx +2 -0
- package/deps/couchbase-cxx-client/core/operations/management/search_index_get_all.hxx +2 -0
- package/deps/couchbase-cxx-client/core/operations/management/search_index_get_documents_count.hxx +2 -0
- package/deps/couchbase-cxx-client/core/operations/management/search_index_get_stats.hxx +2 -0
- package/deps/couchbase-cxx-client/core/operations/management/search_index_upsert.hxx +2 -0
- package/deps/couchbase-cxx-client/core/operations/management/user_drop.hxx +2 -0
- package/deps/couchbase-cxx-client/core/operations/management/user_get.hxx +2 -0
- package/deps/couchbase-cxx-client/core/operations/management/user_get_all.hxx +2 -0
- package/deps/couchbase-cxx-client/core/operations/management/user_upsert.hxx +2 -0
- package/deps/couchbase-cxx-client/core/operations/management/view_index_drop.hxx +2 -0
- package/deps/couchbase-cxx-client/core/operations/management/view_index_get.hxx +2 -0
- package/deps/couchbase-cxx-client/core/operations/management/view_index_get_all.hxx +2 -0
- package/deps/couchbase-cxx-client/core/operations/management/view_index_upsert.hxx +2 -0
- package/deps/couchbase-cxx-client/core/operations/operation_traits.hxx +6 -0
- package/deps/couchbase-cxx-client/core/operations.hxx +0 -1
- package/deps/couchbase-cxx-client/core/operations_fwd.hxx +8 -0
- package/deps/couchbase-cxx-client/core/origin.cxx +67 -12
- package/deps/couchbase-cxx-client/core/origin.hxx +13 -8
- package/deps/couchbase-cxx-client/core/orphan_reporter.cxx +164 -0
- package/deps/couchbase-cxx-client/core/orphan_reporter.hxx +65 -0
- package/deps/couchbase-cxx-client/core/sasl/CMakeLists.txt +1 -0
- package/deps/couchbase-cxx-client/core/sasl/client.cc +6 -0
- package/deps/couchbase-cxx-client/core/sasl/mechanism.cc +2 -1
- package/deps/couchbase-cxx-client/core/sasl/mechanism.h +2 -1
- package/deps/couchbase-cxx-client/core/sasl/oauthbearer/oauthbearer.cc +41 -0
- package/deps/couchbase-cxx-client/core/sasl/oauthbearer/oauthbearer.h +47 -0
- package/deps/couchbase-cxx-client/core/tls_context_provider.cxx +44 -0
- package/deps/couchbase-cxx-client/core/tls_context_provider.hxx +44 -0
- package/deps/couchbase-cxx-client/core/tracing/attribute_helpers.hxx +45 -0
- package/deps/couchbase-cxx-client/core/tracing/constants.hxx +148 -68
- package/deps/couchbase-cxx-client/core/tracing/threshold_logging_options.hxx +0 -3
- package/deps/couchbase-cxx-client/core/tracing/threshold_logging_tracer.cxx +122 -170
- package/deps/couchbase-cxx-client/core/tracing/tracer_wrapper.cxx +17 -24
- package/deps/couchbase-cxx-client/core/tracing/tracer_wrapper.hxx +8 -10
- package/deps/couchbase-cxx-client/core/tracing/wrapper_sdk_tracer.cxx +114 -0
- package/deps/couchbase-cxx-client/core/tracing/wrapper_sdk_tracer.hxx +85 -0
- package/deps/couchbase-cxx-client/core/transactions/attempt_context_impl.cxx +16 -14
- package/deps/couchbase-cxx-client/core/transactions/attempt_context_impl.hxx +4 -4
- package/deps/couchbase-cxx-client/core/transactions/transactions.cxx +1 -1
- package/deps/couchbase-cxx-client/core/transactions/transactions_cleanup.cxx +1 -2
- package/deps/couchbase-cxx-client/core/utils/byteswap.hxx +12 -0
- package/deps/couchbase-cxx-client/core/utils/concurrent_fixed_priority_queue.hxx +102 -0
- package/deps/couchbase-cxx-client/core/utils/connection_string.cxx +2 -0
- package/deps/couchbase-cxx-client/couchbase/certificate_authenticator.hxx +1 -0
- package/deps/couchbase-cxx-client/couchbase/cluster.hxx +47 -0
- package/deps/couchbase-cxx-client/couchbase/cluster_options.hxx +16 -0
- package/deps/couchbase-cxx-client/couchbase/collection.hxx +60 -15
- package/deps/couchbase-cxx-client/couchbase/error_codes.hxx +48 -48
- package/deps/couchbase-cxx-client/couchbase/jwt_authenticator.hxx +52 -0
- package/deps/couchbase-cxx-client/couchbase/metrics/meter.hxx +2 -1
- package/deps/couchbase-cxx-client/couchbase/metrics/otel_meter.hxx +75 -80
- package/deps/couchbase-cxx-client/couchbase/network_options.hxx +19 -0
- package/deps/couchbase-cxx-client/couchbase/password_authenticator.hxx +1 -0
- package/deps/couchbase-cxx-client/couchbase/tracing/otel_tracer.hxx +15 -17
- package/deps/couchbase-cxx-client/couchbase/tracing/request_span.hxx +2 -2
- package/dist/analyticsexecutor.d.ts +15 -0
- package/dist/analyticsexecutor.js +79 -50
- package/dist/analyticsindexmanager.d.ts +66 -0
- package/dist/analyticsindexmanager.js +404 -277
- package/dist/analyticstypes.d.ts +5 -0
- package/dist/authenticators.d.ts +34 -1
- package/dist/authenticators.js +19 -1
- package/dist/binarycollection.d.ts +17 -0
- package/dist/binding.d.ts +245 -228
- package/dist/bindingutilities.js +1 -1
- package/dist/bucket.d.ts +8 -0
- package/dist/bucket.js +8 -0
- package/dist/bucketmanager.d.ts +30 -0
- package/dist/bucketmanager.js +128 -69
- package/dist/cluster.d.ts +45 -0
- package/dist/cluster.js +133 -21
- package/dist/collection.d.ts +75 -2
- package/dist/collection.js +772 -551
- package/dist/collectionmanager.d.ts +34 -0
- package/dist/collectionmanager.js +172 -89
- package/dist/couchbase.d.ts +5 -0
- package/dist/couchbase.js +5 -0
- package/dist/datastructures.js +310 -97
- package/dist/errors.d.ts +8 -0
- package/dist/errors.js +12 -1
- package/dist/eventingfunctionmanager.d.ts +42 -0
- package/dist/eventingfunctionmanager.js +172 -100
- package/dist/logger.d.ts +192 -0
- package/dist/logger.js +213 -0
- package/dist/loggingmeter.d.ts +120 -0
- package/dist/loggingmeter.js +226 -0
- package/dist/metrics.d.ts +33 -0
- package/dist/metrics.js +5 -0
- package/dist/observability.d.ts +60 -0
- package/dist/observability.js +86 -0
- package/dist/observabilityhandler.d.ts +176 -0
- package/dist/observabilityhandler.js +733 -0
- package/dist/observabilitytypes.d.ts +320 -0
- package/dist/observabilitytypes.js +362 -0
- package/dist/observabilityutilities.d.ts +60 -0
- package/dist/observabilityutilities.js +175 -0
- package/dist/otelmeter.d.ts +51 -0
- package/dist/otelmeter.js +100 -0
- package/dist/oteltracer.d.ts +69 -0
- package/dist/oteltracer.js +141 -0
- package/dist/queryexecutor.d.ts +16 -0
- package/dist/queryexecutor.js +128 -86
- package/dist/queryindexmanager.d.ts +29 -0
- package/dist/queryindexmanager.js +277 -150
- package/dist/querytypes.d.ts +5 -0
- package/dist/scope.js +2 -2
- package/dist/scopeeventingfunctionmanager.d.ts +5 -0
- package/dist/scopeeventingfunctionmanager.js +217 -119
- package/dist/scopesearchindexmanager.d.ts +5 -0
- package/dist/scopesearchindexmanager.js +295 -166
- package/dist/sdspecs.js +6 -1
- package/dist/searchexecutor.d.ts +15 -0
- package/dist/searchexecutor.js +54 -26
- package/dist/searchindexmanager.d.ts +54 -0
- package/dist/searchindexmanager.js +235 -142
- package/dist/searchtypes.d.ts +5 -0
- package/dist/thresholdlogging.d.ts +301 -0
- package/dist/thresholdlogging.js +657 -0
- package/dist/tracing.d.ts +55 -0
- package/dist/tracing.js +2 -0
- package/dist/usermanager.d.ts +46 -0
- package/dist/usermanager.js +199 -118
- package/dist/utilities.d.ts +4 -0
- package/dist/utilities.js +11 -1
- package/dist/version.d.ts +2 -0
- package/dist/version.js +7 -0
- package/dist/viewexecutor.d.ts +15 -0
- package/dist/viewexecutor.js +54 -29
- package/dist/viewindexmanager.d.ts +30 -0
- package/dist/viewindexmanager.js +129 -100
- package/dist/viewtypes.d.ts +5 -0
- package/package.json +19 -9
- package/scripts/prebuilds.js +1 -1
- package/scripts/updateVersion.js +26 -0
- package/src/connection.cpp +79 -98
- package/src/connection.hpp +46 -38
- package/src/connection_autogen.cpp +1236 -292
- package/src/jstocbpp_autogen.hpp +1117 -313
- package/src/jstocbpp_basic.hpp +73 -0
- package/src/jstocbpp_defs.hpp +37 -9
- package/src/jstocbpp_errors.hpp +37 -11
- package/tools/gen-bindings-js.js +100 -22
- package/tools/gen-bindings-json.py +40 -6
- package/src/transcoder.hpp +0 -96
|
@@ -24,14 +24,14 @@
|
|
|
24
24
|
#include "core/meta/version.hxx"
|
|
25
25
|
#include "core/platform/uuid.h"
|
|
26
26
|
#include "core/service_type_fmt.hxx"
|
|
27
|
+
#include "core/utils/concurrent_fixed_priority_queue.hxx"
|
|
27
28
|
#include "core/utils/json.hxx"
|
|
28
29
|
|
|
29
30
|
#include <asio/steady_timer.hpp>
|
|
31
|
+
#include <memory>
|
|
30
32
|
#include <tao/json/value.hpp>
|
|
31
33
|
|
|
32
34
|
#include <chrono>
|
|
33
|
-
#include <mutex>
|
|
34
|
-
#include <queue>
|
|
35
35
|
#include <utility>
|
|
36
36
|
|
|
37
37
|
namespace couchbase::core::tracing
|
|
@@ -44,6 +44,11 @@ struct reported_span {
|
|
|
44
44
|
{
|
|
45
45
|
return duration < other.duration;
|
|
46
46
|
}
|
|
47
|
+
|
|
48
|
+
auto operator>(const reported_span& other) const -> bool
|
|
49
|
+
{
|
|
50
|
+
return duration > other.duration;
|
|
51
|
+
}
|
|
47
52
|
};
|
|
48
53
|
|
|
49
54
|
class threshold_logging_span
|
|
@@ -52,16 +57,15 @@ class threshold_logging_span
|
|
|
52
57
|
{
|
|
53
58
|
private:
|
|
54
59
|
std::chrono::system_clock::time_point start_{ std::chrono::system_clock::now() };
|
|
55
|
-
std::
|
|
56
|
-
|
|
57
|
-
std::map<std::string, std::string> string_tags_{
|
|
58
|
-
{ attributes::system, "couchbase" },
|
|
59
|
-
{ attributes::span_kind, "client" },
|
|
60
|
-
{ attributes::component, couchbase::core::meta::sdk_id() },
|
|
61
|
-
};
|
|
62
|
-
std::chrono::microseconds duration_{ 0 };
|
|
60
|
+
std::chrono::microseconds total_duration_{ 0 };
|
|
61
|
+
|
|
63
62
|
std::uint64_t last_server_duration_us_{ 0 };
|
|
64
63
|
std::uint64_t total_server_duration_us_{ 0 };
|
|
64
|
+
std::optional<std::string> operation_id_{};
|
|
65
|
+
std::optional<std::string> last_local_id_{};
|
|
66
|
+
std::optional<std::string> service_{};
|
|
67
|
+
std::optional<std::string> peer_hostname_{};
|
|
68
|
+
std::optional<std::uint16_t> peer_port_{};
|
|
65
69
|
|
|
66
70
|
std::shared_ptr<threshold_logging_tracer> tracer_{};
|
|
67
71
|
|
|
@@ -74,30 +78,74 @@ public:
|
|
|
74
78
|
{
|
|
75
79
|
}
|
|
76
80
|
|
|
77
|
-
void add_tag(const std::string&
|
|
81
|
+
void add_tag(const std::string& tag_name, std::uint64_t value) override
|
|
78
82
|
{
|
|
79
|
-
if (
|
|
83
|
+
if (tag_name == tracing::attributes::dispatch::server_duration) {
|
|
80
84
|
last_server_duration_us_ = value;
|
|
81
|
-
|
|
85
|
+
if (name() != tracing::operation::step_dispatch) {
|
|
86
|
+
total_server_duration_us_ += value;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
if (tag_name == tracing::attributes::dispatch::peer_port) {
|
|
90
|
+
peer_port_ = static_cast<std::uint16_t>(value);
|
|
82
91
|
}
|
|
83
|
-
integer_tags_.try_emplace(name, value);
|
|
84
92
|
}
|
|
85
93
|
|
|
86
|
-
void add_tag(const std::string&
|
|
94
|
+
void add_tag(const std::string& tag_name, const std::string& value) override
|
|
87
95
|
{
|
|
88
|
-
|
|
96
|
+
if (tag_name == tracing::attributes::op::service) {
|
|
97
|
+
service_ = value;
|
|
98
|
+
}
|
|
99
|
+
if (tag_name == tracing::attributes::dispatch::local_id) {
|
|
100
|
+
last_local_id_ = value;
|
|
101
|
+
}
|
|
102
|
+
if (tag_name == tracing::attributes::dispatch::operation_id) {
|
|
103
|
+
operation_id_ = value;
|
|
104
|
+
}
|
|
105
|
+
if (tag_name == tracing::attributes::dispatch::peer_address) {
|
|
106
|
+
peer_hostname_ = value;
|
|
107
|
+
}
|
|
89
108
|
}
|
|
90
109
|
|
|
91
110
|
void end() override;
|
|
92
111
|
|
|
93
|
-
|
|
112
|
+
void set_last_local_id(const std::string& id)
|
|
113
|
+
{
|
|
114
|
+
last_local_id_ = id;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
void set_operation_id(const std::string& id)
|
|
118
|
+
{
|
|
119
|
+
operation_id_ = id;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
void set_peer_hostname(const std::string& hostname)
|
|
123
|
+
{
|
|
124
|
+
peer_hostname_ = hostname;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
void set_peer_port(const std::uint16_t port)
|
|
128
|
+
{
|
|
129
|
+
peer_port_ = port;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
[[nodiscard]] auto last_remote_socket() const -> std::optional<std::string>
|
|
133
|
+
{
|
|
134
|
+
if (peer_hostname_.has_value() && peer_port_.has_value()) {
|
|
135
|
+
return fmt::format("{}:{}", peer_hostname_.value(), peer_port_.value());
|
|
136
|
+
}
|
|
137
|
+
return {};
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
void add_server_duration(const std::uint64_t duration_us)
|
|
94
141
|
{
|
|
95
|
-
|
|
142
|
+
last_server_duration_us_ = duration_us;
|
|
143
|
+
total_server_duration_us_ += duration_us;
|
|
96
144
|
}
|
|
97
145
|
|
|
98
|
-
[[nodiscard]] auto
|
|
146
|
+
[[nodiscard]] auto total_duration() const -> std::chrono::microseconds
|
|
99
147
|
{
|
|
100
|
-
return
|
|
148
|
+
return total_duration_;
|
|
101
149
|
}
|
|
102
150
|
|
|
103
151
|
[[nodiscard]] auto last_server_duration_us() const -> std::uint64_t
|
|
@@ -110,27 +158,27 @@ public:
|
|
|
110
158
|
return total_server_duration_us_;
|
|
111
159
|
}
|
|
112
160
|
|
|
113
|
-
[[nodiscard]] auto
|
|
161
|
+
[[nodiscard]] auto operation_id() const -> std::optional<std::string>
|
|
114
162
|
{
|
|
115
|
-
return
|
|
163
|
+
return operation_id_;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
[[nodiscard]] auto last_local_id() const -> std::optional<std::string>
|
|
167
|
+
{
|
|
168
|
+
return last_local_id_;
|
|
116
169
|
}
|
|
117
170
|
|
|
118
171
|
[[nodiscard]] auto is_key_value() const -> bool
|
|
119
172
|
{
|
|
120
|
-
|
|
121
|
-
if (service_tag == string_tags_.end()) {
|
|
122
|
-
return false;
|
|
123
|
-
}
|
|
124
|
-
return service_tag->second == tracing::service::key_value;
|
|
173
|
+
return service_.has_value() && service_.value() == tracing::service::key_value;
|
|
125
174
|
}
|
|
126
175
|
|
|
127
176
|
[[nodiscard]] auto service() const -> std::optional<service_type>
|
|
128
177
|
{
|
|
129
|
-
|
|
130
|
-
if (service_tag == string_tags_.end()) {
|
|
178
|
+
if (!service_.has_value()) {
|
|
131
179
|
return {};
|
|
132
180
|
}
|
|
133
|
-
const auto& service_name =
|
|
181
|
+
const auto& service_name = service_.value();
|
|
134
182
|
if (service_name == tracing::service::key_value) {
|
|
135
183
|
return service_type::key_value;
|
|
136
184
|
}
|
|
@@ -153,65 +201,7 @@ public:
|
|
|
153
201
|
}
|
|
154
202
|
};
|
|
155
203
|
|
|
156
|
-
|
|
157
|
-
class concurrent_fixed_queue
|
|
158
|
-
{
|
|
159
|
-
private:
|
|
160
|
-
std::mutex mutex_;
|
|
161
|
-
std::priority_queue<T> data_;
|
|
162
|
-
std::size_t capacity_{};
|
|
163
|
-
|
|
164
|
-
public:
|
|
165
|
-
using size_type = typename std::priority_queue<T>::size_type;
|
|
166
|
-
|
|
167
|
-
explicit concurrent_fixed_queue(std::size_t capacity)
|
|
168
|
-
: capacity_(capacity)
|
|
169
|
-
{
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
concurrent_fixed_queue(const concurrent_fixed_queue&) = delete;
|
|
173
|
-
concurrent_fixed_queue(concurrent_fixed_queue&&) = delete;
|
|
174
|
-
auto operator=(const concurrent_fixed_queue&) -> concurrent_fixed_queue& = delete;
|
|
175
|
-
auto operator=(concurrent_fixed_queue&&) -> concurrent_fixed_queue& = delete;
|
|
176
|
-
~concurrent_fixed_queue() = default;
|
|
177
|
-
|
|
178
|
-
void pop()
|
|
179
|
-
{
|
|
180
|
-
std::unique_lock<std::mutex> lock(mutex_);
|
|
181
|
-
data_.pop();
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
auto size() -> size_type
|
|
185
|
-
{
|
|
186
|
-
std::unique_lock<std::mutex> lock(mutex_);
|
|
187
|
-
return data_.size();
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
auto empty() -> bool
|
|
191
|
-
{
|
|
192
|
-
const std::unique_lock<std::mutex> lock(mutex_);
|
|
193
|
-
return data_.empty();
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
void emplace(const T&& item)
|
|
197
|
-
{
|
|
198
|
-
const std::unique_lock<std::mutex> lock(mutex_);
|
|
199
|
-
data_.emplace(std::forward<const T>(item));
|
|
200
|
-
if (data_.size() > capacity_) {
|
|
201
|
-
data_.pop();
|
|
202
|
-
}
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
auto steal_data() -> std::priority_queue<T>
|
|
206
|
-
{
|
|
207
|
-
std::priority_queue<T> data;
|
|
208
|
-
const std::unique_lock<std::mutex> lock(mutex_);
|
|
209
|
-
std::swap(data, data_);
|
|
210
|
-
return data;
|
|
211
|
-
}
|
|
212
|
-
};
|
|
213
|
-
|
|
214
|
-
using fixed_span_queue = concurrent_fixed_queue<reported_span>;
|
|
204
|
+
using fixed_span_queue = utils::concurrent_fixed_priority_queue<reported_span>;
|
|
215
205
|
|
|
216
206
|
auto
|
|
217
207
|
convert(const std::shared_ptr<threshold_logging_span>& span) -> reported_span
|
|
@@ -219,45 +209,35 @@ convert(const std::shared_ptr<threshold_logging_span>& span) -> reported_span
|
|
|
219
209
|
tao::json::value entry{
|
|
220
210
|
{ "operation_name", span->name() },
|
|
221
211
|
{ "total_duration_us",
|
|
222
|
-
std::chrono::duration_cast<std::chrono::microseconds>(span->
|
|
212
|
+
std::chrono::duration_cast<std::chrono::microseconds>(span->total_duration()).count() }
|
|
223
213
|
};
|
|
224
214
|
if (span->is_key_value()) {
|
|
225
215
|
entry["last_server_duration_us"] = span->last_server_duration_us();
|
|
226
216
|
entry["total_server_duration_us"] = span->total_server_duration_us();
|
|
227
217
|
}
|
|
228
218
|
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
if (pair != tags.end()) {
|
|
232
|
-
entry["last_operation_id"] = pair->second;
|
|
219
|
+
if (span->operation_id().has_value()) {
|
|
220
|
+
entry["last_operation_id"] = span->operation_id().value();
|
|
233
221
|
}
|
|
234
222
|
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
entry["last_local_id"] = pair->second;
|
|
223
|
+
if (span->last_local_id().has_value()) {
|
|
224
|
+
entry["last_local_id"] = span->last_local_id().value();
|
|
238
225
|
}
|
|
239
226
|
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
entry["last_local_socket"] = pair->second;
|
|
227
|
+
if (span->last_remote_socket().has_value()) {
|
|
228
|
+
entry["last_remote_socket"] = span->last_remote_socket().value();
|
|
243
229
|
}
|
|
244
230
|
|
|
245
|
-
|
|
246
|
-
if (pair != tags.end()) {
|
|
247
|
-
entry["last_remote_socket"] = pair->second;
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
return { span->duration(), std::move(entry) };
|
|
231
|
+
return { span->total_duration(), std::move(entry) };
|
|
251
232
|
}
|
|
252
233
|
|
|
253
234
|
class threshold_logging_tracer_impl
|
|
235
|
+
: public std::enable_shared_from_this<threshold_logging_tracer_impl>
|
|
254
236
|
{
|
|
255
237
|
public:
|
|
256
238
|
threshold_logging_tracer_impl(const threshold_logging_options& options, asio::io_context& ctx)
|
|
257
239
|
: options_(options)
|
|
258
|
-
, emit_orphan_report_(ctx)
|
|
259
240
|
, emit_threshold_report_(ctx)
|
|
260
|
-
, orphan_queue_{ options.orphaned_sample_size }
|
|
261
241
|
{
|
|
262
242
|
threshold_queues_.try_emplace(service_type::key_value, options.threshold_sample_size);
|
|
263
243
|
threshold_queues_.try_emplace(service_type::query, options.threshold_sample_size);
|
|
@@ -274,98 +254,55 @@ public:
|
|
|
274
254
|
|
|
275
255
|
~threshold_logging_tracer_impl()
|
|
276
256
|
{
|
|
277
|
-
emit_orphan_report_.cancel();
|
|
278
257
|
emit_threshold_report_.cancel();
|
|
279
258
|
|
|
280
|
-
log_orphan_report();
|
|
281
259
|
log_threshold_report();
|
|
282
260
|
}
|
|
283
261
|
|
|
284
262
|
void start()
|
|
285
263
|
{
|
|
286
|
-
rearm_orphan_reporter();
|
|
287
264
|
rearm_threshold_reporter();
|
|
288
265
|
}
|
|
289
266
|
|
|
290
267
|
void stop()
|
|
291
268
|
{
|
|
292
|
-
emit_orphan_report_.cancel();
|
|
293
269
|
emit_threshold_report_.cancel();
|
|
294
270
|
}
|
|
295
271
|
|
|
296
|
-
void add_orphan(const std::shared_ptr<threshold_logging_span>& span)
|
|
297
|
-
{
|
|
298
|
-
orphan_queue_.emplace(convert(span));
|
|
299
|
-
}
|
|
300
|
-
|
|
301
272
|
void check_threshold(const std::shared_ptr<threshold_logging_span>& span)
|
|
302
273
|
{
|
|
303
|
-
auto service = span->service();
|
|
274
|
+
const auto service = span->service();
|
|
304
275
|
if (!service.has_value()) {
|
|
305
276
|
return;
|
|
306
277
|
}
|
|
307
|
-
if (span->
|
|
308
|
-
auto queue = threshold_queues_.find(service.value());
|
|
309
|
-
|
|
278
|
+
if (span->total_duration() > options_.threshold_for_service(service.value())) {
|
|
279
|
+
if (const auto queue = threshold_queues_.find(service.value());
|
|
280
|
+
queue != threshold_queues_.end()) {
|
|
310
281
|
queue->second.emplace(convert(span));
|
|
311
282
|
}
|
|
312
283
|
}
|
|
313
284
|
}
|
|
314
285
|
|
|
315
286
|
private:
|
|
316
|
-
void rearm_orphan_reporter()
|
|
317
|
-
{
|
|
318
|
-
emit_orphan_report_.expires_after(options_.orphaned_emit_interval);
|
|
319
|
-
emit_orphan_report_.async_wait([this](std::error_code ec) {
|
|
320
|
-
if (ec == asio::error::operation_aborted) {
|
|
321
|
-
return;
|
|
322
|
-
}
|
|
323
|
-
log_orphan_report();
|
|
324
|
-
rearm_orphan_reporter();
|
|
325
|
-
});
|
|
326
|
-
}
|
|
327
|
-
|
|
328
287
|
void rearm_threshold_reporter()
|
|
329
288
|
{
|
|
330
289
|
emit_threshold_report_.expires_after(options_.threshold_emit_interval);
|
|
331
|
-
emit_threshold_report_.async_wait([
|
|
290
|
+
emit_threshold_report_.async_wait([self = shared_from_this()](std::error_code ec) -> void {
|
|
332
291
|
if (ec == asio::error::operation_aborted) {
|
|
333
292
|
return;
|
|
334
293
|
}
|
|
335
|
-
log_threshold_report();
|
|
336
|
-
rearm_threshold_reporter();
|
|
294
|
+
self->log_threshold_report();
|
|
295
|
+
self->rearm_threshold_reporter();
|
|
337
296
|
});
|
|
338
297
|
}
|
|
339
298
|
|
|
340
|
-
void log_orphan_report()
|
|
341
|
-
{
|
|
342
|
-
if (orphan_queue_.empty()) {
|
|
343
|
-
return;
|
|
344
|
-
}
|
|
345
|
-
auto queue = orphan_queue_.steal_data();
|
|
346
|
-
tao::json::value report{
|
|
347
|
-
{ "count", queue.size() },
|
|
348
|
-
#if COUCHBASE_CXX_CLIENT_DEBUG_BUILD
|
|
349
|
-
{ "emit_interval_ms", options_.orphaned_emit_interval.count() },
|
|
350
|
-
{ "sample_size", options_.orphaned_sample_size },
|
|
351
|
-
#endif
|
|
352
|
-
};
|
|
353
|
-
tao::json::value entries = tao::json::empty_array;
|
|
354
|
-
while (!queue.empty()) {
|
|
355
|
-
entries.emplace_back(queue.top().payload);
|
|
356
|
-
queue.pop();
|
|
357
|
-
}
|
|
358
|
-
report["top"] = entries;
|
|
359
|
-
CB_LOG_WARNING("Orphan responses observed: {}", utils::json::generate(report));
|
|
360
|
-
}
|
|
361
|
-
|
|
362
299
|
void log_threshold_report()
|
|
363
300
|
{
|
|
364
301
|
for (auto& [service, threshold_queue] : threshold_queues_) {
|
|
365
302
|
if (threshold_queue.empty()) {
|
|
366
303
|
continue;
|
|
367
304
|
}
|
|
368
|
-
auto queue = threshold_queue.steal_data();
|
|
305
|
+
auto [queue, _] = threshold_queue.steal_data();
|
|
369
306
|
tao::json::value report{
|
|
370
307
|
{ "count", queue.size() },
|
|
371
308
|
{ "service", fmt::format("{}", service) },
|
|
@@ -388,11 +325,9 @@ private:
|
|
|
388
325
|
}
|
|
389
326
|
}
|
|
390
327
|
|
|
391
|
-
|
|
328
|
+
threshold_logging_options options_;
|
|
392
329
|
|
|
393
|
-
asio::steady_timer emit_orphan_report_;
|
|
394
330
|
asio::steady_timer emit_threshold_report_;
|
|
395
|
-
fixed_span_queue orphan_queue_;
|
|
396
331
|
std::map<service_type, fixed_span_queue> threshold_queues_{};
|
|
397
332
|
};
|
|
398
333
|
|
|
@@ -407,11 +342,7 @@ threshold_logging_tracer::start_span(std::string name,
|
|
|
407
342
|
void
|
|
408
343
|
threshold_logging_tracer::report(const std::shared_ptr<threshold_logging_span>& span)
|
|
409
344
|
{
|
|
410
|
-
|
|
411
|
-
impl_->add_orphan(span);
|
|
412
|
-
} else {
|
|
413
|
-
impl_->check_threshold(span);
|
|
414
|
-
}
|
|
345
|
+
impl_->check_threshold(span);
|
|
415
346
|
}
|
|
416
347
|
|
|
417
348
|
threshold_logging_tracer::threshold_logging_tracer(asio::io_context& ctx,
|
|
@@ -436,9 +367,30 @@ threshold_logging_tracer::stop()
|
|
|
436
367
|
void
|
|
437
368
|
threshold_logging_span::end()
|
|
438
369
|
{
|
|
439
|
-
|
|
370
|
+
total_duration_ = std::chrono::duration_cast<std::chrono::microseconds>(
|
|
440
371
|
std::chrono::system_clock::now() - start_);
|
|
441
|
-
|
|
372
|
+
if (service_.has_value()) {
|
|
373
|
+
tracer_->report(shared_from_this());
|
|
374
|
+
}
|
|
375
|
+
if (name() == tracing::operation::step_dispatch) {
|
|
376
|
+
// Transfer the relevant attributes to the operation-level span
|
|
377
|
+
if (const auto p = std::dynamic_pointer_cast<threshold_logging_span>(parent()); p) {
|
|
378
|
+
if (last_local_id_.has_value()) {
|
|
379
|
+
p->set_last_local_id(last_local_id_.value());
|
|
380
|
+
}
|
|
381
|
+
if (operation_id_.has_value()) {
|
|
382
|
+
p->set_operation_id(operation_id_.value());
|
|
383
|
+
}
|
|
384
|
+
if (peer_hostname_.has_value()) {
|
|
385
|
+
p->set_peer_hostname(peer_hostname_.value());
|
|
386
|
+
}
|
|
387
|
+
if (peer_port_.has_value()) {
|
|
388
|
+
p->set_peer_port(peer_port_.value());
|
|
389
|
+
}
|
|
390
|
+
if (last_server_duration_us_ > 0) {
|
|
391
|
+
p->add_server_duration(last_server_duration_us_);
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
}
|
|
442
395
|
}
|
|
443
|
-
|
|
444
396
|
} // namespace couchbase::core::tracing
|
|
@@ -18,13 +18,14 @@
|
|
|
18
18
|
#include "tracer_wrapper.hxx"
|
|
19
19
|
|
|
20
20
|
#include "constants.hxx"
|
|
21
|
-
|
|
22
|
-
#include <mutex>
|
|
21
|
+
#include "core/logger/logger.hxx"
|
|
23
22
|
|
|
24
23
|
namespace couchbase::core::tracing
|
|
25
24
|
{
|
|
26
|
-
tracer_wrapper::tracer_wrapper(std::shared_ptr<couchbase::tracing::request_tracer> tracer
|
|
25
|
+
tracer_wrapper::tracer_wrapper(std::shared_ptr<couchbase::tracing::request_tracer> tracer,
|
|
26
|
+
std::shared_ptr<cluster_label_listener> label_listener)
|
|
27
27
|
: tracer_{ std::move(tracer) }
|
|
28
|
+
, cluster_label_listener_{ std::move(label_listener) }
|
|
28
29
|
{
|
|
29
30
|
}
|
|
30
31
|
|
|
@@ -46,42 +47,34 @@ tracer_wrapper::create_span(std::string span_name,
|
|
|
46
47
|
-> std::shared_ptr<couchbase::tracing::request_span>
|
|
47
48
|
{
|
|
48
49
|
auto span = tracer_->start_span(std::move(span_name), std::move(parent_span));
|
|
49
|
-
span->
|
|
50
|
-
|
|
51
|
-
std::optional<std::string> cluster_name;
|
|
52
|
-
std::optional<std::string> cluster_uuid;
|
|
53
|
-
{
|
|
54
|
-
const std::shared_lock lock{ cluster_labels_mutex_ };
|
|
55
|
-
cluster_name = cluster_name_;
|
|
56
|
-
cluster_uuid = cluster_uuid_;
|
|
50
|
+
if (!span->uses_tags()) {
|
|
51
|
+
return span;
|
|
57
52
|
}
|
|
58
53
|
|
|
54
|
+
span->add_tag(attributes::common::system, "couchbase");
|
|
55
|
+
|
|
56
|
+
auto [cluster_name, cluster_uuid] = cluster_label_listener_->cluster_labels();
|
|
59
57
|
if (cluster_name) {
|
|
60
|
-
span->add_tag(attributes::cluster_name, cluster_name.value());
|
|
58
|
+
span->add_tag(attributes::common::cluster_name, cluster_name.value());
|
|
61
59
|
}
|
|
62
60
|
if (cluster_uuid) {
|
|
63
|
-
span->add_tag(attributes::cluster_uuid, cluster_uuid.value());
|
|
61
|
+
span->add_tag(attributes::common::cluster_uuid, cluster_uuid.value());
|
|
64
62
|
}
|
|
65
63
|
|
|
66
64
|
return span;
|
|
67
65
|
}
|
|
68
66
|
|
|
69
|
-
|
|
70
|
-
tracer_wrapper::
|
|
67
|
+
auto
|
|
68
|
+
tracer_wrapper::wrapped() -> std::shared_ptr<couchbase::tracing::request_tracer>
|
|
71
69
|
{
|
|
72
|
-
|
|
73
|
-
if (config.cluster_uuid.has_value()) {
|
|
74
|
-
cluster_uuid_ = config.cluster_uuid;
|
|
75
|
-
}
|
|
76
|
-
if (config.cluster_name.has_value()) {
|
|
77
|
-
cluster_name_ = config.cluster_name;
|
|
78
|
-
}
|
|
70
|
+
return tracer_;
|
|
79
71
|
}
|
|
80
72
|
|
|
81
73
|
auto
|
|
82
|
-
tracer_wrapper::create(std::shared_ptr<couchbase::tracing::request_tracer> tracer
|
|
74
|
+
tracer_wrapper::create(std::shared_ptr<couchbase::tracing::request_tracer> tracer,
|
|
75
|
+
std::shared_ptr<cluster_label_listener> label_listener)
|
|
83
76
|
-> std::shared_ptr<tracer_wrapper>
|
|
84
77
|
{
|
|
85
|
-
return std::make_shared<tracer_wrapper>(std::move(tracer));
|
|
78
|
+
return std::make_shared<tracer_wrapper>(std::move(tracer), std::move(label_listener));
|
|
86
79
|
}
|
|
87
80
|
} // namespace couchbase::core::tracing
|
|
@@ -17,8 +17,7 @@
|
|
|
17
17
|
|
|
18
18
|
#pragma once
|
|
19
19
|
|
|
20
|
-
#include "core/
|
|
21
|
-
#include "core/topology/configuration.hxx"
|
|
20
|
+
#include "core/cluster_label_listener.hxx"
|
|
22
21
|
|
|
23
22
|
#include <couchbase/tracing/request_span.hxx>
|
|
24
23
|
#include <couchbase/tracing/request_tracer.hxx>
|
|
@@ -30,10 +29,11 @@
|
|
|
30
29
|
|
|
31
30
|
namespace couchbase::core::tracing
|
|
32
31
|
{
|
|
33
|
-
class tracer_wrapper
|
|
32
|
+
class tracer_wrapper
|
|
34
33
|
{
|
|
35
34
|
public:
|
|
36
|
-
explicit tracer_wrapper(std::shared_ptr<couchbase::tracing::request_tracer> tracer
|
|
35
|
+
explicit tracer_wrapper(std::shared_ptr<couchbase::tracing::request_tracer> tracer,
|
|
36
|
+
std::shared_ptr<cluster_label_listener> label_listener);
|
|
37
37
|
|
|
38
38
|
void start();
|
|
39
39
|
void stop();
|
|
@@ -42,16 +42,14 @@ public:
|
|
|
42
42
|
std::shared_ptr<couchbase::tracing::request_span> parent_span)
|
|
43
43
|
-> std::shared_ptr<couchbase::tracing::request_span>;
|
|
44
44
|
|
|
45
|
-
|
|
45
|
+
[[nodiscard]] auto wrapped() -> std::shared_ptr<couchbase::tracing::request_tracer>;
|
|
46
46
|
|
|
47
|
-
[[nodiscard]] static auto create(std::shared_ptr<couchbase::tracing::request_tracer> tracer
|
|
47
|
+
[[nodiscard]] static auto create(std::shared_ptr<couchbase::tracing::request_tracer> tracer,
|
|
48
|
+
std::shared_ptr<cluster_label_listener> label_listener)
|
|
48
49
|
-> std::shared_ptr<tracer_wrapper>;
|
|
49
50
|
|
|
50
51
|
private:
|
|
51
52
|
std::shared_ptr<couchbase::tracing::request_tracer> tracer_;
|
|
52
|
-
|
|
53
|
-
std::optional<std::string> cluster_name_{};
|
|
54
|
-
std::optional<std::string> cluster_uuid_{};
|
|
55
|
-
std::shared_mutex cluster_labels_mutex_{};
|
|
53
|
+
std::shared_ptr<couchbase::core::cluster_label_listener> cluster_label_listener_;
|
|
56
54
|
};
|
|
57
55
|
} // namespace couchbase::core::tracing
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
/* -*- Mode: C++; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */
|
|
2
|
+
/*
|
|
3
|
+
* Copyright 2025. Couchbase, Inc.
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
#include "wrapper_sdk_tracer.hxx"
|
|
19
|
+
|
|
20
|
+
#include "core/logger/logger.hxx"
|
|
21
|
+
|
|
22
|
+
namespace couchbase::core::tracing
|
|
23
|
+
{
|
|
24
|
+
auto
|
|
25
|
+
wrapper_sdk_tracer::start_span(std::string name,
|
|
26
|
+
std::shared_ptr<couchbase::tracing::request_span> parent)
|
|
27
|
+
-> std::shared_ptr<couchbase::tracing::request_span>
|
|
28
|
+
{
|
|
29
|
+
const auto parent_wrapper_span = std::dynamic_pointer_cast<wrapper_sdk_span>(parent);
|
|
30
|
+
if (!parent_wrapper_span) {
|
|
31
|
+
// If no parent span is provided, wrappers have no way of accessing any child spans created, so
|
|
32
|
+
// there is no reason to create spans.
|
|
33
|
+
return noop_instance_;
|
|
34
|
+
}
|
|
35
|
+
const auto span = std::make_shared<wrapper_sdk_span>(std::move(name), std::move(parent));
|
|
36
|
+
parent_wrapper_span->add_child(span);
|
|
37
|
+
return span;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
wrapper_sdk_span::wrapper_sdk_span(std::string name)
|
|
41
|
+
: couchbase::tracing::request_span{ std::move(name) }
|
|
42
|
+
{
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
wrapper_sdk_span::wrapper_sdk_span(std::string name,
|
|
46
|
+
const std::shared_ptr<couchbase::tracing::request_span>& parent)
|
|
47
|
+
: couchbase::tracing::request_span{ std::move(name) }
|
|
48
|
+
, parent_{ parent }
|
|
49
|
+
{
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
void
|
|
53
|
+
wrapper_sdk_span::add_child(const std::shared_ptr<wrapper_sdk_span>& child)
|
|
54
|
+
{
|
|
55
|
+
const std::scoped_lock lock(children_mutex_);
|
|
56
|
+
children_.emplace_back(child);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
void
|
|
60
|
+
wrapper_sdk_span::add_tag(const std::string& name, std::uint64_t value)
|
|
61
|
+
{
|
|
62
|
+
uint_tags_.emplace(name, value);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
void
|
|
66
|
+
wrapper_sdk_span::add_tag(const std::string& name, const std::string& value)
|
|
67
|
+
{
|
|
68
|
+
string_tags_.emplace(name, value);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
void
|
|
72
|
+
wrapper_sdk_span::end()
|
|
73
|
+
{
|
|
74
|
+
end_time_ = std::chrono::system_clock::now();
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
auto
|
|
78
|
+
wrapper_sdk_span::uint_tags() const -> const std::map<std::string, std::uint64_t>&
|
|
79
|
+
{
|
|
80
|
+
return uint_tags_;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
auto
|
|
84
|
+
wrapper_sdk_span::string_tags() const -> const std::map<std::string, std::string>&
|
|
85
|
+
{
|
|
86
|
+
return string_tags_;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
auto
|
|
90
|
+
wrapper_sdk_span::children() -> std::vector<std::shared_ptr<wrapper_sdk_span>>
|
|
91
|
+
{
|
|
92
|
+
const std::scoped_lock lock(children_mutex_);
|
|
93
|
+
return children_;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
auto
|
|
97
|
+
wrapper_sdk_span::start_time() const -> const std::chrono::system_clock::time_point&
|
|
98
|
+
{
|
|
99
|
+
return start_time_;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
auto
|
|
103
|
+
wrapper_sdk_span::end_time() const -> const std::chrono::system_clock::time_point&
|
|
104
|
+
{
|
|
105
|
+
return end_time_;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
auto
|
|
109
|
+
wrapper_sdk_span::parent() const -> std::shared_ptr<couchbase::tracing::request_span>
|
|
110
|
+
{
|
|
111
|
+
return parent_.lock();
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
} // namespace couchbase::core::tracing
|