Skip to content

Commit e52dd9a

Browse files
authored
impl: add client origin metadata for a failed streaming read (#14103)
1 parent 44bb9a8 commit e52dd9a

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

google/cloud/completion_queue_test.cc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ using ::google::cloud::testing_util::IsOk;
4646
using ::testing::Contains;
4747
using ::testing::HasSubstr;
4848
using ::testing::Not;
49+
using ::testing::Pair;
4950
using ::testing::StrictMock;
5051

5152
using Request = google::protobuf::Duration;
@@ -421,6 +422,8 @@ TEST(CompletionQueueTest, MakeRpcsAfterShutdown) {
421422
},
422423
[](Status const& status) {
423424
EXPECT_EQ(StatusCode::kCancelled, status.code());
425+
auto const& metadata = status.error_info().metadata();
426+
EXPECT_THAT(metadata, Contains(Pair("gl-cpp.error.origin", "client")));
424427
});
425428

426429
mock_cq->SimulateCompletion(true);

google/cloud/internal/async_read_stream_impl.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include "google/cloud/grpc_error_delegate.h"
1919
#include "google/cloud/internal/call_context.h"
2020
#include "google/cloud/internal/completion_queue_impl.h"
21+
#include "google/cloud/internal/make_status.h"
2122
#include "google/cloud/version.h"
2223
#include <grpcpp/support/async_stream.h>
2324
#include <memory>
@@ -264,8 +265,11 @@ class AsyncReadStreamImpl
264265

265266
/// Handle the result of a Finish() request.
266267
void OnFinish(bool ok, Status status) {
267-
on_finish_(ok ? std::move(status)
268-
: Status(StatusCode::kCancelled, "call cancelled"));
268+
on_finish_(
269+
ok ? std::move(status)
270+
: internal::CancelledError("call cancelled",
271+
GCP_ERROR_INFO().WithMetadata(
272+
"gl-cpp.error.origin", "client")));
269273
}
270274

271275
/**

0 commit comments

Comments
 (0)