From e35cf362a49b4de753cbe69f3e836d2e40408ca2 Mon Sep 17 00:00:00 2001 From: Yash Tibrewal Date: Mon, 19 Jun 2023 11:59:59 -0700 Subject: [PATCH] Revert "[logging] Handle trailers-only responses (#33461)" (#33485) This reverts commit cb9fe64fa5e10851f716213037a5de1e01f6066c. This broke tests https://fusion2.corp.google.com/ci/kokoro/prod:grpc-gcp%2Ftools%2Fobservability%2Fmaster%2Fcontinuous_cpp/activity/8c408662-43bd-4377-a6b9-9a89490cea83/tests Attempting to add a test in https://github.com/grpc/grpc/pull/33486 --- .../ext/filters/logging/logging_filter.cc | 22 +++++++++---------- src/core/ext/filters/logging/logging_sink.h | 1 - 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/src/core/ext/filters/logging/logging_filter.cc b/src/core/ext/filters/logging/logging_filter.cc index 474649ab375..761d554e57a 100644 --- a/src/core/ext/filters/logging/logging_filter.cc +++ b/src/core/ext/filters/logging/logging_filter.cc @@ -256,19 +256,21 @@ class CallData { void LogServerHeader(bool is_client, CallTracerAnnotationInterface* tracer, const ServerMetadata* metadata) { LoggingSink::Entry entry; - if (is_client) { - if (auto* value = metadata->get_pointer(PeerString())) { - peer_ = PeerStringToAddress(*value); + if (metadata != nullptr) { + if (is_client) { + if (auto* value = metadata->get_pointer(PeerString())) { + peer_ = PeerStringToAddress(*value); + } } } SetCommonEntryFields(&entry, is_client, tracer, LoggingSink::Entry::EventType::kServerHeader); - if (metadata->TransportSize() == 0) return; - seen_server_header_ = true; - MetadataEncoder encoder(&entry.payload, nullptr, - config_.max_metadata_bytes()); - metadata->Encode(&encoder); - entry.payload_truncated = encoder.truncated(); + if (metadata != nullptr) { + MetadataEncoder encoder(&entry.payload, nullptr, + config_.max_metadata_bytes()); + metadata->Encode(&encoder); + entry.payload_truncated = encoder.truncated(); + } g_logging_sink->LogEntry(std::move(entry)); } @@ -277,7 +279,6 @@ class CallData { LoggingSink::Entry entry; SetCommonEntryFields(&entry, is_client, tracer, LoggingSink::Entry::EventType::kServerTrailer); - entry.is_trailer_only = !seen_server_header_; if (metadata != nullptr) { MetadataEncoder encoder(&entry.payload, &entry.payload.status_details, config_.max_metadata_bytes()); @@ -339,7 +340,6 @@ class CallData { std::string authority_; LoggingSink::Entry::Address peer_; LoggingSink::Config config_; - bool seen_server_header_ = false; }; class ClientLoggingFilter final : public ChannelFilter { diff --git a/src/core/ext/filters/logging/logging_sink.h b/src/core/ext/filters/logging/logging_sink.h index 24852b40f8c..a78d4de85a0 100644 --- a/src/core/ext/filters/logging/logging_sink.h +++ b/src/core/ext/filters/logging/logging_sink.h @@ -107,7 +107,6 @@ class LoggingSink { std::string trace_id; std::string span_id; bool is_sampled = false; - bool is_trailer_only; }; virtual ~LoggingSink() = default;