Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions core/impl/analytics.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ build_analytics_request(std::string statement,
std::move(options.client_context_id),
options.timeout,
};
request.parent_span = options.parent_span;
if (!options.raw.empty()) {
for (auto& [name, value] : options.raw) {
request.raw[name] = std::move(value);
Expand Down
30 changes: 27 additions & 3 deletions core/impl/collection.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ class collection_impl : public std::enable_shared_from_this<collection_impl>
{},
options.timeout,
{ options.retry_strategy },
options.parent_span,
},
[handler = std::move(handler)](auto resp) mutable {
return handler(core::impl::make_error(std::move(resp.ctx)),
Expand All @@ -166,6 +167,7 @@ class collection_impl : public std::enable_shared_from_this<collection_impl>
false,
options.timeout,
{ options.retry_strategy },
options.parent_span,
},
[handler = std::move(handler)](auto resp) mutable {
std::optional<std::chrono::system_clock::time_point> expiry_time{};
Expand All @@ -190,6 +192,7 @@ class collection_impl : public std::enable_shared_from_this<collection_impl>
expiry,
options.timeout,
{ options.retry_strategy },
options.parent_span,
},
[handler = std::move(handler)](auto resp) mutable {
return handler(core::impl::make_error(std::move(resp.ctx)),
Expand All @@ -210,6 +213,7 @@ class collection_impl : public std::enable_shared_from_this<collection_impl>
expiry,
options.timeout,
{ options.retry_strategy },
options.parent_span,
},
[handler = std::move(handler)](const auto& resp) mutable {
return handler(core::impl::make_error(std::move(resp.ctx)), result{ resp.cas });
Expand Down Expand Up @@ -279,6 +283,7 @@ class collection_impl : public std::enable_shared_from_this<collection_impl>
options.durability_level,
options.timeout,
{ options.retry_strategy },
options.parent_span,
},
[handler = std::move(handler)](auto resp) mutable {
if (resp.ctx.ec()) {
Expand All @@ -290,7 +295,14 @@ class collection_impl : public std::enable_shared_from_this<collection_impl>
}

core::operations::remove_request request{
id, {}, {}, options.cas, durability_level::none, options.timeout, { options.retry_strategy },
id,
{},
{},
options.cas,
durability_level::none,
options.timeout,
{ options.retry_strategy },
options.parent_span,
};
return core_.execute(std::move(request),
[core = core_, id = std::move(id), options, handler = std::move(handler)](
Expand Down Expand Up @@ -332,6 +344,7 @@ class collection_impl : public std::enable_shared_from_this<collection_impl>
static_cast<uint32_t>(lock_duration.count()),
options.timeout,
{ options.retry_strategy },
options.parent_span,
},
[handler = std::move(handler)](auto&& resp) mutable {
return handler(core::impl::make_error(std::move(resp.ctx)),
Expand All @@ -352,6 +365,7 @@ class collection_impl : public std::enable_shared_from_this<collection_impl>
cas,
options.timeout,
{ options.retry_strategy },
options.parent_span,
},
[handler = std::move(handler)](auto&& resp) mutable {
return handler(core::impl::make_error(std::move(resp.ctx)));
Expand All @@ -369,6 +383,7 @@ class collection_impl : public std::enable_shared_from_this<collection_impl>
{},
options.timeout,
{ options.retry_strategy },
options.parent_span,
},
[handler = std::move(handler)](auto&& resp) mutable {
return handler(core::impl::make_error(std::move(resp.ctx)),
Expand All @@ -395,6 +410,7 @@ class collection_impl : public std::enable_shared_from_this<collection_impl>
specs,
options.timeout,
{ options.retry_strategy },
options.parent_span,
},
[handler = std::move(handler)](auto resp) mutable {
if (resp.ctx.ec()) {
Expand Down Expand Up @@ -427,7 +443,7 @@ class collection_impl : public std::enable_shared_from_this<collection_impl>
core::document_id{ bucket_name_, scope_name_, name_, std::move(document_key) },
specs,
options.timeout,
{},
options.parent_span,
options.read_preference,
},
[handler = std::move(handler)](auto resp) mutable {
Expand Down Expand Up @@ -465,7 +481,7 @@ class collection_impl : public std::enable_shared_from_this<collection_impl>
core::document_id{ bucket_name_, scope_name_, name_, std::move(document_key) },
specs,
options.timeout,
{},
options.parent_span,
options.read_preference,
},
[handler = std::move(handler)](auto resp) mutable {
Expand Down Expand Up @@ -514,6 +530,7 @@ class collection_impl : public std::enable_shared_from_this<collection_impl>
options.timeout,
{ options.retry_strategy },
options.preserve_expiry,
options.parent_span,
},
[handler = std::move(handler)](auto resp) mutable {
if (resp.ctx.ec()) {
Expand Down Expand Up @@ -548,6 +565,7 @@ class collection_impl : public std::enable_shared_from_this<collection_impl>
options.timeout,
{ options.retry_strategy },
options.preserve_expiry,
options.parent_span,
};
return core_.execute(
std::move(request),
Expand Down Expand Up @@ -611,6 +629,7 @@ class collection_impl : public std::enable_shared_from_this<collection_impl>
options.timeout,
{ options.retry_strategy },
options.preserve_expiry,
options.parent_span,
},
[handler = std::move(handler)](auto resp) mutable {
return handler(core::impl::make_error(std::move(resp.ctx)),
Expand All @@ -629,6 +648,7 @@ class collection_impl : public std::enable_shared_from_this<collection_impl>
options.timeout,
{ options.retry_strategy },
options.preserve_expiry,
options.parent_span,
};
return core_.execute(
std::move(request),
Expand Down Expand Up @@ -681,6 +701,7 @@ class collection_impl : public std::enable_shared_from_this<collection_impl>
options.durability_level,
options.timeout,
{ options.retry_strategy },
options.parent_span,
},
[handler = std::move(handler)](auto&& resp) mutable {
if (resp.ctx.ec()) {
Expand All @@ -701,6 +722,7 @@ class collection_impl : public std::enable_shared_from_this<collection_impl>
durability_level::none,
options.timeout,
{ options.retry_strategy },
options.parent_span,
};
return core_.execute(
std::move(request),
Expand Down Expand Up @@ -754,6 +776,7 @@ class collection_impl : public std::enable_shared_from_this<collection_impl>
options.timeout,
{ options.retry_strategy },
options.preserve_expiry,
options.parent_span,
},
[handler = std::move(handler)](auto resp) mutable {
if (resp.ctx.ec()) {
Expand All @@ -776,6 +799,7 @@ class collection_impl : public std::enable_shared_from_this<collection_impl>
options.timeout,
{ options.retry_strategy },
options.preserve_expiry,
options.parent_span,
};
return core_.execute(std::move(request),
[core = core_, id = std::move(id), options, handler = std::move(handler)](
Expand Down
1 change: 1 addition & 0 deletions core/impl/query.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ build_query_request(std::string statement,
std::move(query_context), std::move(options.client_context_id),
options.timeout, options.profile,
};
request.parent_span = options.parent_span;
if (!options.raw.empty()) {
for (auto& [name, value] : options.raw) {
request.raw[name] = std::move(value);
Expand Down
2 changes: 2 additions & 0 deletions core/impl/search.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ build_search_request(std::string index_name,
options.client_context_id,
options.timeout,
};
request.parent_span = options.parent_span;
return request;
}

Expand Down Expand Up @@ -207,6 +208,7 @@ build_search_request(std::string index_name,
options.client_context_id,
options.timeout,
};
core_request.parent_span = options.parent_span;

if (auto vector_search = request.vector_search(); vector_search.has_value()) {
core_request.vector_search = core::utils::json::generate_binary(vector_search->query);
Expand Down
5 changes: 5 additions & 0 deletions core/meta/features.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -201,3 +201,8 @@
* The Metrics API for OpenTelemetry was GA'd in version 1.7.0.
*/
#define COUCHBASE_CXX_CLIENT_OTEL_METER_USES_GA_METRICS_API 1

/**
* All options classes in the Public API expose the parent_span option.
*/
#define COUCHBASE_CXX_CLIENT_PUBLIC_API_PARENT_SPAN 1
17 changes: 16 additions & 1 deletion couchbase/common_options.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#pragma once

#include <couchbase/retry_strategy.hxx>
#include <couchbase/tracing/request_span.hxx>

#include <chrono>
#include <memory>
Expand Down Expand Up @@ -69,6 +70,18 @@ public:
return self();
}

/**
* @param span
*
* @since 1.0.4
* @volatile
*/
auto parent_span(std::shared_ptr<tracing::request_span> span) -> derived_class&
{
parent_span_ = std::move(span);
return self();
}

/**
* Immutable value object representing consistent options.
*
Expand All @@ -78,6 +91,7 @@ public:
struct built {
const std::optional<std::chrono::milliseconds> timeout;
const std::shared_ptr<couchbase::retry_strategy> retry_strategy;
const std::shared_ptr<tracing::request_span> parent_span;
};

protected:
Expand All @@ -88,7 +102,7 @@ protected:
*/
[[nodiscard]] auto build_common_options() const -> built
{
return { timeout_, retry_strategy_ };
return { timeout_, retry_strategy_, parent_span_ };
}

/**
Expand All @@ -107,6 +121,7 @@ protected:
private:
std::optional<std::chrono::milliseconds> timeout_{};
std::shared_ptr<couchbase::retry_strategy> retry_strategy_{ nullptr };
std::shared_ptr<tracing::request_span> parent_span_{ nullptr };
};

} // namespace couchbase
Loading