Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cleanup(storage): address post-merge comments #14459

Merged
merged 1 commit into from
Jul 11, 2024
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
5 changes: 5 additions & 0 deletions google/cloud/storage/internal/tracing_object_read_source.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,12 @@ namespace storage_internal {
GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN

/**
* Maintains a single span for a download, including resumed requests.
*
* Downloads may issue additional RPCs, with their corresponding spans, after
* the function that function that starts them returns. We need to hold the
* initial span somewhere, and we need to activate that span before calling any
* functions that may create RPCs.
*/
class TracingObjectReadSource : public storage::internal::ObjectReadSource {
public:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ using ::google::cloud::storage::testing::MockObjectReadSource;
using ::google::cloud::storage::testing::canonical_errors::PermanentError;
using ::google::cloud::testing_util::EventNamed;
using ::google::cloud::testing_util::InstallSpanCatcher;
using ::google::cloud::testing_util::IsActive;
using ::google::cloud::testing_util::IsOkAndHolds;
using ::google::cloud::testing_util::OTelAttribute;
using ::google::cloud::testing_util::SpanEventAttributesAre;
Expand All @@ -43,7 +44,6 @@ using ::google::cloud::testing_util::SpanNamed;
using ::google::cloud::testing_util::SpanWithParent;
using ::google::cloud::testing_util::SpanWithStatus;
using ::google::cloud::testing_util::StatusIs;
using ::google::cloud::testing_util::ThereIsAnActiveSpan;
using ::testing::AllOf;
using ::testing::ResultOf;
using ::testing::Return;
Expand Down Expand Up @@ -77,17 +77,13 @@ TEST(TracingObjectReadSourceSpan, FullDownload) {
EXPECT_CALL(*mock, IsOpen).WillOnce(Return(true));
EXPECT_CALL(*mock, Read)
.WillOnce([root] {
EXPECT_TRUE(ThereIsAnActiveSpan());
EXPECT_EQ(opentelemetry::trace::Tracer::GetCurrentSpan()->GetContext(),
root->GetContext());
EXPECT_THAT(root, IsActive());
auto c1 = internal::MakeSpan("Child1");
internal::EndSpan(*c1);
return ReadSourceResult{/*.bytes_received=*/1234, {}};
})
.WillOnce([root] {
EXPECT_TRUE(ThereIsAnActiveSpan());
EXPECT_EQ(opentelemetry::trace::Tracer::GetCurrentSpan()->GetContext(),
root->GetContext());
EXPECT_THAT(root, IsActive());
auto c2 = internal::MakeSpan("Child2");
auto c3 = internal::MakeSpan("Child3");
internal::EndSpan(*c3);
Expand Down Expand Up @@ -128,17 +124,13 @@ TEST(TracingObjectReadSourceSpan, FailedDownload) {
EXPECT_CALL(*mock, IsOpen).WillOnce(Return(true));
EXPECT_CALL(*mock, Read)
.WillOnce([root] {
EXPECT_TRUE(ThereIsAnActiveSpan());
EXPECT_EQ(opentelemetry::trace::Tracer::GetCurrentSpan()->GetContext(),
root->GetContext());
EXPECT_THAT(root, IsActive());
auto c1 = internal::MakeSpan("Child1");
internal::EndSpan(*c1);
return ReadSourceResult{/*.bytes_received=*/1234, {}};
})
.WillOnce([root] {
EXPECT_TRUE(ThereIsAnActiveSpan());
EXPECT_EQ(opentelemetry::trace::Tracer::GetCurrentSpan()->GetContext(),
root->GetContext());
EXPECT_THAT(root, IsActive());
auto c2 = internal::MakeSpan("Child2");
auto c3 = internal::MakeSpan("Child3");
internal::EndSpan(*c3);
Expand Down Expand Up @@ -176,9 +168,7 @@ TEST(TracingObjectReadSourceSpan, CloseDownload) {
auto mock = std::make_unique<MockObjectReadSource>();
EXPECT_CALL(*mock, IsOpen).WillOnce(Return(true));
EXPECT_CALL(*mock, Read).WillOnce([root] {
EXPECT_TRUE(ThereIsAnActiveSpan());
EXPECT_EQ(opentelemetry::trace::Tracer::GetCurrentSpan()->GetContext(),
root->GetContext());
EXPECT_THAT(root, IsActive());
auto c1 = internal::MakeSpan("Child1");
internal::EndSpan(*c1);
return ReadSourceResult{/*.bytes_received=*/1234, {}};
Expand Down
Loading