From 9649ebeaafa9ffc97e931bf811b631b18d01a3b6 Mon Sep 17 00:00:00 2001 From: Markus Hennerbichler Date: Fri, 23 Feb 2024 17:53:34 +0000 Subject: [PATCH] [EXPORTER] Error when grpc endpoint is empty (#2507) --- 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 7ce728ec49..fcd53985d4 100644 --- a/exporters/otlp/src/otlp_grpc_client.cc +++ b/exporters/otlp/src/otlp_grpc_client.cc @@ -264,8 +264,13 @@ OtlpGrpcClient::~OtlpGrpcClient() 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 @@ -280,6 +285,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);