Skip to content

Commit

Permalink
[EXPORTER] Error when grpc endpoint is empty (open-telemetry#2507)
Browse files Browse the repository at this point in the history
  • Loading branch information
HennerM authored Feb 23, 2024
1 parent 4eb99f9 commit 9649ebe
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 @@ -264,8 +264,13 @@ OtlpGrpcClient::~OtlpGrpcClient()

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
Expand All @@ -280,6 +285,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 9649ebe

Please sign in to comment.