Skip to content

Commit

Permalink
fix windows build
Browse files Browse the repository at this point in the history
  • Loading branch information
lalitb committed Jul 26, 2021
1 parent 511d941 commit 125d9b5
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 9 deletions.
4 changes: 2 additions & 2 deletions exporters/otlp/test/otlp_grpc_exporter_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ TEST_F(OtlpGrpcExporterTestPeer, ConfigSslCredentialsTest)
EXPECT_EQ(GetOptions(exporter).use_ssl_credentials, true);
}

#ifndef NO_GETENV
# ifndef NO_GETENV
// Test exporter configuration options with use_ssl_credentials
TEST_F(OtlpGrpcExporterTestPeer, ConfigFromEnv)
{
Expand All @@ -148,7 +148,7 @@ TEST_F(OtlpGrpcExporterTestPeer, ConfigFromEnv)
EXPECT_EQ(GetOptions(exporter).use_ssl_credentials, true);
EXPECT_EQ(GetOptions(exporter).endpoint, endpoint);
}
#endif
# endif

} // namespace otlp
} // namespace exporter
Expand Down
1 change: 0 additions & 1 deletion sdk/include/opentelemetry/sdk/common/env_variables.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ inline const std::string GetEnvironmentVariable(const char *env_var_name)
// avoid calling std::getenv which is deprecated in MSVC.
size_t required_size = 0;
getenv_s(&required_size, nullptr, 0, env_var_name);
const char *endpoint_from_env = nullptr;
std::unique_ptr<char> endpoint_buffer;
if (required_size > 0)
{
Expand Down
12 changes: 6 additions & 6 deletions sdk/test/resource/resource_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -176,21 +176,21 @@ TEST(ResourceTest, OtelResourceDetector)
}
}
EXPECT_EQ(received_attributes.size(), expected_attributes.size());
#if defined(_MSC_VER)
# if defined(_MSC_VER)
putenv("OTEL_RESOURCE_ATTRIBUTES=");
#else
# else
unsetenv("OTEL_RESOURCE_ATTRIBUTES");
#endif
# endif
}

TEST(ResourceTest, OtelResourceDetectorEmptyEnv)
{
std::map<std::string, std::string> expected_attributes = {};
#if defined(_MSC_VER)
# if defined(_MSC_VER)
putenv("OTEL_RESOURCE_ATTRIBUTES=");
#else
# else
unsetenv("OTEL_RESOURCE_ATTRIBUTES");
#endif
# endif
OTELResourceDetector detector;
auto resource = detector.Detect();
auto received_attributes = resource.GetAttributes();
Expand Down

0 comments on commit 125d9b5

Please sign in to comment.