Skip to content

Commit

Permalink
feat(generator): include request in async streaming RPC logs (#14565)
Browse files Browse the repository at this point in the history
  • Loading branch information
coryan authored Jul 25, 2024
1 parent e559c9a commit ad1d045
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,9 @@ GoldenKitchenSinkLogging::AsyncStreamingRead(
::google::cloud::internal::AsyncStreamingReadRpcLogging<google::test::admin::database::v1::Response>;

auto request_id = google::cloud::internal::RequestIdForLogging();
GCP_LOG(DEBUG) << __func__ << "(" << request_id << ")";
google::cloud::internal::LogRequest(
__func__, request_id,
google::cloud::internal::DebugString(request, tracing_options_));
auto stream = child_->AsyncStreamingRead(
cq, std::move(context), std::move(options), request);
if (stream_logging_) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,10 @@ TEST_F(LoggingDecoratorTest, AsyncStreamingRead) {
EXPECT_THAT(finish, StatusIs(StatusCode::kAborted));

auto const log_lines = log_.ExtractLines();
EXPECT_THAT(log_lines, Contains(StartsWith("AsyncStreamingRead(")));
EXPECT_THAT(
log_lines,
Contains(AllOf(StartsWith("AsyncStreamingRead("),
HasSubstr("google.test.admin.database.v1.Request"))));
EXPECT_THAT(log_lines, Contains(StartsWith("Start(")));
EXPECT_THAT(log_lines, Contains(StartsWith("Finish(")));
}
Expand Down
4 changes: 3 additions & 1 deletion generator/internal/logging_decorator_generator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,9 @@ std::unique_ptr<::google::cloud::internal::AsyncStreamingReadRpc<
::google::cloud::internal::AsyncStreamingReadRpcLogging<$response_type$>;
auto request_id = google::cloud::internal::RequestIdForLogging();
GCP_LOG(DEBUG) << __func__ << "(" << request_id << ")";
google::cloud::internal::LogRequest(
__func__, request_id,
google::cloud::internal::DebugString(request, tracing_options_));
auto stream = child_->Async$method_name$(
cq, std::move(context), std::move(options), request);
if (stream_logging_) {
Expand Down
12 changes: 9 additions & 3 deletions google/cloud/bigtable/internal/bigtable_logging_decorator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,9 @@ BigtableLogging::AsyncReadRows(
google::bigtable::v2::ReadRowsResponse>;

auto request_id = google::cloud::internal::RequestIdForLogging();
GCP_LOG(DEBUG) << __func__ << "(" << request_id << ")";
google::cloud::internal::LogRequest(
__func__, request_id,
google::cloud::internal::DebugString(request, tracing_options_));
auto stream = child_->AsyncReadRows(cq, std::move(context),
std::move(options), request);
if (stream_logging_) {
Expand All @@ -215,7 +217,9 @@ BigtableLogging::AsyncSampleRowKeys(
google::bigtable::v2::SampleRowKeysResponse>;

auto request_id = google::cloud::internal::RequestIdForLogging();
GCP_LOG(DEBUG) << __func__ << "(" << request_id << ")";
google::cloud::internal::LogRequest(
__func__, request_id,
google::cloud::internal::DebugString(request, tracing_options_));
auto stream = child_->AsyncSampleRowKeys(cq, std::move(context),
std::move(options), request);
if (stream_logging_) {
Expand Down Expand Up @@ -254,7 +258,9 @@ BigtableLogging::AsyncMutateRows(
google::bigtable::v2::MutateRowsResponse>;

auto request_id = google::cloud::internal::RequestIdForLogging();
GCP_LOG(DEBUG) << __func__ << "(" << request_id << ")";
google::cloud::internal::LogRequest(
__func__, request_id,
google::cloud::internal::DebugString(request, tracing_options_));
auto stream = child_->AsyncMutateRows(cq, std::move(context),
std::move(options), request);
if (stream_logging_) {
Expand Down
4 changes: 3 additions & 1 deletion google/cloud/storage/internal/storage_logging_decorator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -485,7 +485,9 @@ StorageLogging::AsyncReadObject(
google::storage::v2::ReadObjectResponse>;

auto request_id = google::cloud::internal::RequestIdForLogging();
GCP_LOG(DEBUG) << __func__ << "(" << request_id << ")";
google::cloud::internal::LogRequest(
__func__, request_id,
google::cloud::internal::DebugString(request, tracing_options_));
auto stream = child_->AsyncReadObject(cq, std::move(context),
std::move(options), request);
if (stream_logging_) {
Expand Down

0 comments on commit ad1d045

Please sign in to comment.