From 07c472c0181dd44f747790c23f763dc3058ea49d Mon Sep 17 00:00:00 2001 From: Markus Hennerbichler Date: Tue, 23 Jan 2024 19:57:46 +0000 Subject: [PATCH] [EXPORTER] Error when grpc endpoint is empty --- exporters/otlp/src/otlp_grpc_client.cc | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/exporters/otlp/src/otlp_grpc_client.cc b/exporters/otlp/src/otlp_grpc_client.cc index c0436eddaf..9439fa4eed 100644 --- a/exporters/otlp/src/otlp_grpc_client.cc +++ b/exporters/otlp/src/otlp_grpc_client.cc @@ -50,8 +50,13 @@ static std::string GetFileContentsOrInMemoryContents(const std::string &file_pat std::shared_ptr OtlpGrpcClient::MakeChannel(const OtlpGrpcClientOptions &options) { - std::shared_ptr channel; + if (options.endpoint.empty()) + { + OTEL_INTERNAL_LOG_ERROR("[OTLP GRPC Client] empty endpoint"); + + return nullptr; + } // // Scheme is allowed in OTLP endpoint definition, but is not allowed for creating gRPC channel. // Passing URI with scheme to grpc::CreateChannel could resolve the endpoint to some unexpected @@ -66,6 +71,7 @@ std::shared_ptr OtlpGrpcClient::MakeChannel(const OtlpGrpcClientO return nullptr; } + std::shared_ptr channel; std::string grpc_target = url.host_ + ":" + std::to_string(static_cast(url.port_)); grpc::ChannelArguments grpc_arguments; grpc_arguments.SetUserAgentPrefix(options.user_agent);