Skip to content

Commit

Permalink
[EXPORTER] Error when grpc endpoint is empty
Browse files Browse the repository at this point in the history
  • Loading branch information
HennerM committed Jan 23, 2024
1 parent fe15d0a commit 07c472c
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion exporters/otlp/src/otlp_grpc_client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,13 @@ static std::string GetFileContentsOrInMemoryContents(const std::string &file_pat

std::shared_ptr<grpc::Channel> OtlpGrpcClient::MakeChannel(const OtlpGrpcClientOptions &options)
{
std::shared_ptr<grpc::Channel> 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
Expand All @@ -66,6 +71,7 @@ std::shared_ptr<grpc::Channel> OtlpGrpcClient::MakeChannel(const OtlpGrpcClientO
return nullptr;
}

std::shared_ptr<grpc::Channel> channel;
std::string grpc_target = url.host_ + ":" + std::to_string(static_cast<int>(url.port_));
grpc::ChannelArguments grpc_arguments;
grpc_arguments.SetUserAgentPrefix(options.user_agent);
Expand Down

0 comments on commit 07c472c

Please sign in to comment.