@@ -34,20 +34,20 @@ namespace {
3434using ReadResponse =
3535 ::google::cloud::storage_experimental::AsyncReaderConnection::ReadResponse;
3636using ::google::cloud::storage_experimental::ObjectDescriptorConnection;
37+ using ::google::cloud::storage_experimental::ReadPayload;
3738using ::google::cloud::storage_mocks::MockAsyncObjectDescriptorConnection;
3839using ::google::cloud::storage_mocks::MockAsyncReaderConnection;
39- using ::google::cloud::storage_experimental::ReadPayload;
4040using ::google::cloud::testing_util::EventNamed;
4141using ::google::cloud::testing_util::InstallSpanCatcher;
4242using ::google::cloud::testing_util::OTelAttribute;
4343using ::google::cloud::testing_util::OTelContextCaptured;
44- using ::google::cloud::testing_util::ThereIsAnActiveSpan;
4544using ::google::cloud::testing_util::PromiseWithOTelContext;
4645using ::google::cloud::testing_util::SpanEventAttributesAre;
4746using ::google::cloud::testing_util::SpanHasInstrumentationScope;
4847using ::google::cloud::testing_util::SpanKindIsClient;
4948using ::google::cloud::testing_util::SpanNamed;
5049using ::google::cloud::testing_util::SpanWithStatus;
50+ using ::google::cloud::testing_util::ThereIsAnActiveSpan;
5151using ::testing::_;
5252
5353// A helper to set expectations on a mock async reader. It captures the OTel
@@ -103,7 +103,8 @@ TEST(ObjectDescriptorConnectionTracing, ReadThenRead) {
103103 namespace sc = ::opentelemetry::trace::SemanticConventions;
104104 auto span_catcher = InstallSpanCatcher ();
105105
106- auto mock_connection = std::make_shared<MockAsyncObjectDescriptorConnection>();
106+ auto mock_connection =
107+ std::make_shared<MockAsyncObjectDescriptorConnection>();
107108 auto * mock_reader_ptr = new MockAsyncReaderConnection;
108109 PromiseWithOTelContext<ReadResponse> p;
109110 EXPECT_CALL (*mock_reader_ptr, Read).WillOnce (expect_context (p));
@@ -126,27 +127,25 @@ TEST(ObjectDescriptorConnectionTracing, ReadThenRead) {
126127
127128 auto spans = span_catcher->GetSpans ();
128129 EXPECT_THAT (
129- spans,
130- ElementsAre (AllOf (
131- SpanNamed (" test-span" ),
132- SpanWithStatus (opentelemetry::trace::StatusCode::kOk ),
133- SpanHasInstrumentationScope (), SpanKindIsClient (),
134- SpanHasEvents (
135- AllOf (EventNamed (" gl-cpp.open.read" ),
136- SpanEventAttributesAre (
137- OTelAttribute<std::int64_t >(" read-length" , 0 ),
138- OTelAttribute<std::int64_t >(" read-start" , 0 ),
139- OTelAttribute<std::string>(sc::kThreadId , _))),
140- AllOf (
141- EventNamed (" gl-cpp.read" ),
142- SpanEventAttributesAre (
143- OTelAttribute<std::int64_t >(" message.starting_offset" ,
144- 123 ),
145- OTelAttribute<std::string>(sc::kThreadId , _),
146- OTelAttribute<std::int64_t >(" rpc.message.id" , 1 ),
147- // THIS WAS THE MISSING ATTRIBUTE:
148- OTelAttribute<std::string>(" rpc.message.type" ,
149- " RECEIVED" )))))));
130+ spans, ElementsAre (AllOf (
131+ SpanNamed (" test-span" ),
132+ SpanWithStatus (opentelemetry::trace::StatusCode::kOk ),
133+ SpanHasInstrumentationScope (), SpanKindIsClient (),
134+ SpanHasEvents (
135+ AllOf (EventNamed (" gl-cpp.open.read" ),
136+ SpanEventAttributesAre (
137+ OTelAttribute<std::int64_t >(" read-length" , 0 ),
138+ OTelAttribute<std::int64_t >(" read-start" , 0 ),
139+ OTelAttribute<std::string>(sc::kThreadId , _))),
140+ AllOf (EventNamed (" gl-cpp.read" ),
141+ SpanEventAttributesAre (
142+ OTelAttribute<std::int64_t >(
143+ " message.starting_offset" , 123 ),
144+ OTelAttribute<std::string>(sc::kThreadId , _),
145+ OTelAttribute<std::int64_t >(" rpc.message.id" , 1 ),
146+ // THIS WAS THE MISSING ATTRIBUTE:
147+ OTelAttribute<std::string>(" rpc.message.type" ,
148+ " RECEIVED" )))))));
150149}
151150
152151} // namespace
0 commit comments