Skip to content

Commit a31d8b9

Browse files
committed
grpc/otel: handle credentials creation error
Signed-off-by: Attila Szakacs <[email protected]>
1 parent acae3b7 commit a31d8b9

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

modules/grpc/otel/otel-dest-worker.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,14 @@ DestWorker::DestWorker(GrpcDestWorker *s)
4747
formatter(s->super.owner->super.super.super.cfg)
4848
{
4949
std::shared_ptr<::grpc::ChannelCredentials> credentials = DestWorker::create_credentials();
50+
if (!credentials)
51+
{
52+
msg_error("Error querying OTel credentials",
53+
evt_tag_str("url", this->owner.get_url().c_str()),
54+
log_pipe_location_tag((LogPipe *) this->super->super.owner));
55+
throw std::runtime_error("Error querying OTel credentials");
56+
}
57+
5058
::grpc::ChannelArguments args = this->create_channel_args();
5159

5260
channel = ::grpc::CreateCustomChannel(owner.get_url(), credentials, args);

modules/grpc/otel/otel-dest.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,15 @@ LogThreadedDestWorker *
5656
DestDriver::construct_worker(int worker_index)
5757
{
5858
GrpcDestWorker *worker = grpc_dw_new(this->super, worker_index);
59-
worker->cpp = new DestWorker(worker);
59+
try
60+
{
61+
worker->cpp = new DestWorker(worker);
62+
}
63+
catch (const std::runtime_error &e)
64+
{
65+
log_threaded_dest_worker_free(&worker->super);
66+
return NULL;
67+
}
6068
return &worker->super;
6169
}
6270

0 commit comments

Comments
 (0)