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);