diff --git a/exporters/otlp/test/otlp_grpc_exporter_test.cc b/exporters/otlp/test/otlp_grpc_exporter_test.cc index 3ac174b691..364c59681b 100644 --- a/exporters/otlp/test/otlp_grpc_exporter_test.cc +++ b/exporters/otlp/test/otlp_grpc_exporter_test.cc @@ -1,49 +1,54 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -#ifndef OPENTELEMETRY_STL_VERSION -// Unfortunately as of 04/27/2021 the fix is NOT in the vcpkg snapshot of Google Test. -// Remove above `#ifdef` once the GMock fix for C++20 is in the mainline. -// -// Please refer to this GitHub issue for additional details: -// https://github.com/google/googletest/issues/2914 -// https://github.com/google/googletest/commit/61f010d703b32de9bfb20ab90ece38ab2f25977f -// -// If we compile using Visual Studio 2019 with `c++latest` (C++20) without the GMock fix, -// then the compilation here fails in `gmock-actions.h` from: -// .\tools\vcpkg\installed\x64-windows\include\gmock\gmock-actions.h(819): -// error C2653: 'result_of': is not a class or namespace name -// -// That is because `std::result_of` has been removed in C++20. - -# include "opentelemetry/exporters/otlp/otlp_grpc_exporter.h" -# include "opentelemetry/exporters/otlp/otlp_grpc_exporter_factory.h" -# include "opentelemetry/exporters/otlp/protobuf_include_prefix.h" - -// Problematic code that pulls in Gmock and breaks with vs2019/c++latest : +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "gmock/gmock.h" + +#include "opentelemetry/exporters/otlp/otlp_grpc_exporter.h" +#include "opentelemetry/exporters/otlp/otlp_grpc_exporter_factory.h" +#include "opentelemetry/exporters/otlp/otlp_grpc_exporter_options.h" +#include "opentelemetry/nostd/shared_ptr.h" +#include "opentelemetry/nostd/span.h" +#include "opentelemetry/sdk/common/exporter_utils.h" +#include "opentelemetry/sdk/trace/exporter.h" +#include "opentelemetry/sdk/trace/processor.h" +#include "opentelemetry/sdk/trace/recordable.h" +#include "opentelemetry/sdk/trace/simple_processor.h" +#include "opentelemetry/sdk/trace/simple_processor_factory.h" +#include "opentelemetry/sdk/trace/tracer_provider.h" +#include "opentelemetry/sdk/trace/tracer_provider_factory.h" +#include "opentelemetry/trace/span.h" +#include "opentelemetry/trace/tracer.h" +#include "opentelemetry/trace/tracer_provider.h" +#include "opentelemetry/version.h" + +// clang-format off +# include "opentelemetry/exporters/otlp/protobuf_include_prefix.h" // IWYU pragma: keep # include "opentelemetry/proto/collector/trace/v1/trace_service_mock.grpc.pb.h" - # include "opentelemetry/proto/collector/trace/v1/trace_service.grpc.pb.h" +# include "opentelemetry/exporters/otlp/protobuf_include_suffix.h" // IWYU pragma: keep +// clang-format on -# include "opentelemetry/exporters/otlp/protobuf_include_suffix.h" - -# include "opentelemetry/nostd/shared_ptr.h" -# include "opentelemetry/sdk/trace/simple_processor.h" -# include "opentelemetry/sdk/trace/simple_processor_factory.h" -# include "opentelemetry/sdk/trace/tracer_provider.h" -# include "opentelemetry/sdk/trace/tracer_provider_factory.h" -# include "opentelemetry/trace/provider.h" -# include "opentelemetry/trace/tracer_provider.h" - -# include -# include -# include - -# if defined(_MSC_VER) -# include "opentelemetry/sdk/common/env_variables.h" +#if defined(_MSC_VER) +# include "opentelemetry/sdk/common/env_variables.h" using opentelemetry::sdk::common::setenv; using opentelemetry::sdk::common::unsetenv; -# endif +#endif using namespace testing; @@ -59,14 +64,14 @@ class OtlpMockTraceServiceStub : public proto::collector::trace::v1::MockTraceSe { public: // Some old toolchains can only use gRPC 1.33 and it's experimental. -# if defined(GRPC_CPP_VERSION_MAJOR) && \ - (GRPC_CPP_VERSION_MAJOR * 1000 + GRPC_CPP_VERSION_MINOR) >= 1039 +#if defined(GRPC_CPP_VERSION_MAJOR) && \ + (GRPC_CPP_VERSION_MAJOR * 1000 + GRPC_CPP_VERSION_MINOR) >= 1039 using async_interface_base = proto::collector::trace::v1::TraceService::StubInterface::async_interface; -# else +#else using async_interface_base = proto::collector::trace::v1::TraceService::StubInterface::experimental_async_interface; -# endif +#endif OtlpMockTraceServiceStub() : async_interface_(this) {} @@ -86,23 +91,23 @@ class OtlpMockTraceServiceStub : public proto::collector::trace::v1::MockTraceSe } // Some old toolchains can only use gRPC 1.33 and it's experimental. -# if defined(GRPC_CPP_VERSION_MAJOR) && \ - (GRPC_CPP_VERSION_MAJOR * 1000 + GRPC_CPP_VERSION_MINOR) >= 1039 || \ - defined(GRPC_CALLBACK_API_NONEXPERIMENTAL) +#if defined(GRPC_CPP_VERSION_MAJOR) && \ + (GRPC_CPP_VERSION_MAJOR * 1000 + GRPC_CPP_VERSION_MINOR) >= 1039 || \ + defined(GRPC_CALLBACK_API_NONEXPERIMENTAL) void Export( ::grpc::ClientContext * /*context*/, const ::opentelemetry::proto::collector::trace::v1::ExportTraceServiceRequest * /*request*/, ::opentelemetry::proto::collector::trace::v1::ExportTraceServiceResponse * /*response*/, ::grpc::ClientUnaryReactor * /*reactor*/) override {} -# else +#else void Export( ::grpc::ClientContext * /*context*/, const ::opentelemetry::proto::collector::trace::v1::ExportTraceServiceRequest * /*request*/, ::opentelemetry::proto::collector::trace::v1::ExportTraceServiceResponse * /*response*/, ::grpc::experimental::ClientUnaryReactor * /*reactor*/) {} -# endif +#endif private: OtlpMockTraceServiceStub *stub_; @@ -188,12 +193,12 @@ TEST_F(OtlpGrpcExporterTestPeer, ExportUnitTest) .WillOnce(Return(grpc::Status::CANCELLED)); result = exporter->Export(batch_2); exporter->ForceFlush(); -# if defined(ENABLE_ASYNC_EXPORT) +#if defined(ENABLE_ASYNC_EXPORT) EXPECT_EQ(sdk::common::ExportResult::kSuccess, result); EXPECT_FALSE(mock_stub->GetLastAsyncStatus().ok()); -# else +#else EXPECT_EQ(sdk::common::ExportResult::kFailure, result); -# endif +#endif } // Create spans, let processor call Export() @@ -242,7 +247,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) { @@ -402,9 +407,9 @@ TEST_F(OtlpGrpcExporterTestPeer, ConfigRetryGenericValuesFromEnv) unsetenv("OTEL_CPP_EXPORTER_OTLP_RETRY_MAX_BACKOFF"); unsetenv("OTEL_CPP_EXPORTER_OTLP_RETRY_BACKOFF_MULTIPLIER"); } -# endif // NO_GETENV +#endif // NO_GETENV -# ifdef ENABLE_OTLP_RETRY_PREVIEW +#ifdef ENABLE_OTLP_RETRY_PREVIEW struct TestTraceService : public opentelemetry::proto::collector::trace::v1::TraceService::Service { TestTraceService(const std::vector &status_codes) : status_codes_(status_codes) @@ -558,9 +563,8 @@ TEST_P(OtlpGrpcExporterRetryIntegrationTests, StatusCodes) ASSERT_EQ(expected_attempts, service.request_count_); } -# endif // ENABLE_OTLP_RETRY_PREVIEW +#endif // ENABLE_OTLP_RETRY_PREVIEW } // namespace otlp } // namespace exporter OPENTELEMETRY_END_NAMESPACE -#endif /* OPENTELEMETRY_STL_VERSION */ diff --git a/exporters/otlp/test/otlp_grpc_metric_exporter_test.cc b/exporters/otlp/test/otlp_grpc_metric_exporter_test.cc index 098c2c85c0..b670846c01 100644 --- a/exporters/otlp/test/otlp_grpc_metric_exporter_test.cc +++ b/exporters/otlp/test/otlp_grpc_metric_exporter_test.cc @@ -1,45 +1,34 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -#ifndef OPENTELEMETRY_STL_VERSION -// Unfortunately as of 04/27/2021 the fix is NOT in the vcpkg snapshot of Google Test. -// Remove above `#ifdef` once the GMock fix for C++20 is in the mainline. -// -// Please refer to this GitHub issue for additional details: -// https://github.com/google/googletest/issues/2914 -// https://github.com/google/googletest/commit/61f010d703b32de9bfb20ab90ece38ab2f25977f -// -// If we compile using Visual Studio 2019 with `c++latest` (C++20) without the GMock fix, -// then the compilation here fails in `gmock-actions.h` from: -// .\tools\vcpkg\installed\x64-windows\include\gmock\gmock-actions.h(819): -// error C2653: 'result_of': is not a class or namespace name -// -// That is because `std::result_of` has been removed in C++20. - -# include "opentelemetry/exporters/otlp/otlp_grpc_metric_exporter.h" - -# include "opentelemetry/exporters/otlp/protobuf_include_prefix.h" - -// Problematic code that pulls in Gmock and breaks with vs2019/c++latest : -# include "opentelemetry/proto/collector/metrics/v1/metrics_service_mock.grpc.pb.h" - -# include "opentelemetry/exporters/otlp/protobuf_include_suffix.h" - -# include "opentelemetry/exporters/otlp/otlp_grpc_client.h" -# include "opentelemetry/exporters/otlp/otlp_grpc_client_factory.h" - -# include "opentelemetry/sdk/trace/simple_processor.h" -# include "opentelemetry/sdk/trace/tracer_provider.h" -# include "opentelemetry/trace/provider.h" - -# include -# include - -# if defined(_MSC_VER) -# include "opentelemetry/sdk/common/env_variables.h" +#include +#include +#include +#include +#include +#include +#include + +#include "opentelemetry/exporters/otlp/otlp_grpc_client.h" +#include "opentelemetry/exporters/otlp/otlp_grpc_client_factory.h" +#include "opentelemetry/exporters/otlp/otlp_grpc_metric_exporter.h" +#include "opentelemetry/exporters/otlp/otlp_grpc_metric_exporter_options.h" +#include "opentelemetry/exporters/otlp/otlp_preferred_temporality.h" +#include "opentelemetry/sdk/metrics/instruments.h" +#include "opentelemetry/sdk/metrics/push_metric_exporter.h" +#include "opentelemetry/version.h" + +// clang-format off +# include "opentelemetry/exporters/otlp/protobuf_include_prefix.h" // IWYU pragma: keep +# include "opentelemetry/proto/collector/metrics/v1/metrics_service.grpc.pb.h" +# include "opentelemetry/exporters/otlp/protobuf_include_suffix.h" // IWYU pragma: keep +// clang-format on + +#if defined(_MSC_VER) +# include "opentelemetry/sdk/common/env_variables.h" using opentelemetry::sdk::common::setenv; using opentelemetry::sdk::common::unsetenv; -# endif +#endif using namespace testing; @@ -109,7 +98,7 @@ TEST_F(OtlpGrpcMetricExporterTestPeer, 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(OtlpGrpcMetricExporterTestPeer, ConfigFromEnv) { @@ -269,7 +258,7 @@ TEST_F(OtlpGrpcMetricExporterTestPeer, ConfigRetryGenericValuesFromEnv) unsetenv("OTEL_CPP_EXPORTER_OTLP_RETRY_MAX_BACKOFF"); unsetenv("OTEL_CPP_EXPORTER_OTLP_RETRY_BACKOFF_MULTIPLIER"); } -# endif // NO_GETENV +#endif // NO_GETENV TEST_F(OtlpGrpcMetricExporterTestPeer, CheckGetAggregationTemporality) { @@ -303,4 +292,3 @@ TEST_F(OtlpGrpcMetricExporterTestPeer, CheckGetAggregationTemporality) } // namespace otlp } // namespace exporter OPENTELEMETRY_END_NAMESPACE -#endif /* OPENTELEMETRY_STL_VERSION */ diff --git a/exporters/otlp/test/otlp_http_exporter_custom_client_test.cc b/exporters/otlp/test/otlp_http_exporter_custom_client_test.cc index e90088be7b..1b5edabf55 100644 --- a/exporters/otlp/test/otlp_http_exporter_custom_client_test.cc +++ b/exporters/otlp/test/otlp_http_exporter_custom_client_test.cc @@ -1,25 +1,33 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -#ifndef OPENTELEMETRY_STL_VERSION - -# include - -# include "opentelemetry/exporters/otlp/otlp_http_client.h" -# include "opentelemetry/exporters/otlp/otlp_http_exporter.h" -# include "opentelemetry/exporters/otlp/otlp_http_exporter_factory.h" -# include "opentelemetry/exporters/otlp/otlp_http_exporter_options.h" -# include "opentelemetry/exporters/otlp/otlp_http_exporter_runtime_options.h" -# include "opentelemetry/ext/http/client/http_client_factory.h" -# include "opentelemetry/sdk/trace/batch_span_processor.h" -# include "opentelemetry/sdk/trace/batch_span_processor_options.h" -# include "opentelemetry/sdk/trace/tracer_provider.h" -# include "opentelemetry/test_common/ext/http/client/http_client_test_factory.h" -# include "opentelemetry/test_common/ext/http/client/nosend/http_client_factory_nosend.h" -# include "opentelemetry/test_common/ext/http/client/nosend/http_client_nosend.h" - -# include -# include "gmock/gmock.h" +#include +#include +#include +#include +#include "gmock/gmock.h" + +#include "opentelemetry/exporters/otlp/otlp_http_client.h" +#include "opentelemetry/exporters/otlp/otlp_http_exporter.h" +#include "opentelemetry/exporters/otlp/otlp_http_exporter_factory.h" +#include "opentelemetry/exporters/otlp/otlp_http_exporter_options.h" +#include "opentelemetry/exporters/otlp/otlp_http_exporter_runtime_options.h" +#include "opentelemetry/ext/http/client/http_client.h" +#include "opentelemetry/nostd/shared_ptr.h" +#include "opentelemetry/nostd/string_view.h" +#include "opentelemetry/sdk/common/thread_instrumentation.h" +#include "opentelemetry/sdk/trace/batch_span_processor.h" +#include "opentelemetry/sdk/trace/batch_span_processor_options.h" +#include "opentelemetry/sdk/trace/exporter.h" +#include "opentelemetry/sdk/trace/processor.h" +#include "opentelemetry/sdk/trace/tracer_provider.h" +#include "opentelemetry/trace/span.h" +#include "opentelemetry/trace/tracer.h" +#include "opentelemetry/version.h" + +#include "opentelemetry/test_common/ext/http/client/http_client_test_factory.h" +#include "opentelemetry/test_common/ext/http/client/nosend/http_client_factory_nosend.h" +#include "opentelemetry/test_common/ext/http/client/nosend/http_client_nosend.h" using namespace testing; @@ -148,5 +156,3 @@ TEST_F(OtlpHttpExporterCustomClientTestPeer, ExportCallsSendRequest) } // namespace otlp } // namespace exporter OPENTELEMETRY_END_NAMESPACE - -#endif // OPENTELEMETRY_STL_VERSION diff --git a/exporters/otlp/test/otlp_http_exporter_test.cc b/exporters/otlp/test/otlp_http_exporter_test.cc index 3cbfa9d16c..2c08afccf3 100644 --- a/exporters/otlp/test/otlp_http_exporter_test.cc +++ b/exporters/otlp/test/otlp_http_exporter_test.cc @@ -1,44 +1,67 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -#ifndef OPENTELEMETRY_STL_VERSION - -# include -# include - -# include "opentelemetry/exporters/otlp/otlp_http_exporter.h" -# include "opentelemetry/exporters/otlp/otlp_http_exporter_factory.h" - -# include "opentelemetry/exporters/otlp/protobuf_include_prefix.h" - -# include "opentelemetry/proto/collector/trace/v1/trace_service.pb.h" - -# include "opentelemetry/exporters/otlp/protobuf_include_suffix.h" - -# include "opentelemetry/ext/http/client/http_client_factory.h" -# include "opentelemetry/ext/http/server/http_server.h" -# include "opentelemetry/sdk/trace/batch_span_processor.h" -# include "opentelemetry/sdk/trace/batch_span_processor_options.h" -# include "opentelemetry/sdk/trace/simple_processor.h" -# include "opentelemetry/sdk/trace/simple_processor_factory.h" -# include "opentelemetry/sdk/trace/tracer_provider.h" -# include "opentelemetry/sdk/trace/tracer_provider_factory.h" -# include "opentelemetry/test_common/ext/http/client/http_client_test_factory.h" -# include "opentelemetry/test_common/ext/http/client/nosend/http_client_nosend.h" -# include "opentelemetry/trace/provider.h" -# include "opentelemetry/trace/tracer_provider.h" - -# include -# include -# include "gmock/gmock.h" - -# include "nlohmann/json.hpp" - -# if defined(_MSC_VER) -# include "opentelemetry/sdk/common/env_variables.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "gmock/gmock.h" +#include "nlohmann/json.hpp" + +#include "opentelemetry/common/timestamp.h" +#include "opentelemetry/context/context.h" +#include "opentelemetry/exporters/otlp/otlp_environment.h" +#include "opentelemetry/exporters/otlp/otlp_http.h" +#include "opentelemetry/exporters/otlp/otlp_http_client.h" +#include "opentelemetry/exporters/otlp/otlp_http_exporter.h" +#include "opentelemetry/exporters/otlp/otlp_http_exporter_factory.h" +#include "opentelemetry/exporters/otlp/otlp_http_exporter_options.h" +#include "opentelemetry/ext/http/client/http_client.h" +#include "opentelemetry/ext/http/server/http_server.h" +#include "opentelemetry/nostd/shared_ptr.h" +#include "opentelemetry/nostd/span.h" +#include "opentelemetry/nostd/string_view.h" +#include "opentelemetry/nostd/variant.h" +#include "opentelemetry/proto/trace/v1/trace.pb.h" +#include "opentelemetry/sdk/common/exporter_utils.h" +#include "opentelemetry/sdk/common/thread_instrumentation.h" +#include "opentelemetry/sdk/resource/resource.h" +#include "opentelemetry/sdk/trace/batch_span_processor.h" +#include "opentelemetry/sdk/trace/batch_span_processor_options.h" +#include "opentelemetry/sdk/trace/exporter.h" +#include "opentelemetry/sdk/trace/processor.h" +#include "opentelemetry/sdk/trace/recordable.h" +#include "opentelemetry/sdk/trace/simple_processor_factory.h" +#include "opentelemetry/sdk/trace/tracer_provider.h" +#include "opentelemetry/sdk/trace/tracer_provider_factory.h" +#include "opentelemetry/test_common/ext/http/client/http_client_test_factory.h" +#include "opentelemetry/test_common/ext/http/client/nosend/http_client_nosend.h" +#include "opentelemetry/trace/span.h" +#include "opentelemetry/trace/span_context.h" +#include "opentelemetry/trace/span_startoptions.h" +#include "opentelemetry/trace/trace_id.h" +#include "opentelemetry/trace/tracer.h" +#include "opentelemetry/version.h" + +// clang-format off +#include "opentelemetry/exporters/otlp/protobuf_include_prefix.h" // IWYU pragma: keep +// IWYU pragma: no_include +#include "opentelemetry/proto/collector/trace/v1/trace_service.pb.h" +#include "opentelemetry/exporters/otlp/protobuf_include_suffix.h" // IWYU pragma: keep +// clang-format on + +#if defined(_MSC_VER) +# include "opentelemetry/sdk/common/env_variables.h" using opentelemetry::sdk::common::setenv; using opentelemetry::sdk::common::unsetenv; -# endif +#endif using namespace testing; OPENTELEMETRY_BEGIN_NAMESPACE @@ -227,7 +250,7 @@ class OtlpHttpExporterTestPeer : public ::testing::Test EXPECT_GE(received_trace_id_counter, 1); } -# ifdef ENABLE_ASYNC_EXPORT +#ifdef ENABLE_ASYNC_EXPORT void ExportJsonIntegrationTestAsync() { auto mock_otlp_client = @@ -342,7 +365,7 @@ class OtlpHttpExporterTestPeer : public ::testing::Test // Exporting can be retried EXPECT_GE(received_trace_id_counter, 1); } -# endif +#endif void ExportBinaryIntegrationTest() { @@ -440,7 +463,7 @@ class OtlpHttpExporterTestPeer : public ::testing::Test EXPECT_GE(received_trace_id_counter, 1); } -# ifdef ENABLE_ASYNC_EXPORT +#ifdef ENABLE_ASYNC_EXPORT void ExportBinaryIntegrationTestAsync() { auto mock_otlp_client = @@ -540,7 +563,7 @@ class OtlpHttpExporterTestPeer : public ::testing::Test // Exporting can be retried EXPECT_GE(received_trace_id_counter, 1); } -# endif +#endif }; TEST(OtlpHttpExporterTest, Shutdown) @@ -560,13 +583,13 @@ TEST_F(OtlpHttpExporterTestPeer, ExportJsonIntegrationTestSync) ExportJsonIntegrationTest(); } -# ifdef ENABLE_ASYNC_EXPORT +#ifdef ENABLE_ASYNC_EXPORT TEST_F(OtlpHttpExporterTestPeer, ExportJsonIntegrationTestAsync) { ExportJsonIntegrationTestAsync(); google::protobuf::ShutdownProtobufLibrary(); } -# endif +#endif // Create spans, let processor call Export() TEST_F(OtlpHttpExporterTestPeer, ExportBinaryIntegrationTestSync) @@ -574,12 +597,12 @@ TEST_F(OtlpHttpExporterTestPeer, ExportBinaryIntegrationTestSync) ExportBinaryIntegrationTest(); } -# ifdef ENABLE_ASYNC_EXPORT +#ifdef ENABLE_ASYNC_EXPORT TEST_F(OtlpHttpExporterTestPeer, ExportBinaryIntegrationTestAsync) { ExportBinaryIntegrationTestAsync(); } -# endif +#endif // Test exporter configuration options TEST_F(OtlpHttpExporterTestPeer, ConfigTest) @@ -614,7 +637,7 @@ TEST(OtlpHttpExporterTest, ConfigDefaultProtocolTest) EXPECT_EQ(opts.content_type, HttpRequestContentType::kBinary); } -# ifndef NO_GETENV +#ifndef NO_GETENV // Test exporter configuration options with use_ssl_credentials TEST_F(OtlpHttpExporterTestPeer, ConfigFromEnv) { @@ -751,9 +774,9 @@ TEST_F(OtlpHttpExporterTestPeer, ConfigRetryGenericValuesFromEnv) unsetenv("OTEL_CPP_EXPORTER_OTLP_RETRY_MAX_BACKOFF"); unsetenv("OTEL_CPP_EXPORTER_OTLP_RETRY_BACKOFF_MULTIPLIER"); } -# endif // NO_GETENV +#endif // NO_GETENV -# ifdef ENABLE_OTLP_RETRY_PREVIEW +#ifdef ENABLE_OTLP_RETRY_PREVIEW using StatusCodeVector = std::vector; class OtlpHttpExporterRetryIntegrationTests @@ -856,9 +879,8 @@ TEST_P(OtlpHttpExporterRetryIntegrationTests, StatusCodes) ASSERT_EQ(expected_attempts, request_count); } -# endif // ENABLE_OTLP_RETRY_PREVIEW +#endif // ENABLE_OTLP_RETRY_PREVIEW } // namespace otlp } // namespace exporter OPENTELEMETRY_END_NAMESPACE -#endif /* OPENTELEMETRY_STL_VERSION */ diff --git a/exporters/otlp/test/otlp_http_log_record_exporter_custom_client_test.cc b/exporters/otlp/test/otlp_http_log_record_exporter_custom_client_test.cc index 82645ab3e1..be61fc92b1 100644 --- a/exporters/otlp/test/otlp_http_log_record_exporter_custom_client_test.cc +++ b/exporters/otlp/test/otlp_http_log_record_exporter_custom_client_test.cc @@ -1,16 +1,19 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -#ifndef OPENTELEMETRY_STL_VERSION +#include +#include +#include +#include -# include "opentelemetry/exporters/otlp/otlp_http_log_record_exporter_factory.h" -# include "opentelemetry/exporters/otlp/otlp_http_log_record_exporter_options.h" -# include "opentelemetry/exporters/otlp/otlp_http_log_record_exporter_runtime_options.h" -# include "opentelemetry/ext/http/client/http_client_factory.h" -# include "opentelemetry/test_common/ext/http/client/http_client_test_factory.h" -# include "opentelemetry/test_common/ext/http/client/nosend/http_client_factory_nosend.h" +#include "opentelemetry/exporters/otlp/otlp_http_log_record_exporter_factory.h" +#include "opentelemetry/exporters/otlp/otlp_http_log_record_exporter_options.h" +#include "opentelemetry/exporters/otlp/otlp_http_log_record_exporter_runtime_options.h" +#include "opentelemetry/sdk/logs/exporter.h" +#include "opentelemetry/version.h" -# include +#include "opentelemetry/test_common/ext/http/client/http_client_test_factory.h" +#include "opentelemetry/test_common/ext/http/client/nosend/http_client_factory_nosend.h" namespace http_client = opentelemetry::ext::http::client; @@ -60,5 +63,3 @@ TEST(OtlpHttpLogRecordExporterCustomClientTest, RuntimeOptionsWithHttpClientCrea } // namespace otlp } // namespace exporter OPENTELEMETRY_END_NAMESPACE - -#endif // OPENTELEMETRY_STL_VERSION diff --git a/exporters/otlp/test/otlp_http_log_record_exporter_test.cc b/exporters/otlp/test/otlp_http_log_record_exporter_test.cc index 3fca7a06ea..ca19af024f 100644 --- a/exporters/otlp/test/otlp_http_log_record_exporter_test.cc +++ b/exporters/otlp/test/otlp_http_log_record_exporter_test.cc @@ -1,41 +1,59 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -#ifndef OPENTELEMETRY_STL_VERSION - -# include -# include - -# include "opentelemetry/exporters/otlp/otlp_http_log_record_exporter.h" - -# include "opentelemetry/exporters/otlp/protobuf_include_prefix.h" - -# include "opentelemetry/proto/collector/logs/v1/logs_service.pb.h" - -# include "opentelemetry/exporters/otlp/protobuf_include_suffix.h" - -# include "opentelemetry/common/key_value_iterable_view.h" -# include "opentelemetry/ext/http/client/http_client_factory.h" -# include "opentelemetry/ext/http/server/http_server.h" -# include "opentelemetry/logs/provider.h" -# include "opentelemetry/sdk/logs/batch_log_record_processor.h" -# include "opentelemetry/sdk/logs/exporter.h" -# include "opentelemetry/sdk/logs/logger_provider.h" -# include "opentelemetry/sdk/resource/resource.h" -# include "opentelemetry/test_common/ext/http/client/http_client_test_factory.h" -# include "opentelemetry/test_common/ext/http/client/nosend/http_client_nosend.h" - -# include -# include -# include "gmock/gmock.h" - -# include "nlohmann/json.hpp" - -# if defined(_MSC_VER) -# include "opentelemetry/sdk/common/env_variables.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include "gmock/gmock.h" +#include "nlohmann/json.hpp" + +#include "opentelemetry/common/key_value_iterable_view.h" +#include "opentelemetry/exporters/otlp/otlp_environment.h" +#include "opentelemetry/exporters/otlp/otlp_http.h" +#include "opentelemetry/exporters/otlp/otlp_http_client.h" +#include "opentelemetry/exporters/otlp/otlp_http_log_record_exporter.h" +#include "opentelemetry/exporters/otlp/otlp_http_log_record_exporter_options.h" +#include "opentelemetry/ext/http/client/http_client.h" +#include "opentelemetry/logs/logger.h" +#include "opentelemetry/logs/severity.h" +#include "opentelemetry/nostd/shared_ptr.h" +#include "opentelemetry/nostd/span.h" +#include "opentelemetry/nostd/string_view.h" +#include "opentelemetry/proto/common/v1/common.pb.h" +#include "opentelemetry/proto/logs/v1/logs.pb.h" +#include "opentelemetry/sdk/common/exporter_utils.h" +#include "opentelemetry/sdk/common/thread_instrumentation.h" +#include "opentelemetry/sdk/logs/batch_log_record_processor.h" +#include "opentelemetry/sdk/logs/batch_log_record_processor_options.h" +#include "opentelemetry/sdk/logs/exporter.h" +#include "opentelemetry/sdk/logs/logger_provider.h" +#include "opentelemetry/sdk/logs/processor.h" +#include "opentelemetry/sdk/logs/recordable.h" +#include "opentelemetry/test_common/ext/http/client/http_client_test_factory.h" +#include "opentelemetry/test_common/ext/http/client/nosend/http_client_nosend.h" +#include "opentelemetry/trace/span_id.h" +#include "opentelemetry/trace/trace_flags.h" +#include "opentelemetry/trace/trace_id.h" +#include "opentelemetry/version.h" + +// clang-format off +#include "opentelemetry/exporters/otlp/protobuf_include_prefix.h" // IWYU pragma: keep +// IWYU pragma: no_include +// IWYU pragma: no_include +#include "opentelemetry/proto/collector/logs/v1/logs_service.pb.h" +#include "opentelemetry/exporters/otlp/protobuf_include_suffix.h" // IWYU pragma: keep +// clang-format on + +#if defined(_MSC_VER) +# include "opentelemetry/sdk/common/env_variables.h" using opentelemetry::sdk::common::setenv; using opentelemetry::sdk::common::unsetenv; -# endif +#endif using namespace testing; @@ -244,7 +262,7 @@ class OtlpHttpLogRecordExporterTestPeer : public ::testing::Test EXPECT_GE(received_record_counter, 1); } -# ifdef ENABLE_ASYNC_EXPORT +#ifdef ENABLE_ASYNC_EXPORT void ExportJsonIntegrationTestAsync() { auto mock_otlp_client = OtlpHttpLogRecordExporterTestPeer::GetMockOtlpHttpClient( @@ -390,7 +408,7 @@ class OtlpHttpLogRecordExporterTestPeer : public ::testing::Test // Exporting can be retried EXPECT_GE(received_record_counter, 1); } -# endif +#endif void ExportBinaryIntegrationTest() { @@ -518,7 +536,7 @@ class OtlpHttpLogRecordExporterTestPeer : public ::testing::Test EXPECT_GE(received_record_counter, 1); } -# ifdef ENABLE_ASYNC_EXPORT +#ifdef ENABLE_ASYNC_EXPORT void ExportBinaryIntegrationTestAsync() { auto mock_otlp_client = OtlpHttpLogRecordExporterTestPeer::GetMockOtlpHttpClient( @@ -648,7 +666,7 @@ class OtlpHttpLogRecordExporterTestPeer : public ::testing::Test // Exporting can be retried EXPECT_GE(received_record_counter, 1); } -# endif +#endif }; TEST(OtlpHttpLogRecordExporterTest, Shutdown) @@ -669,13 +687,13 @@ TEST_F(OtlpHttpLogRecordExporterTestPeer, ExportJsonIntegrationTestSync) ExportJsonIntegrationTest(); } -# ifdef ENABLE_ASYNC_EXPORT +#ifdef ENABLE_ASYNC_EXPORT TEST_F(OtlpHttpLogRecordExporterTestPeer, ExportJsonIntegrationTestAsync) { ExportJsonIntegrationTestAsync(); google::protobuf::ShutdownProtobufLibrary(); } -# endif +#endif // Create log records, let processor call Export() TEST_F(OtlpHttpLogRecordExporterTestPeer, ExportBinaryIntegrationTestSync) @@ -683,12 +701,12 @@ TEST_F(OtlpHttpLogRecordExporterTestPeer, ExportBinaryIntegrationTestSync) ExportBinaryIntegrationTest(); } -# ifdef ENABLE_ASYNC_EXPORT +#ifdef ENABLE_ASYNC_EXPORT TEST_F(OtlpHttpLogRecordExporterTestPeer, ExportBinaryIntegrationTestAsync) { ExportBinaryIntegrationTestAsync(); } -# endif +#endif // Test exporter configuration options TEST_F(OtlpHttpLogRecordExporterTestPeer, ConfigTest) @@ -723,7 +741,7 @@ TEST(OtlpHttpLogRecordExporterTest, ConfigDefaultProtocolTest) EXPECT_EQ(opts.content_type, HttpRequestContentType::kBinary); } -# ifndef NO_GETENV +#ifndef NO_GETENV // Test exporter configuration options with use_ssl_credentials TEST_F(OtlpHttpLogRecordExporterTestPeer, ConfigFromEnv) { @@ -867,9 +885,8 @@ TEST_F(OtlpHttpLogRecordExporterTestPeer, ConfigRetryGenericValuesFromEnv) unsetenv("OTEL_CPP_EXPORTER_OTLP_RETRY_MAX_BACKOFF"); unsetenv("OTEL_CPP_EXPORTER_OTLP_RETRY_BACKOFF_MULTIPLIER"); } -# endif // NO_GETENV +#endif // NO_GETENV } // namespace otlp } // namespace exporter OPENTELEMETRY_END_NAMESPACE -#endif /* OPENTELEMETRY_STL_VERSION */ diff --git a/exporters/otlp/test/otlp_http_metric_exporter_custom_client_test.cc b/exporters/otlp/test/otlp_http_metric_exporter_custom_client_test.cc index 58cbfe28e8..96f3c59c75 100644 --- a/exporters/otlp/test/otlp_http_metric_exporter_custom_client_test.cc +++ b/exporters/otlp/test/otlp_http_metric_exporter_custom_client_test.cc @@ -1,16 +1,19 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -#ifndef OPENTELEMETRY_STL_VERSION +#include +#include +#include +#include -# include "opentelemetry/exporters/otlp/otlp_http_metric_exporter_factory.h" -# include "opentelemetry/exporters/otlp/otlp_http_metric_exporter_options.h" -# include "opentelemetry/exporters/otlp/otlp_http_metric_exporter_runtime_options.h" -# include "opentelemetry/ext/http/client/http_client_factory.h" -# include "opentelemetry/test_common/ext/http/client/http_client_test_factory.h" -# include "opentelemetry/test_common/ext/http/client/nosend/http_client_factory_nosend.h" +#include "opentelemetry/exporters/otlp/otlp_http_metric_exporter_factory.h" +#include "opentelemetry/exporters/otlp/otlp_http_metric_exporter_options.h" +#include "opentelemetry/exporters/otlp/otlp_http_metric_exporter_runtime_options.h" +#include "opentelemetry/sdk/metrics/push_metric_exporter.h" +#include "opentelemetry/version.h" -# include +#include "opentelemetry/test_common/ext/http/client/http_client_test_factory.h" +#include "opentelemetry/test_common/ext/http/client/nosend/http_client_factory_nosend.h" namespace http_client = opentelemetry::ext::http::client; @@ -60,5 +63,3 @@ TEST(OtlpHttpMetricExporterCustomClientTest, RuntimeOptionsWithHttpClientCreates } // namespace otlp } // namespace exporter OPENTELEMETRY_END_NAMESPACE - -#endif // OPENTELEMETRY_STL_VERSION diff --git a/exporters/zipkin/include/opentelemetry/exporters/zipkin/zipkin_exporter.h b/exporters/zipkin/include/opentelemetry/exporters/zipkin/zipkin_exporter.h index cb4d8f099b..8fdd99bff4 100644 --- a/exporters/zipkin/include/opentelemetry/exporters/zipkin/zipkin_exporter.h +++ b/exporters/zipkin/include/opentelemetry/exporters/zipkin/zipkin_exporter.h @@ -13,10 +13,7 @@ #include "opentelemetry/ext/http/client/http_client.h" #include "opentelemetry/ext/http/client/http_client_factory.h" #include "opentelemetry/ext/http/common/url_parser.h" -#include "opentelemetry/nostd/span.h" -#include "opentelemetry/sdk/common/exporter_utils.h" #include "opentelemetry/sdk/trace/exporter.h" -#include "opentelemetry/sdk/trace/recordable.h" #include "opentelemetry/version.h" OPENTELEMETRY_BEGIN_NAMESPACE diff --git a/exporters/zipkin/test/zipkin_exporter_test.cc b/exporters/zipkin/test/zipkin_exporter_test.cc index 086357c07f..3d5718ac38 100644 --- a/exporters/zipkin/test/zipkin_exporter_test.cc +++ b/exporters/zipkin/test/zipkin_exporter_test.cc @@ -1,31 +1,51 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -#ifndef OPENTELEMETRY_STL_VERSION - -# include "opentelemetry/exporters/zipkin/zipkin_exporter.h" -# include "opentelemetry/exporters/zipkin/zipkin_exporter_factory.h" -# include "opentelemetry/ext/http/client/curl/http_client_curl.h" -# include "opentelemetry/ext/http/server/http_server.h" -# include "opentelemetry/sdk/trace/batch_span_processor.h" -# include "opentelemetry/sdk/trace/batch_span_processor_options.h" -# include "opentelemetry/sdk/trace/tracer_provider.h" -# include "opentelemetry/test_common/ext/http/client/nosend/http_client_factory_nosend.h" -# include "opentelemetry/trace/provider.h" - -# include -# include "gmock/gmock.h" - -# include "nlohmann/json.hpp" - -# include -# include - -# if defined(_MSC_VER) -# include "opentelemetry/sdk/common/env_variables.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include "gmock/gmock.h" +#include "nlohmann/json.hpp" + +#include "opentelemetry/common/timestamp.h" +#include "opentelemetry/context/context.h" +#include "opentelemetry/exporters/zipkin/zipkin_exporter.h" +#include "opentelemetry/exporters/zipkin/zipkin_exporter_factory.h" +#include "opentelemetry/exporters/zipkin/zipkin_exporter_options.h" +#include "opentelemetry/ext/http/client/curl/http_client_curl.h" +#include "opentelemetry/ext/http/client/http_client.h" +#include "opentelemetry/nostd/shared_ptr.h" +#include "opentelemetry/nostd/span.h" +#include "opentelemetry/nostd/string_view.h" +#include "opentelemetry/nostd/variant.h" +#include "opentelemetry/sdk/common/exporter_utils.h" +#include "opentelemetry/sdk/resource/resource.h" +#include "opentelemetry/sdk/trace/batch_span_processor.h" +#include "opentelemetry/sdk/trace/batch_span_processor_options.h" +#include "opentelemetry/sdk/trace/exporter.h" +#include "opentelemetry/sdk/trace/processor.h" +#include "opentelemetry/sdk/trace/recordable.h" +#include "opentelemetry/sdk/trace/tracer_provider.h" +#include "opentelemetry/trace/span.h" +#include "opentelemetry/trace/span_context.h" +#include "opentelemetry/trace/span_startoptions.h" +#include "opentelemetry/trace/trace_id.h" +#include "opentelemetry/trace/tracer.h" +#include "opentelemetry/trace/tracer_provider.h" +#include "opentelemetry/version.h" + +#include "opentelemetry/test_common/ext/http/client/nosend/http_client_factory_nosend.h" + +#if defined(_MSC_VER) +# include "opentelemetry/sdk/common/env_variables.h" using opentelemetry::sdk::common::setenv; using opentelemetry::sdk::common::unsetenv; -# endif +#endif namespace sdk_common = opentelemetry::sdk::common; using namespace testing; @@ -211,7 +231,7 @@ TEST_F(ZipkinExporterTestPeer, ConfigTest) EXPECT_EQ(GetOptions(exporter).endpoint, "http://localhost:45455/v1/traces"); } -# ifndef NO_GETENV +#ifndef NO_GETENV // Test exporter configuration options from env TEST_F(ZipkinExporterTestPeer, ConfigFromEnv) { @@ -224,7 +244,7 @@ TEST_F(ZipkinExporterTestPeer, ConfigFromEnv) unsetenv("OTEL_EXPORTER_ZIPKIN_ENDPOINT"); } -# endif // NO_GETENV +#endif // NO_GETENV TEST_F(ZipkinExporterTestPeer, FactoryInjectionCreatesExporter) { @@ -247,4 +267,3 @@ TEST_F(ZipkinExporterTestPeer, HttpClientSyncInjectionCreatesExporter) } // namespace zipkin } // namespace exporter OPENTELEMETRY_END_NAMESPACE -#endif /* OPENTELEMETRY_STL_VERSION */