From 04cad432b64846e7c81e98c6c5683df90214e912 Mon Sep 17 00:00:00 2001 From: Darren Bolduc Date: Wed, 26 Jun 2024 15:43:23 -0400 Subject: [PATCH] chore(otel): use newer messaging semantic conventions (#14373) --- .../blocking_publisher_tracing_connection.cc | 2 +- .../internal/publisher_tracing_connection.cc | 2 +- .../publisher_tracing_connection_test.cc | 8 ++- .../internal/subscriber_tracing_connection.cc | 2 +- .../subscriber_tracing_connection_test.cc | 10 ++-- .../pubsub/internal/tracing_batch_callback.cc | 5 +- .../internal/tracing_batch_callback_test.cc | 12 +++- .../pubsub/internal/tracing_batch_sink.cc | 4 +- .../internal/tracing_batch_sink_test.cc | 10 ++-- .../tracing_exactly_once_ack_handler.cc | 6 +- .../tracing_exactly_once_ack_handler_test.cc | 8 ++- .../internal/tracing_pull_ack_handler.cc | 6 +- .../internal/tracing_pull_ack_handler_test.cc | 20 ++++--- .../internal/tracing_pull_lease_manager.cc | 2 +- .../tracing_pull_lease_manager_test.cc | 10 ++-- .../async/reader_connection_tracing.cc | 28 +++++---- .../async/reader_connection_tracing_test.cc | 60 +++++++++++-------- .../async/writer_connection_tracing.cc | 58 +++++++++--------- .../async/writer_connection_tracing_test.cc | 11 ++-- 19 files changed, 157 insertions(+), 107 deletions(-) diff --git a/google/cloud/pubsub/internal/blocking_publisher_tracing_connection.cc b/google/cloud/pubsub/internal/blocking_publisher_tracing_connection.cc index d568c41e5a3da..603d98b58776b 100644 --- a/google/cloud/pubsub/internal/blocking_publisher_tracing_connection.cc +++ b/google/cloud/pubsub/internal/blocking_publisher_tracing_connection.cc @@ -42,7 +42,7 @@ opentelemetry::nostd::shared_ptr StartPublishSpan( {{sc::kMessagingSystem, "gcp_pubsub"}, {sc::kMessagingDestinationName, topic.topic_id()}, {"gcp.project_id", topic.project_id()}, - {sc::kMessagingOperation, "create"}, + {/*sc::kMessagingOperationType=*/"messaging.operation.type", "create"}, {/*sc::kMessagingMessageEnvelopeSize=*/"messaging.message.envelope.size", static_cast(MessageSize(m))}, {sc::kCodeFunction, "pubsub::BlockingPublisher::Publish"}}, diff --git a/google/cloud/pubsub/internal/publisher_tracing_connection.cc b/google/cloud/pubsub/internal/publisher_tracing_connection.cc index 37f32fa95a0fb..d0156ec3c2a68 100644 --- a/google/cloud/pubsub/internal/publisher_tracing_connection.cc +++ b/google/cloud/pubsub/internal/publisher_tracing_connection.cc @@ -52,7 +52,7 @@ opentelemetry::nostd::shared_ptr StartPublishSpan( {{sc::kMessagingSystem, "gcp_pubsub"}, {sc::kMessagingDestinationName, topic.topic_id()}, {"gcp.project_id", topic.project_id()}, - {sc::kMessagingOperation, "create"}, + {/*sc::kMessagingOperationType=*/"messaging.operation.type", "create"}, {/*sc::kMessagingMessageEnvelopeSize=*/"messaging.message.envelope.size", static_cast(MessageSize(m))}, {sc::kCodeFunction, "pubsub::PublisherConnection::Publish"}}, diff --git a/google/cloud/pubsub/internal/publisher_tracing_connection_test.cc b/google/cloud/pubsub/internal/publisher_tracing_connection_test.cc index c87e8d600193f..9cb827b329f63 100644 --- a/google/cloud/pubsub/internal/publisher_tracing_connection_test.cc +++ b/google/cloud/pubsub/internal/publisher_tracing_connection_test.cc @@ -95,7 +95,9 @@ TEST(PublisherTracingConnectionTest, PublishSpanOnSuccess) { OTelAttribute(/*sc::kMessagingMessageEnvelopeSize=*/ "messaging.message.envelope.size", 45), - OTelAttribute(sc::kMessagingOperation, "create"), + OTelAttribute( + /*sc::kMessagingOperationType=*/"messaging.operation.type", + "create"), OTelAttribute(sc::kMessagingMessageId, "test-id-0"), OTelAttribute( sc::kCodeFunction, @@ -137,7 +139,9 @@ TEST(PublisherTracingConnectionTest, PublishSpanOnError) { OTelAttribute( "messaging.gcp_pubsub.message.ordering_key", "ordering-key-0"), - OTelAttribute(sc::kMessagingOperation, "create"), + OTelAttribute( + /*sc::kMessagingOperationType=*/"messaging.operation.type", + "create"), OTelAttribute("gl-cpp.status_code", kErrorCode), OTelAttribute(/*sc::kMessagingMessageEnvelopeSize=*/ "messaging.message.envelope.size", diff --git a/google/cloud/pubsub/internal/subscriber_tracing_connection.cc b/google/cloud/pubsub/internal/subscriber_tracing_connection.cc index 7014e4bcd8763..dfb9e592d7b8c 100644 --- a/google/cloud/pubsub/internal/subscriber_tracing_connection.cc +++ b/google/cloud/pubsub/internal/subscriber_tracing_connection.cc @@ -42,7 +42,7 @@ opentelemetry::nostd::shared_ptr StartPullSpan() { auto span = internal::MakeSpan( subscription.subscription_id() + " receive", {{sc::kMessagingSystem, "gcp_pubsub"}, - {sc::kMessagingOperation, "receive"}, + {/*sc::kMessagingOperationType=*/"messaging.operation.type", "receive"}, {sc::kCodeFunction, "pubsub::SubscriberConnection::Pull"}, {"gcp.project_id", subscription.project_id()}, {sc::kMessagingDestinationName, subscription.subscription_id()}}, diff --git a/google/cloud/pubsub/internal/subscriber_tracing_connection_test.cc b/google/cloud/pubsub/internal/subscriber_tracing_connection_test.cc index db4a7195ec698..e4766d3667435 100644 --- a/google/cloud/pubsub/internal/subscriber_tracing_connection_test.cc +++ b/google/cloud/pubsub/internal/subscriber_tracing_connection_test.cc @@ -152,10 +152,12 @@ TEST(SubscriberTracingConnectionTest, PullAttributes) { SpanHasAttributes(OTelAttribute( sc::kCodeFunction, "pubsub::SubscriberConnection::Pull"))))); - EXPECT_THAT(spans, - Contains(AllOf(SpanNamed("test-subscription receive"), - SpanHasAttributes(OTelAttribute( - sc::kMessagingOperation, "receive"))))); + EXPECT_THAT( + spans, Contains(AllOf( + SpanNamed("test-subscription receive"), + SpanHasAttributes(OTelAttribute( + /*sc::kMessagingOperationType=*/"messaging.operation.type", + "receive"))))); EXPECT_THAT(spans, Contains(AllOf(SpanNamed("test-subscription receive"), SpanHasAttributes(OTelAttribute( diff --git a/google/cloud/pubsub/internal/tracing_batch_callback.cc b/google/cloud/pubsub/internal/tracing_batch_callback.cc index b1b3745ac55d3..f97e06070c39f 100644 --- a/google/cloud/pubsub/internal/tracing_batch_callback.cc +++ b/google/cloud/pubsub/internal/tracing_batch_callback.cc @@ -55,7 +55,8 @@ opentelemetry::nostd::shared_ptr StartSubscribeSpan( auto span = internal::MakeSpan( subscription.subscription_id() + " subscribe", {{sc::kMessagingSystem, "gcp_pubsub"}, - {sc::kMessagingOperation, "subscribe"}, + {/*sc::kMessagingOperationType=*/"messaging.operation.type", + "subscribe"}, {"gcp.project_id", subscription.project_id()}, {sc::kMessagingDestinationName, subscription.subscription_id()}, {sc::kMessagingMessageId, m.message_id()}, @@ -207,7 +208,7 @@ class TracingBatchCallback : public BatchCallback { auto span = internal::MakeSpan( subscription_.subscription_id() + " modack", {{sc::kMessagingSystem, "gcp_pubsub"}, - {sc::kMessagingOperation, "extend"}, + {/*sc::kMessagingOperationType=*/"messaging.operation.type", "extend"}, {sc::kMessagingBatchMessageCount, static_cast(request.ack_ids().size())}, {"messaging.gcp_pubsub.message.ack_deadline_seconds", diff --git a/google/cloud/pubsub/internal/tracing_batch_callback_test.cc b/google/cloud/pubsub/internal/tracing_batch_callback_test.cc index 8e2d810dcfe80..92ecacb68167e 100644 --- a/google/cloud/pubsub/internal/tracing_batch_callback_test.cc +++ b/google/cloud/pubsub/internal/tracing_batch_callback_test.cc @@ -159,7 +159,9 @@ TEST(TracingBatchCallback, StartAndEndModackSpanForOneMessage) { SpanHasAttributes( OTelAttribute(sc::kMessagingSystem, "gcp_pubsub"), OTelAttribute("gcp.project_id", "test-project"), - OTelAttribute(sc::kMessagingOperation, "extend"), + OTelAttribute( + /*sc::kMessagingOperationType=*/"messaging.operation.type", + "extend"), OTelAttribute(sc::kMessagingBatchMessageCount, 1), OTelAttribute( "messaging.gcp_pubsub.message.ack_deadline_seconds", 10), @@ -195,7 +197,9 @@ TEST(TracingBatchCallback, StartAndEndModackSpanForMultipleMessages) { SpanHasAttributes( OTelAttribute(sc::kMessagingSystem, "gcp_pubsub"), OTelAttribute("gcp.project_id", "test-project"), - OTelAttribute(sc::kMessagingOperation, "extend"), + OTelAttribute( + /*sc::kMessagingOperationType=*/"messaging.operation.type", + "extend"), OTelAttribute(sc::kMessagingBatchMessageCount, 2), OTelAttribute( "messaging.gcp_pubsub.message.ack_deadline_seconds", 10), @@ -246,7 +250,9 @@ TEST(TracingBatchCallback, SubscribeAttributes) { SpanHasAttributes( OTelAttribute(sc::kMessagingSystem, "gcp_pubsub"), OTelAttribute("gcp.project_id", "test-project"), - OTelAttribute(sc::kMessagingOperation, "subscribe"), + OTelAttribute( + /*sc::kMessagingOperationType=*/"messaging.operation.type", + "subscribe"), OTelAttribute(sc::kMessagingMessageId, "id-0"), OTelAttribute("messaging.gcp_pubsub.message.ack_id", "ack-id-0"), diff --git a/google/cloud/pubsub/internal/tracing_batch_sink.cc b/google/cloud/pubsub/internal/tracing_batch_sink.cc index 355e1d0d87247..a4782985e09d1 100644 --- a/google/cloud/pubsub/internal/tracing_batch_sink.cc +++ b/google/cloud/pubsub/internal/tracing_batch_sink.cc @@ -69,8 +69,8 @@ auto MakeParent(Links const& links, Spans const& message_spans, {{sc::kMessagingBatchMessageCount, static_cast(message_spans.size())}, {sc::kCodeFunction, "BatchSink::AsyncPublish"}, - {/*sc::kMessagingOperation=*/ - "messaging.operation", "publish"}, + {/*sc::kMessagingOperationType=*/ + "messaging.operation.type", "publish"}, {sc::kThreadId, internal::CurrentThreadId()}, {sc::kMessagingSystem, "gcp_pubsub"}, {/*sc::kServerAddress=*/"server.address", endpoint}, diff --git a/google/cloud/pubsub/internal/tracing_batch_sink_test.cc b/google/cloud/pubsub/internal/tracing_batch_sink_test.cc index a693fb620c986..80c56e6d506a2 100644 --- a/google/cloud/pubsub/internal/tracing_batch_sink_test.cc +++ b/google/cloud/pubsub/internal/tracing_batch_sink_test.cc @@ -205,10 +205,12 @@ TEST(TracingBatchSink, PublishSpanHasAttributes) { SpanNamed("test-topic publish"), SpanHasAttributes(OTelAttribute( sc::kCodeFunction, "BatchSink::AsyncPublish"))))); - EXPECT_THAT(spans, - Contains(AllOf(SpanNamed("test-topic publish"), - SpanHasAttributes(OTelAttribute( - sc::kMessagingOperation, "publish"))))); + EXPECT_THAT( + spans, Contains(AllOf( + SpanNamed("test-topic publish"), + SpanHasAttributes(OTelAttribute( + /*sc::kMessagingOperationType=*/"messaging.operation.type", + "publish"))))); EXPECT_THAT(spans, Contains(AllOf(SpanNamed("test-topic publish"), SpanHasAttributes(OTelAttribute( diff --git a/google/cloud/pubsub/internal/tracing_exactly_once_ack_handler.cc b/google/cloud/pubsub/internal/tracing_exactly_once_ack_handler.cc index b1ba25bb5c598..26071c91811c9 100644 --- a/google/cloud/pubsub/internal/tracing_exactly_once_ack_handler.cc +++ b/google/cloud/pubsub/internal/tracing_exactly_once_ack_handler.cc @@ -75,7 +75,8 @@ class TracingExactlyOnceAckHandler {sc::kMessagingDestinationName, sub.subscription_id()}, {"messaging.gcp_pubsub.message.delivery_attempt", static_cast(delivery_attempt())}, - {sc::kMessagingOperation, "settle"}}, + {/*sc::kMessagingOperationType=*/"messaging.operation.type", + "settle"}}, std::move(links), options); auto scope = internal::OTelScope(span); return internal::EndSpan(std::move(span), child_->ack()); @@ -104,7 +105,8 @@ class TracingExactlyOnceAckHandler {sc::kMessagingDestinationName, sub.subscription_id()}, {"messaging.gcp_pubsub.message.delivery_attempt", static_cast(delivery_attempt())}, - {sc::kMessagingOperation, "settle"}}, + {/*sc::kMessagingOperationType=*/"messaging.operation.type", + "settle"}}, std::move(links), options); auto scope = internal::OTelScope(span); diff --git a/google/cloud/pubsub/internal/tracing_exactly_once_ack_handler_test.cc b/google/cloud/pubsub/internal/tracing_exactly_once_ack_handler_test.cc index a6dd7de176ac8..402bfc831f77e 100644 --- a/google/cloud/pubsub/internal/tracing_exactly_once_ack_handler_test.cc +++ b/google/cloud/pubsub/internal/tracing_exactly_once_ack_handler_test.cc @@ -164,7 +164,9 @@ TEST(TracingAckHandlerTest, AckAttributes) { SpanHasAttributes( OTelAttribute(sc::kMessagingSystem, "gcp_pubsub"), OTelAttribute("gcp.project_id", "test-project"), - OTelAttribute(sc::kMessagingOperation, "settle"), + OTelAttribute( + /*sc::kMessagingOperationType=*/"messaging.operation.type", + "settle"), OTelAttribute(sc::kCodeFunction, "pubsub::AckHandler::ack"), OTelAttribute( @@ -270,7 +272,9 @@ TEST(TracingAckHandlerTest, NackAttributes) { SpanHasAttributes( OTelAttribute(sc::kMessagingSystem, "gcp_pubsub"), OTelAttribute("gcp.project_id", "test-project"), - OTelAttribute(sc::kMessagingOperation, "settle"), + OTelAttribute( + /*sc::kMessagingOperationType=*/"messaging.operation.type", + "settle"), OTelAttribute(sc::kCodeFunction, "pubsub::AckHandler::nack"), OTelAttribute( diff --git a/google/cloud/pubsub/internal/tracing_pull_ack_handler.cc b/google/cloud/pubsub/internal/tracing_pull_ack_handler.cc index 78158f8a17c20..ec174057ff4d5 100644 --- a/google/cloud/pubsub/internal/tracing_pull_ack_handler.cc +++ b/google/cloud/pubsub/internal/tracing_pull_ack_handler.cc @@ -67,7 +67,8 @@ class TracingPullAckHandler : public pubsub::PullAckHandler::Impl { TracingAttributes attributes = MakeSharedAttributes(ack_id, subscription); attributes.emplace_back( std::make_pair(sc::kCodeFunction, "pubsub::PullAckHandler::ack")); - attributes.emplace_back(std::make_pair(sc::kMessagingOperation, "ack")); + attributes.emplace_back(std::make_pair( + /*sc::kMessagingOperationType=*/"messaging.operation.type", "ack")); auto span = internal::MakeSpan(subscription.subscription_id() + " ack", attributes, CreateLinks(consumer_span_context_), options); @@ -92,7 +93,8 @@ class TracingPullAckHandler : public pubsub::PullAckHandler::Impl { TracingAttributes attributes = MakeSharedAttributes(ack_id, subscription); attributes.emplace_back( std::make_pair(sc::kCodeFunction, "pubsub::PullAckHandler::nack")); - attributes.emplace_back(std::make_pair(sc::kMessagingOperation, "nack")); + attributes.emplace_back(std::make_pair( + /*sc::kMessagingOperationType=*/"messaging.operation.type", "nack")); auto span = internal::MakeSpan(subscription.subscription_id() + " nack", attributes, CreateLinks(consumer_span_context_), options); diff --git a/google/cloud/pubsub/internal/tracing_pull_ack_handler_test.cc b/google/cloud/pubsub/internal/tracing_pull_ack_handler_test.cc index f10ee7e27609a..52a485588bab2 100644 --- a/google/cloud/pubsub/internal/tracing_pull_ack_handler_test.cc +++ b/google/cloud/pubsub/internal/tracing_pull_ack_handler_test.cc @@ -112,10 +112,12 @@ TEST(TracingAckHandlerTest, AckAttributes) { Contains(AllOf(SpanNamed("test-subscription ack"), SpanHasAttributes(OTelAttribute( "gcp.project_id", "test-project"))))); - EXPECT_THAT(spans, - Contains(AllOf(SpanNamed("test-subscription ack"), - SpanHasAttributes(OTelAttribute( - sc::kMessagingOperation, "ack"))))); + EXPECT_THAT( + spans, Contains(AllOf( + SpanNamed("test-subscription ack"), + SpanHasAttributes(OTelAttribute( + /*sc::kMessagingOperationType=*/"messaging.operation.type", + "ack"))))); EXPECT_THAT( spans, Contains(AllOf(SpanNamed("test-subscription ack"), @@ -182,10 +184,12 @@ TEST(TracingAckHandlerTest, NackAttributes) { Contains(AllOf(SpanNamed("test-subscription nack"), SpanHasAttributes(OTelAttribute( sc::kMessagingSystem, "gcp_pubsub"))))); - EXPECT_THAT(spans, - Contains(AllOf(SpanNamed("test-subscription nack"), - SpanHasAttributes(OTelAttribute( - sc::kMessagingOperation, "nack"))))); + EXPECT_THAT( + spans, Contains(AllOf( + SpanNamed("test-subscription nack"), + SpanHasAttributes(OTelAttribute( + /*sc::kMessagingOperationType=*/"messaging.operation.type", + "nack"))))); EXPECT_THAT(spans, Contains(AllOf(SpanNamed("test-subscription nack"), SpanHasAttributes(OTelAttribute( diff --git a/google/cloud/pubsub/internal/tracing_pull_lease_manager.cc b/google/cloud/pubsub/internal/tracing_pull_lease_manager.cc index 0bcd6368477d0..bfe610b4e92f9 100644 --- a/google/cloud/pubsub/internal/tracing_pull_lease_manager.cc +++ b/google/cloud/pubsub/internal/tracing_pull_lease_manager.cc @@ -58,7 +58,7 @@ class TracingPullLeaseManagerImpl : public PullLeaseManagerImpl { auto span = internal::MakeSpan( subscription_.subscription_id() + " modack", {{sc::kMessagingSystem, "gcp_pubsub"}, - {sc::kMessagingOperation, "modack"}, + {/*sc::kMessagingOperationType=*/"messaging.operation.type", "modack"}, {sc::kCodeFunction, "pubsub::PullLeaseManager::ExtendLease"}, {"messaging.gcp_pubsub.message.ack_id", ack_id_}, {"messaging.gcp_pubsub.message.ack_deadline_seconds", diff --git a/google/cloud/pubsub/internal/tracing_pull_lease_manager_test.cc b/google/cloud/pubsub/internal/tracing_pull_lease_manager_test.cc index 2d6d2bcd58fe7..2fd5da3302ade 100644 --- a/google/cloud/pubsub/internal/tracing_pull_lease_manager_test.cc +++ b/google/cloud/pubsub/internal/tracing_pull_lease_manager_test.cc @@ -172,10 +172,12 @@ TEST(TracingPullLeaseManagerImplTest, AsyncModifyAckDeadlineAttributes) { Contains(AllOf(SpanNamed("test-subscription modack"), SpanHasAttributes(OTelAttribute( sc::kMessagingSystem, "gcp_pubsub"))))); - EXPECT_THAT(spans, - Contains(AllOf(SpanNamed("test-subscription modack"), - SpanHasAttributes(OTelAttribute( - sc::kMessagingOperation, "modack"))))); + EXPECT_THAT( + spans, Contains(AllOf( + SpanNamed("test-subscription modack"), + SpanHasAttributes(OTelAttribute( + /*sc::kMessagingOperationType=*/"messaging.operation.type", + "modack"))))); EXPECT_THAT(spans, Contains(AllOf(SpanNamed("test-subscription modack"), SpanHasAttributes(OTelAttribute( diff --git a/google/cloud/storage/internal/async/reader_connection_tracing.cc b/google/cloud/storage/internal/async/reader_connection_tracing.cc index efc0e72d8d7cb..cf27bd19275b1 100644 --- a/google/cloud/storage/internal/async/reader_connection_tracing.cc +++ b/google/cloud/storage/internal/async/reader_connection_tracing.cc @@ -52,22 +52,24 @@ class AsyncReaderConnectionTracing .then([count = ++count_, span = span_](auto f) -> ReadResponse { auto r = f.get(); if (absl::holds_alternative(r)) { - span->AddEvent("gl-cpp.read", - { - {sc::kMessageType, "RECEIVED"}, - {sc::kMessageId, count}, - {sc::kThreadId, internal::CurrentThreadId()}, - }); + span->AddEvent( + "gl-cpp.read", + { + {/*sc::kRpcMessageType=*/"rpc.message.type", "RECEIVED"}, + {/*sc::kRpcMessageId=*/"rpc.message.id", count}, + {sc::kThreadId, internal::CurrentThreadId()}, + }); return internal::EndSpan(*span, absl::get(std::move(r))); } auto const& payload = absl::get(r); - span->AddEvent("gl-cpp.read", - { - {sc::kMessageType, "RECEIVED"}, - {sc::kMessageId, count}, - {sc::kThreadId, internal::CurrentThreadId()}, - {"message.starting_offset", payload.offset()}, - }); + span->AddEvent( + "gl-cpp.read", + { + {/*sc::kRpcMessageType=*/"rpc.message.type", "RECEIVED"}, + {/*sc::kRpcMessageId=*/"rpc.message.id", count}, + {sc::kThreadId, internal::CurrentThreadId()}, + {"message.starting_offset", payload.offset()}, + }); return r; }) .then([oc = opentelemetry::context::RuntimeContext::GetCurrent()]( diff --git a/google/cloud/storage/internal/async/reader_connection_tracing_test.cc b/google/cloud/storage/internal/async/reader_connection_tracing_test.cc index c12a9b80c1977..50b2b21b3e64f 100644 --- a/google/cloud/storage/internal/async/reader_connection_tracing_test.cc +++ b/google/cloud/storage/internal/async/reader_connection_tracing_test.cc @@ -106,16 +106,21 @@ TEST(ReaderConnectionTracing, WithError) { AllOf( EventNamed("gl-cpp.read"), SpanEventAttributesAre( - OTelAttribute(sc::kMessageId, 1), - OTelAttribute(sc::kMessageType, "RECEIVED"), + OTelAttribute( + /*sc::kRpcMessageId=*/"rpc.message.id", 1), + OTelAttribute( + /*sc::kRpcMessageType=*/"rpc.message.type", + "RECEIVED"), OTelAttribute("message.starting_offset", 0), OTelAttribute(sc::kThreadId, _))), - AllOf( - EventNamed("gl-cpp.read"), - SpanEventAttributesAre( - OTelAttribute(sc::kMessageId, 2), - OTelAttribute(sc::kMessageType, "RECEIVED"), - OTelAttribute(sc::kThreadId, _))))))); + AllOf(EventNamed("gl-cpp.read"), + SpanEventAttributesAre( + OTelAttribute( + /*sc::kRpcMessageId=*/"rpc.message.id", 2), + OTelAttribute( + /*sc::kRpcMessageType=*/"rpc.message.type", + "RECEIVED"), + OTelAttribute(sc::kThreadId, _))))))); } TEST(ReaderConnectionTracing, WithSuccess) { @@ -159,24 +164,31 @@ TEST(ReaderConnectionTracing, WithSuccess) { AllOf( EventNamed("gl-cpp.read"), SpanEventAttributesAre( - OTelAttribute(sc::kMessageId, 1), - OTelAttribute(sc::kMessageType, "RECEIVED"), + OTelAttribute( + /*sc::kRpcMessageId=*/"rpc.message.id", 1), + OTelAttribute( + /*sc::kRpcMessageType=*/"rpc.message.type", + "RECEIVED"), OTelAttribute("message.starting_offset", 0), OTelAttribute(sc::kThreadId, _))), - AllOf( - EventNamed("gl-cpp.read"), - SpanEventAttributesAre( - OTelAttribute(sc::kMessageId, 2), - OTelAttribute(sc::kMessageType, "RECEIVED"), - OTelAttribute("message.starting_offset", - 1024), - OTelAttribute(sc::kThreadId, _))), - AllOf( - EventNamed("gl-cpp.read"), - SpanEventAttributesAre( - OTelAttribute(sc::kMessageId, 3), - OTelAttribute(sc::kMessageType, "RECEIVED"), - OTelAttribute(sc::kThreadId, _))))))); + AllOf(EventNamed("gl-cpp.read"), + SpanEventAttributesAre( + OTelAttribute( + /*sc::kRpcMessageId=*/"rpc.message.id", 2), + OTelAttribute( + /*sc::kRpcMessageType=*/"rpc.message.type", + "RECEIVED"), + OTelAttribute("message.starting_offset", + 1024), + OTelAttribute(sc::kThreadId, _))), + AllOf(EventNamed("gl-cpp.read"), + SpanEventAttributesAre( + OTelAttribute( + /*sc::kRpcMessageId=*/"rpc.message.id", 3), + OTelAttribute( + /*sc::kRpcMessageType=*/"rpc.message.type", + "RECEIVED"), + OTelAttribute(sc::kThreadId, _))))))); auto const metadata = actual->GetRequestMetadata(); EXPECT_THAT(metadata.headers, diff --git a/google/cloud/storage/internal/async/writer_connection_tracing.cc b/google/cloud/storage/internal/async/writer_connection_tracing.cc index 15d929f94b5cb..3bb930e6e9b3c 100644 --- a/google/cloud/storage/internal/async/writer_connection_tracing.cc +++ b/google/cloud/storage/internal/async/writer_connection_tracing.cc @@ -61,13 +61,14 @@ class AsyncWriterConnectionTracing auto size = static_cast(p.size()); return impl_->Write(std::move(p)) .then([count = ++sent_count_, span = span_, size](auto f) { - span->AddEvent("gl-cpp.write", - { - {sc::kMessageType, "SENT"}, - {sc::kMessageId, count}, - {sc::kThreadId, internal::CurrentThreadId()}, - {"gl-cpp.size", size}, - }); + span->AddEvent( + "gl-cpp.write", + { + {/*sc::kRpcMessageType=*/"rpc.message.type", "SENT"}, + {/*sc::kRpcMessageId=*/"rpc.message.id", count}, + {sc::kThreadId, internal::CurrentThreadId()}, + {"gl-cpp.size", size}, + }); auto status = f.get(); if (!status.ok()) return internal::EndSpan(*span, std::move(status)); return status; @@ -80,13 +81,14 @@ class AsyncWriterConnectionTracing auto size = static_cast(p.size()); return impl_->Finalize(std::move(p)) .then([count = ++sent_count_, span = span_, size](auto f) { - span->AddEvent("gl-cpp.finalize", - { - {sc::kMessageType, "SENT"}, - {sc::kMessageId, count}, - {sc::kThreadId, internal::CurrentThreadId()}, - {"gl-cpp.size", size}, - }); + span->AddEvent( + "gl-cpp.finalize", + { + {/*sc::kRpcMessageType=*/"rpc.message.type", "SENT"}, + {/*sc::kRpcMessageId=*/"rpc.message.id", count}, + {sc::kThreadId, internal::CurrentThreadId()}, + {"gl-cpp.size", size}, + }); return internal::EndSpan(*span, f.get()); }); } @@ -96,13 +98,14 @@ class AsyncWriterConnectionTracing auto size = static_cast(p.size()); return impl_->Flush(std::move(p)) .then([count = ++sent_count_, span = span_, size](auto f) { - span->AddEvent("gl-cpp.flush", - { - {sc::kMessageType, "SENT"}, - {sc::kMessageId, count}, - {sc::kThreadId, internal::CurrentThreadId()}, - {"gl-cpp.size", size}, - }); + span->AddEvent( + "gl-cpp.flush", + { + {/*sc::kRpcMessageType=*/"rpc.message.type", "SENT"}, + {/*sc::kRpcMessageId=*/"rpc.message.id", count}, + {sc::kThreadId, internal::CurrentThreadId()}, + {"gl-cpp.size", size}, + }); auto status = f.get(); if (!status.ok()) return internal::EndSpan(*span, std::move(status)); return status; @@ -112,12 +115,13 @@ class AsyncWriterConnectionTracing future> Query() override { internal::OTelScope scope(span_); return impl_->Query().then([count = ++recv_count_, span = span_](auto f) { - span->AddEvent("gl-cpp.query", - { - {sc::kMessageType, "RECEIVE"}, - {sc::kMessageId, count}, - {sc::kThreadId, internal::CurrentThreadId()}, - }); + span->AddEvent( + "gl-cpp.query", + { + {/*sc::kRpcMessageType=*/"rpc.message.type", "RECEIVE"}, + {/*sc::kRpcMessageId=*/"rpc.message.id", count}, + {sc::kThreadId, internal::CurrentThreadId()}, + }); auto response = f.get(); if (!response) return internal::EndSpan(*span, std::move(response)); return response; diff --git a/google/cloud/storage/internal/async/writer_connection_tracing_test.cc b/google/cloud/storage/internal/async/writer_connection_tracing_test.cc index 1c1106b6e0ca5..8d156a9a5ab6c 100644 --- a/google/cloud/storage/internal/async/writer_connection_tracing_test.cc +++ b/google/cloud/storage/internal/async/writer_connection_tracing_test.cc @@ -55,8 +55,9 @@ using ::testing::VariantWith; auto ExpectSent(std::int64_t id, std::uint64_t size) { namespace sc = ::opentelemetry::trace::SemanticConventions; return SpanEventAttributesAre( - OTelAttribute(sc::kMessageType, "SENT"), - OTelAttribute(sc::kMessageId, id), + OTelAttribute(/*sc::kRpcMessageType=*/"rpc.message.type", + "SENT"), + OTelAttribute(/*sc::kRpcMessageId=*/"rpc.message.id", id), OTelAttribute(sc::kThreadId, _), OTelAttribute("gl-cpp.size", size)); } @@ -73,8 +74,10 @@ auto ExpectQuery(std::int64_t id) { namespace sc = ::opentelemetry::trace::SemanticConventions; return AllOf(EventNamed("gl-cpp.query"), SpanEventAttributesAre( - OTelAttribute(sc::kMessageType, "RECEIVE"), - OTelAttribute(sc::kMessageId, id), + OTelAttribute( + /*sc::kRpcMessageType=*/"rpc.message.type", "RECEIVE"), + OTelAttribute( + /*sc::kRpcMessageId=*/"rpc.message.id", id), OTelAttribute(sc::kThreadId, _))); }