otlp_grpc_target_test.cc 914 B

12345678910111213141516171819202122232425262728293031323334353637
  1. // Copyright The OpenTelemetry Authors
  2. // SPDX-License-Identifier: Apache-2.0
  3. #include <grpcpp/grpcpp.h>
  4. #include <gtest/gtest.h>
  5. #include "opentelemetry/exporters/otlp/otlp_grpc_client.h"
  6. OPENTELEMETRY_BEGIN_NAMESPACE
  7. namespace exporter
  8. {
  9. namespace otlp
  10. {
  11. TEST(OtlpGrpcClientEndpointTest, GrpcClientTest)
  12. {
  13. OtlpGrpcClientOptions opts1;
  14. opts1.endpoint = "unix:///tmp/otel1.sock";
  15. OtlpGrpcClientOptions opts2;
  16. opts2.endpoint = "unix:tmp/otel2.sock";
  17. OtlpGrpcClientOptions opts3;
  18. opts3.endpoint = "localhost:4317";
  19. auto target1 = OtlpGrpcClient::GetGrpcTarget(opts1.endpoint);
  20. auto target2 = OtlpGrpcClient::GetGrpcTarget(opts2.endpoint);
  21. auto target3 = OtlpGrpcClient::GetGrpcTarget(opts3.endpoint);
  22. EXPECT_EQ(target1, "unix:/tmp/otel1.sock");
  23. EXPECT_EQ(target2, "");
  24. EXPECT_EQ(target3, "localhost:4317");
  25. }
  26. } // namespace otlp
  27. } // namespace exporter
  28. OPENTELEMETRY_END_NAMESPACE