Skip to content

Commit

Permalink
add parent span support
Browse files Browse the repository at this point in the history
  • Loading branch information
Matt-Woz committed Jul 27, 2023
1 parent d7efc7a commit 8deaf53
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion core/impl/lookup_in_replica.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ lookup_in_replica_request::encode_to(lookup_in_replica_request::encoded_request_
encoded.opaque(opaque);
encoded.partition(partition);
encoded.body().id(id);
encoded.body().read_replica(read_replica);
encoded.body().read_replica(true);
encoded.body().specs(specs);
return {};
}
Expand Down
2 changes: 1 addition & 1 deletion core/impl/lookup_in_replica.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ struct lookup_in_replica_request {
document_id id;
std::vector<couchbase::core::impl::subdoc::command> specs{};
std::optional<std::chrono::milliseconds> timeout{};
bool read_replica{ true };
std::shared_ptr<couchbase::tracing::request_span> parent_span{ nullptr };
std::uint16_t partition{};
std::uint32_t opaque{};
io::retry_context<false> retries{};
Expand Down
5 changes: 3 additions & 2 deletions core/operations/document_lookup_in_all_replicas.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,14 @@ struct lookup_in_all_replicas_request {
core::document_id id;
std::vector<couchbase::core::impl::subdoc::command> specs{};
std::optional<std::chrono::milliseconds> timeout{};
std::shared_ptr<couchbase::tracing::request_span> parent_span{ nullptr };

template<typename Core, typename Handler>
void execute(Core core, Handler handler)
{
core->with_bucket_configuration(
id.bucket(),
[core, id = id, timeout = timeout, specs = specs, h = std::forward<Handler>(handler)](
[core, id = id, timeout = timeout, specs = specs, parent_span = parent_span, h = std::forward<Handler>(handler)](
std::error_code ec, const topology::configuration& config) mutable {
if (ec) {
std::optional<std::string> first_error_path{};
Expand Down Expand Up @@ -98,7 +99,7 @@ struct lookup_in_all_replicas_request {
for (std::size_t idx = 1U; idx <= config.num_replicas.value_or(0U); ++idx) {
document_id replica_id{ id };
replica_id.node_index(idx);
core->execute(impl::lookup_in_replica_request{ std::move(replica_id), specs, timeout },
core->execute(impl::lookup_in_replica_request{ std::move(replica_id), specs, timeout, parent_span },
[ctx](impl::lookup_in_replica_response&& resp) {
handler_type local_handler{};
{
Expand Down
5 changes: 3 additions & 2 deletions core/operations/document_lookup_in_any_replica.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,14 @@ struct lookup_in_any_replica_request {
core::document_id id;
std::vector<couchbase::core::impl::subdoc::command> specs{};
std::optional<std::chrono::milliseconds> timeout{};
std::shared_ptr<couchbase::tracing::request_span> parent_span{ nullptr };

template<typename Core, typename Handler>
void execute(Core core, Handler handler)
{
core->with_bucket_configuration(
id.bucket(),
[core, id = id, timeout = timeout, specs = specs, h = std::forward<Handler>(handler)](
[core, id = id, timeout = timeout, specs = specs, parent_span = parent_span, h = std::forward<Handler>(handler)](
std::error_code ec, const topology::configuration& config) mutable {
if (ec) {
std::optional<std::string> first_error_path{};
Expand All @@ -81,7 +82,7 @@ struct lookup_in_any_replica_request {
for (std::size_t idx = 1U; idx <= config.num_replicas.value_or(0U); ++idx) {
document_id replica_id{ id };
replica_id.node_index(idx);
core->execute(impl::lookup_in_replica_request{ std::move(replica_id), specs, timeout },
core->execute(impl::lookup_in_replica_request{ std::move(replica_id), specs, timeout, parent_span },
[ctx](impl::lookup_in_replica_response&& resp) {
handler_type local_handler;
{
Expand Down

0 comments on commit 8deaf53

Please sign in to comment.