From 611906eeafdbfe4a92fd1f81989692a222da1a78 Mon Sep 17 00:00:00 2001 From: Marc Alff Date: Thu, 18 Jul 2024 01:27:46 +0200 Subject: [PATCH] [REMOVAL] Remove build option `WITH_DEPRECATED_SDK_FACTORY` (#2717) --- .github/workflows/iwyu.yml | 1 - CHANGELOG.md | 38 ++++++++ CMakeLists.txt | 19 ---- DEPRECATED.md | 80 +---------------- api/CMakeLists.txt | 5 -- ci/do_ci.ps1 | 2 - ci/do_ci.sh | 4 - examples/logs_simple/main.cc | 10 --- examples/metrics_simple/metrics_ostream.cc | 9 -- examples/otlp/file_log_main.cc | 13 --- examples/otlp/file_main.cc | 8 -- examples/otlp/grpc_log_main.cc | 13 --- examples/otlp/grpc_main.cc | 8 -- examples/otlp/http_log_main.cc | 16 ---- examples/otlp/http_main.cc | 8 -- examples/simple/main.cc | 5 -- .../otlp_grpc_log_record_exporter_test.cc | 7 -- .../sdk/logs/event_logger_provider_factory.h | 9 -- .../sdk/logs/logger_provider_factory.h | 32 ------- .../sdk/metrics/meter_provider_factory.h | 26 ------ .../sdk/trace/tracer_provider_factory.h | 64 -------------- sdk/src/logs/event_logger_provider_factory.cc | 11 --- sdk/src/logs/logger_provider_factory.cc | 46 ---------- sdk/src/metrics/meter_provider_factory.cc | 36 -------- sdk/src/trace/tracer_provider_factory.cc | 86 ------------------- 25 files changed, 39 insertions(+), 517 deletions(-) diff --git a/.github/workflows/iwyu.yml b/.github/workflows/iwyu.yml index 598f57e97e..2c84b84cdc 100644 --- a/.github/workflows/iwyu.yml +++ b/.github/workflows/iwyu.yml @@ -40,7 +40,6 @@ jobs: -DWITH_STL=CXX14 \ -DCMAKE_CXX_INCLUDE_WHAT_YOU_USE="include-what-you-use;-w;-Xiwyu;--mapping_file=${TOPDIR}/.iwyu.imp;" \ -DBUILD_TESTING=OFF \ - -DWITH_DEPRECATED_SDK_FACTORY=OFF \ -DBUILD_W3CTRACECONTEXT_TEST=OFF \ -DWITH_OTLP_GRPC=OFF \ -DWITH_OTLP_HTTP=ON \ diff --git a/CHANGELOG.md b/CHANGELOG.md index e7e13ec3d6..bce84c84df 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,44 @@ Increment the: * [CI] Add a clang-tidy build [#3001](https://github.com/open-telemetry/opentelemetry-cpp/pull/3001) +* [REMOVAL] Remove build option `WITH_DEPRECATED_SDK_FACTORY` + [#2717](https://github.com/open-telemetry/opentelemetry-cpp/pull/2717) + +Breaking changes: + +* [REMOVAL] Remove build option `WITH_DEPRECATED_SDK_FACTORY` + [#2717](https://github.com/open-telemetry/opentelemetry-cpp/pull/2717) + + * As announced in opentelemetry-cpp previous release 1.16.0, + CMake option `WITH_DEPRECATED_SDK_FACTORY` was temporary, + and to be removed by the next release. + * This option is now removed. + * Code configuring the SDK must be adjusted, as previously described: + + * [API/SDK] Provider cleanup + [#2664](https://github.com/open-telemetry/opentelemetry-cpp/pull/2664) + + * Before this fix: + * SDK factory methods such as: + * opentelemetry::sdk::trace::TracerProviderFactory::Create() + * opentelemetry::sdk::metrics::MeterProviderFactory::Create() + * opentelemetry::sdk::logs::LoggerProviderFactory::Create() + * opentelemetry::sdk::logs::EventLoggerProviderFactory::Create() + + returned an API object (opentelemetry::trace::TracerProvider) + to the caller. + + * After this fix, these methods return an SDK level object + (opentelemetry::sdk::trace::TracerProvider) to the caller. + * Returning an SDK object is necessary for the application to + cleanup and invoke SDK level methods, such as ForceFlush(), + on a provider. + * The application code that configures the SDK, by calling + the various provider factories, may need adjustment. + * All the examples have been updated, and in particular no + longer perform static_cast do convert an API object to an SDK object. + Please refer to examples for guidance on how to adjust. + ## [1.16.1 2024-07-17] * [BUILD] Add bazel missing BUILD file diff --git a/CMakeLists.txt b/CMakeLists.txt index 44ddd05e1c..d10e831297 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -159,14 +159,6 @@ message(STATUS "OPENTELEMETRY_VERSION=${OPENTELEMETRY_VERSION}") option(WITH_NO_DEPRECATED_CODE "Do not include deprecated code" OFF) -# This option is temporary, and will be removed. Set -# WITH_DEPRECATED_SDK_FACTORY=OFF to migrate to the new SDK code. -option(WITH_DEPRECATED_SDK_FACTORY "Use deprecated SDK provider factory" ON) - -if(WITH_DEPRECATED_SDK_FACTORY) - message(WARNING "WITH_DEPRECATED_SDK_FACTORY=ON is temporary and deprecated") -endif() - set(WITH_STL "OFF" CACHE STRING "Which version of the Standard Library for C++ to use") @@ -204,13 +196,6 @@ if(NOT WITH_STL STREQUAL "OFF") endif() endif() -if(DEFINED WITH_OTLP) - message( - FATAL_ERROR - "WITH_OTLP is deprecated. Please set either WITH_OTLP_GRPC=ON, WITH_OTLP_HTTP=ON, or both to ON." - ) -endif() - option(WITH_OTLP_GRPC_SSL_MTLS_PREVIEW "Whether to enable mTLS support fro gRPC" OFF) @@ -294,10 +279,6 @@ option( option(WITH_FUNC_TESTS "Whether to build functional tests" ON) -if(DEFINED WITH_LOGS_PREVIEW) - message(WARNING "WITH_LOGS_PREVIEW is removed because logs signal is stable") -endif() - option(WITH_ASYNC_EXPORT_PREVIEW "Whether to enable async export" OFF) # Exemplar specs status is experimental, so behind feature flag by default diff --git a/DEPRECATED.md b/DEPRECATED.md index 7db5ba9d93..0632f50503 100644 --- a/DEPRECATED.md +++ b/DEPRECATED.md @@ -88,85 +88,7 @@ No date set yet for the Jaeger Propagator. ## [opentelemetry-cpp SDK] -### SDK ProviderFactory cleanup - -#### Announcement (SDK ProviderFactory cleanup) - -* Version: 1.15.0 -* Date: 2024-06-03 -* PR: [API/SDK] Provider cleanup - [#2664](https://github.com/open-telemetry/opentelemetry-cpp/pull/2664) - -This PR introduces changes to SDK ProviderFactory methods. - -#### Motivation (SDK ProviderFactory cleanup) - -SDK Factory methods for signal providers, such as: - -* opentelemetry::sdk::trace::TracerProviderFactory -* opentelemetry::sdk::metrics::MeterProviderFactory -* opentelemetry::sdk::logs::LoggerProviderFactory -* opentelemetry::sdk::logs::EventLoggerProviderFactory - -currently returns a unique pointer on a API class. - -This is incorrect, the proper return type should be -a unique pointer on a SDK class instead. - -#### Scope (SDK ProviderFactory cleanup) - -All the current Create methods in: - -* class opentelemetry::sdk::trace::TracerProviderFactory -* class opentelemetry::sdk::metrics::MeterProviderFactory -* class opentelemetry::sdk::logs::LoggerProviderFactory -* class opentelemetry::sdk::logs::EventLoggerProviderFactory - -are marked as deprecated, as they return an API object. - -Instead, another set of Create methods is provided, -with a different return type, an SDK object. - -Both sets can not be exposed at the same time, -as this would cause build breaks, -so a compilation flag is defined to select which methods to use. - -When OPENTELEMETRY_DEPRECATED_SDK_FACTORY is defined, -the old, deprecated, methods are available. - -When OPENTELEMETRY_DEPRECATED_SDK_FACTORY is not defined, -the new methods are available. - -The scope of this deprecation and removal, -is to remove the flag OPENTELEMETRY_DEPRECATED_SDK_FACTORY itself, -which implies that only the new set of Create() methods, -returning an SDK object, are supported. - -#### Mitigation (SDK ProviderFactory cleanup) - -Build without defining flag OPENTELEMETRY_DEPRECATED_SDK_FACTORY. - -Existing code, such as: - -```cpp - std::shared_ptr tracer_provider; - tracer_provider = opentelemetry::sdk::trace::TracerProviderFactory::Create(...); -``` - -should be adjusted to: - -```cpp - std::shared_ptr tracer_provider; - tracer_provider = opentelemetry::sdk::trace::TracerProviderFactory::Create(...); -``` - -#### Planned removal (SDK ProviderFactory cleanup) - -Flag OPENTELEMETRY_DEPRECATED_SDK_FACTORY is introduced in release 1.16.0, -to provide a migration path. - -This flag is meant to be temporary, and short lived. -Expect removal by release 1.17.0 +N/A ## [opentelemetry-cpp Exporter] diff --git a/api/CMakeLists.txt b/api/CMakeLists.txt index e07275efed..78e97ad029 100644 --- a/api/CMakeLists.txt +++ b/api/CMakeLists.txt @@ -35,11 +35,6 @@ if(WITH_NO_DEPRECATED_CODE) INTERFACE OPENTELEMETRY_NO_DEPRECATED_CODE) endif() -if(WITH_DEPRECATED_SDK_FACTORY) - target_compile_definitions(opentelemetry_api - INTERFACE OPENTELEMETRY_DEPRECATED_SDK_FACTORY) -endif() - if(WITH_ABSEIL) target_compile_definitions(opentelemetry_api INTERFACE HAVE_ABSEIL) target_link_libraries( diff --git a/ci/do_ci.ps1 b/ci/do_ci.ps1 index bcae6359bb..e9c1f64646 100644 --- a/ci/do_ci.ps1 +++ b/ci/do_ci.ps1 @@ -135,7 +135,6 @@ switch ($action) { cmake $SRC_DIR ` -DOTELCPP_MAINTAINER_MODE=ON ` -DWITH_NO_DEPRECATED_CODE=ON ` - -DWITH_DEPRECATED_SDK_FACTORY=OFF ` -DVCPKG_TARGET_TRIPLET=x64-windows ` "-DCMAKE_TOOLCHAIN_FILE=$VCPKG_DIR/scripts/buildsystems/vcpkg.cmake" $exit = $LASTEXITCODE @@ -160,7 +159,6 @@ switch ($action) { -DCMAKE_CXX_STANDARD=20 ` -DOTELCPP_MAINTAINER_MODE=ON ` -DWITH_NO_DEPRECATED_CODE=ON ` - -DWITH_DEPRECATED_SDK_FACTORY=OFF ` -DVCPKG_TARGET_TRIPLET=x64-windows ` "-DCMAKE_TOOLCHAIN_FILE=$VCPKG_DIR/scripts/buildsystems/vcpkg.cmake" $exit = $LASTEXITCODE diff --git a/ci/do_ci.sh b/ci/do_ci.sh index efdac9e87e..6d339c8d4e 100755 --- a/ci/do_ci.sh +++ b/ci/do_ci.sh @@ -130,7 +130,6 @@ elif [[ "$1" == "cmake.maintainer.sync.test" ]]; then -DWITH_ASYNC_EXPORT_PREVIEW=OFF \ -DOTELCPP_MAINTAINER_MODE=ON \ -DWITH_NO_DEPRECATED_CODE=ON \ - -DWITH_DEPRECATED_SDK_FACTORY=OFF \ -DWITH_OTLP_HTTP_COMPRESSION=ON \ ${IWYU} \ "${SRC_DIR}" @@ -153,7 +152,6 @@ elif [[ "$1" == "cmake.maintainer.async.test" ]]; then -DWITH_ASYNC_EXPORT_PREVIEW=ON \ -DOTELCPP_MAINTAINER_MODE=ON \ -DWITH_NO_DEPRECATED_CODE=ON \ - -DWITH_DEPRECATED_SDK_FACTORY=OFF \ -DWITH_OTLP_HTTP_COMPRESSION=ON \ ${IWYU} \ "${SRC_DIR}" @@ -177,7 +175,6 @@ elif [[ "$1" == "cmake.maintainer.cpp11.async.test" ]]; then -DWITH_ASYNC_EXPORT_PREVIEW=ON \ -DOTELCPP_MAINTAINER_MODE=ON \ -DWITH_NO_DEPRECATED_CODE=ON \ - -DWITH_DEPRECATED_SDK_FACTORY=OFF \ -DWITH_OTLP_HTTP_COMPRESSION=ON \ "${SRC_DIR}" make -k -j $(nproc) @@ -199,7 +196,6 @@ elif [[ "$1" == "cmake.maintainer.abiv2.test" ]]; then -DWITH_ASYNC_EXPORT_PREVIEW=OFF \ -DOTELCPP_MAINTAINER_MODE=ON \ -DWITH_NO_DEPRECATED_CODE=ON \ - -DWITH_DEPRECATED_SDK_FACTORY=OFF \ -DWITH_ABI_VERSION_1=OFF \ -DWITH_ABI_VERSION_2=ON \ -DWITH_OTLP_HTTP_COMPRESSION=ON \ diff --git a/examples/logs_simple/main.cc b/examples/logs_simple/main.cc index 444775dc59..3d7dfb8831 100644 --- a/examples/logs_simple/main.cc +++ b/examples/logs_simple/main.cc @@ -44,13 +44,8 @@ void InitTracer() auto exporter = trace_exporter::OStreamSpanExporterFactory::Create(); auto processor = trace_sdk::SimpleSpanProcessorFactory::Create(std::move(exporter)); -#ifdef OPENTELEMETRY_DEPRECATED_SDK_FACTORY - std::shared_ptr provider = - opentelemetry::sdk::trace::TracerProviderFactory::Create(std::move(processor)); -#else std::shared_ptr provider = opentelemetry::sdk::trace::TracerProviderFactory::Create(std::move(processor)); -#endif /* OPENTELEMETRY_DEPRECATED_SDK_FACTORY */ // Set the global trace provider const std::shared_ptr &api_provider = provider; @@ -70,13 +65,8 @@ void InitLogger() std::unique_ptr(new logs_exporter::OStreamLogRecordExporter); auto processor = logs_sdk::SimpleLogRecordProcessorFactory::Create(std::move(exporter)); -#ifdef OPENTELEMETRY_DEPRECATED_SDK_FACTORY - std::shared_ptr provider( - opentelemetry::sdk::logs::LoggerProviderFactory::Create(std::move(processor))); -#else std::shared_ptr provider( opentelemetry::sdk::logs::LoggerProviderFactory::Create(std::move(processor))); -#endif /* OPENTELEMETRY_DEPRECATED_SDK_FACTORY */ // Set the global logger provider const std::shared_ptr &api_provider = provider; diff --git a/examples/metrics_simple/metrics_ostream.cc b/examples/metrics_simple/metrics_ostream.cc index 5871b5e6a3..5bdc7339eb 100644 --- a/examples/metrics_simple/metrics_ostream.cc +++ b/examples/metrics_simple/metrics_ostream.cc @@ -57,12 +57,7 @@ void InitMetrics(const std::string &name) auto reader = metrics_sdk::PeriodicExportingMetricReaderFactory::Create(std::move(exporter), options); -#ifdef OPENTELEMETRY_DEPRECATED_SDK_FACTORY - auto u_provider = opentelemetry::sdk::metrics::MeterProviderFactory::Create(); - auto *provider = static_cast(u_provider.get()); -#else auto provider = opentelemetry::sdk::metrics::MeterProviderFactory::Create(); -#endif /* OPENTELEMETRY_DEPRECATED_SDK_FACTORY */ provider->AddMetricReader(std::move(reader)); @@ -118,11 +113,7 @@ void InitMetrics(const std::string &name) provider->AddView(std::move(histogram_instrument_selector), std::move(histogram_meter_selector), std::move(histogram_view)); -#ifdef OPENTELEMETRY_DEPRECATED_SDK_FACTORY - std::shared_ptr api_provider(std::move(u_provider)); -#else std::shared_ptr api_provider(std::move(provider)); -#endif /* OPENTELEMETRY_DEPRECATED_SDK_FACTORY */ metrics_api::Provider::SetMeterProvider(api_provider); } diff --git a/examples/otlp/file_log_main.cc b/examples/otlp/file_log_main.cc index 30eb71cc2b..3cd59f7240 100644 --- a/examples/otlp/file_log_main.cc +++ b/examples/otlp/file_log_main.cc @@ -46,13 +46,8 @@ namespace opentelemetry::exporter::otlp::OtlpFileExporterOptions opts; opentelemetry::exporter::otlp::OtlpFileLogRecordExporterOptions log_opts; -#ifdef OPENTELEMETRY_DEPRECATED_SDK_FACTORY -std::shared_ptr tracer_provider; -std::shared_ptr logger_provider; -#else std::shared_ptr tracer_provider; std::shared_ptr logger_provider; -#endif /* OPENTELEMETRY_DEPRECATED_SDK_FACTORY */ void InitTracer() { @@ -71,11 +66,7 @@ void CleanupTracer() // We call ForceFlush to prevent to cancel running exportings, It's optional. if (tracer_provider) { -#ifdef OPENTELEMETRY_DEPRECATED_SDK_FACTORY - static_cast(tracer_provider.get())->ForceFlush(); -#else tracer_provider->ForceFlush(); -#endif /* OPENTELEMETRY_DEPRECATED_SDK_FACTORY */ } tracer_provider.reset(); @@ -99,11 +90,7 @@ void CleanupLogger() // We call ForceFlush to prevent to cancel running exportings, It's optional. if (logger_provider) { -#ifdef OPENTELEMETRY_DEPRECATED_SDK_FACTORY - static_cast(logger_provider.get())->ForceFlush(); -#else logger_provider->ForceFlush(); -#endif /* OPENTELEMETRY_DEPRECATED_SDK_FACTORY */ } logger_provider.reset(); diff --git a/examples/otlp/file_main.cc b/examples/otlp/file_main.cc index 243ad44428..377662aee4 100644 --- a/examples/otlp/file_main.cc +++ b/examples/otlp/file_main.cc @@ -31,11 +31,7 @@ namespace { opentelemetry::exporter::otlp::OtlpFileExporterOptions opts; -#ifdef OPENTELEMETRY_DEPRECATED_SDK_FACTORY -std::shared_ptr provider; -#else std::shared_ptr provider; -#endif /* OPENTELEMETRY_DEPRECATED_SDK_FACTORY */ void InitTracer() { @@ -54,11 +50,7 @@ void CleanupTracer() // We call ForceFlush to prevent to cancel running exportings, It's optional. if (provider) { -#ifdef OPENTELEMETRY_DEPRECATED_SDK_FACTORY - static_cast(provider.get())->ForceFlush(); -#else provider->ForceFlush(); -#endif /* OPENTELEMETRY_DEPRECATED_SDK_FACTORY */ } provider.reset(); diff --git a/examples/otlp/grpc_log_main.cc b/examples/otlp/grpc_log_main.cc index 24037f6190..c7aca2ea31 100644 --- a/examples/otlp/grpc_log_main.cc +++ b/examples/otlp/grpc_log_main.cc @@ -38,13 +38,8 @@ namespace opentelemetry::exporter::otlp::OtlpGrpcExporterOptions opts; opentelemetry::exporter::otlp::OtlpGrpcLogRecordExporterOptions log_opts; -#ifdef OPENTELEMETRY_DEPRECATED_SDK_FACTORY -std::shared_ptr tracer_provider; -std::shared_ptr logger_provider; -#else std::shared_ptr tracer_provider; std::shared_ptr logger_provider; -#endif /* OPENTELEMETRY_DEPRECATED_SDK_FACTORY */ void InitTracer() { @@ -63,11 +58,7 @@ void CleanupTracer() // We call ForceFlush to prevent to cancel running exportings, It's optional. if (tracer_provider) { -#ifdef OPENTELEMETRY_DEPRECATED_SDK_FACTORY - static_cast(tracer_provider.get())->ForceFlush(); -#else tracer_provider->ForceFlush(); -#endif /* OPENTELEMETRY_DEPRECATED_SDK_FACTORY */ } tracer_provider.reset(); @@ -92,11 +83,7 @@ void CleanupLogger() // We call ForceFlush to prevent to cancel running exportings, It's optional. if (logger_provider) { -#ifdef OPENTELEMETRY_DEPRECATED_SDK_FACTORY - static_cast(logger_provider.get())->ForceFlush(); -#else logger_provider->ForceFlush(); -#endif /* OPENTELEMETRY_DEPRECATED_SDK_FACTORY */ } logger_provider.reset(); diff --git a/examples/otlp/grpc_main.cc b/examples/otlp/grpc_main.cc index 15499985af..9b29e16edd 100644 --- a/examples/otlp/grpc_main.cc +++ b/examples/otlp/grpc_main.cc @@ -24,11 +24,7 @@ namespace { opentelemetry::exporter::otlp::OtlpGrpcExporterOptions opts; -#ifdef OPENTELEMETRY_DEPRECATED_SDK_FACTORY -std::shared_ptr provider; -#else std::shared_ptr provider; -#endif /* OPENTELEMETRY_DEPRECATED_SDK_FACTORY */ void InitTracer() { @@ -47,11 +43,7 @@ void CleanupTracer() // We call ForceFlush to prevent to cancel running exportings, It's optional. if (provider) { -#ifdef OPENTELEMETRY_DEPRECATED_SDK_FACTORY - static_cast(provider.get())->ForceFlush(); -#else provider->ForceFlush(); -#endif /* OPENTELEMETRY_DEPRECATED_SDK_FACTORY */ } provider.reset(); diff --git a/examples/otlp/http_log_main.cc b/examples/otlp/http_log_main.cc index 37bace2b0f..4f42b61ce9 100644 --- a/examples/otlp/http_log_main.cc +++ b/examples/otlp/http_log_main.cc @@ -48,11 +48,7 @@ namespace opentelemetry::exporter::otlp::OtlpHttpExporterOptions trace_opts; -#ifdef OPENTELEMETRY_DEPRECATED_SDK_FACTORY -std::shared_ptr tracer_provider; -#else std::shared_ptr tracer_provider; -#endif /* OPENTELEMETRY_DEPRECATED_SDK_FACTORY */ void InitTracer() { @@ -88,11 +84,7 @@ void CleanupTracer() // We call ForceFlush to prevent to cancel running exportings, It's optional. if (tracer_provider) { -#ifdef OPENTELEMETRY_DEPRECATED_SDK_FACTORY - static_cast(tracer_provider.get())->ForceFlush(); -#else tracer_provider->ForceFlush(); -#endif /* OPENTELEMETRY_DEPRECATED_SDK_FACTORY */ } tracer_provider.reset(); @@ -102,11 +94,7 @@ void CleanupTracer() opentelemetry::exporter::otlp::OtlpHttpLogRecordExporterOptions logger_opts; -#ifdef OPENTELEMETRY_DEPRECATED_SDK_FACTORY -std::shared_ptr logger_provider; -#else std::shared_ptr logger_provider; -#endif /* OPENTELEMETRY_DEPRECATED_SDK_FACTORY */ void InitLogger() { @@ -126,11 +114,7 @@ void CleanupLogger() // We call ForceFlush to prevent to cancel running exportings, It's optional. if (logger_provider) { -#ifdef OPENTELEMETRY_DEPRECATED_SDK_FACTORY - static_cast(logger_provider.get())->ForceFlush(); -#else logger_provider->ForceFlush(); -#endif /* OPENTELEMETRY_DEPRECATED_SDK_FACTORY */ } logger_provider.reset(); diff --git a/examples/otlp/http_main.cc b/examples/otlp/http_main.cc index 6217bdcb34..ce88e46fca 100644 --- a/examples/otlp/http_main.cc +++ b/examples/otlp/http_main.cc @@ -35,11 +35,7 @@ namespace { opentelemetry::exporter::otlp::OtlpHttpExporterOptions opts; -#ifdef OPENTELEMETRY_DEPRECATED_SDK_FACTORY -std::shared_ptr provider; -#else std::shared_ptr provider; -#endif /* OPENTELEMETRY_DEPRECATED_SDK_FACTORY */ void InitTracer() { @@ -57,11 +53,7 @@ void CleanupTracer() // We call ForceFlush to prevent to cancel running exportings, It's optional. if (provider) { -#ifdef OPENTELEMETRY_DEPRECATED_SDK_FACTORY - static_cast(provider.get())->ForceFlush(); -#else provider->ForceFlush(); -#endif /* OPENTELEMETRY_DEPRECATED_SDK_FACTORY */ } provider.reset(); diff --git a/examples/simple/main.cc b/examples/simple/main.cc index 349aec500a..245786688c 100644 --- a/examples/simple/main.cc +++ b/examples/simple/main.cc @@ -31,13 +31,8 @@ void InitTracer() auto exporter = trace_exporter::OStreamSpanExporterFactory::Create(); auto processor = trace_sdk::SimpleSpanProcessorFactory::Create(std::move(exporter)); -#ifdef OPENTELEMETRY_DEPRECATED_SDK_FACTORY - std::shared_ptr provider = - opentelemetry::sdk::trace::TracerProviderFactory::Create(std::move(processor)); -#else std::shared_ptr provider = opentelemetry::sdk::trace::TracerProviderFactory::Create(std::move(processor)); -#endif /* OPENTELEMETRY_DEPRECATED_SDK_FACTORY */ // Set the global trace provider const std::shared_ptr &api_provider = provider; diff --git a/exporters/otlp/test/otlp_grpc_log_record_exporter_test.cc b/exporters/otlp/test/otlp_grpc_log_record_exporter_test.cc index 4c7a9fd7f1..90827f576f 100644 --- a/exporters/otlp/test/otlp_grpc_log_record_exporter_test.cc +++ b/exporters/otlp/test/otlp_grpc_log_record_exporter_test.cc @@ -288,17 +288,10 @@ TEST_F(OtlpGrpcLogRecordExporterTestPeer, ExportIntegrationTest) std::unique_ptr trace_stub_interface( trace_mock_stub); -#ifdef OPENTELEMETRY_DEPRECATED_SDK_FACTORY - auto trace_provider = opentelemetry::nostd::shared_ptr( - opentelemetry::sdk::trace::TracerProviderFactory::Create( - opentelemetry::sdk::trace::SimpleSpanProcessorFactory::Create( - GetExporter(trace_stub_interface)))); -#else auto trace_provider = opentelemetry::nostd::shared_ptr( opentelemetry::sdk::trace::TracerProviderFactory::Create( opentelemetry::sdk::trace::SimpleSpanProcessorFactory::Create( GetExporter(trace_stub_interface)))); -#endif /* OPENTELEMETRY_DEPRECATED_SDK_FACTORY */ // Trace and Logs should both receive datas when links static gRPC on ELF ABI. EXPECT_CALL(*trace_mock_stub, Export(_, _, _)) diff --git a/sdk/include/opentelemetry/sdk/logs/event_logger_provider_factory.h b/sdk/include/opentelemetry/sdk/logs/event_logger_provider_factory.h index 621cbea6c8..5559605171 100644 --- a/sdk/include/opentelemetry/sdk/logs/event_logger_provider_factory.h +++ b/sdk/include/opentelemetry/sdk/logs/event_logger_provider_factory.h @@ -24,16 +24,7 @@ class EventLoggerProviderFactory * Create a EventLoggerProvider. */ -#ifdef OPENTELEMETRY_DEPRECATED_SDK_FACTORY - -# ifndef OPENTELEMETRY_NO_DEPRECATED_CODE - OPENTELEMETRY_DEPRECATED - static std::unique_ptr Create(); -# endif /* OPENTELEMETRY_NO_DEPRECATED_CODE */ - -#else static std::unique_ptr Create(); -#endif /* OPENTELEMETRY_DEPRECATED_SDK_FACTORY */ }; } // namespace logs diff --git a/sdk/include/opentelemetry/sdk/logs/logger_provider_factory.h b/sdk/include/opentelemetry/sdk/logs/logger_provider_factory.h index 7b8f636e68..490393209c 100644 --- a/sdk/include/opentelemetry/sdk/logs/logger_provider_factory.h +++ b/sdk/include/opentelemetry/sdk/logs/logger_provider_factory.h @@ -24,36 +24,6 @@ namespace logs class OPENTELEMETRY_EXPORT LoggerProviderFactory { public: -#ifdef OPENTELEMETRY_DEPRECATED_SDK_FACTORY - -# ifndef OPENTELEMETRY_NO_DEPRECATED_CODE - - OPENTELEMETRY_DEPRECATED - static std::unique_ptr Create( - std::unique_ptr &&processor); - - OPENTELEMETRY_DEPRECATED - static std::unique_ptr Create( - std::unique_ptr &&processor, - const opentelemetry::sdk::resource::Resource &resource); - - OPENTELEMETRY_DEPRECATED - static std::unique_ptr Create( - std::vector> &&processors); - - OPENTELEMETRY_DEPRECATED - static std::unique_ptr Create( - std::vector> &&processors, - const opentelemetry::sdk::resource::Resource &resource); - - OPENTELEMETRY_DEPRECATED - static std::unique_ptr Create( - std::unique_ptr context); - -# endif /* OPENTELEMETRY_NO_DEPRECATED_CODE */ - -#else - /** * Create a LoggerProvider. */ @@ -85,8 +55,6 @@ class OPENTELEMETRY_EXPORT LoggerProviderFactory */ static std::unique_ptr Create( std::unique_ptr context); - -#endif /* OPENTELEMETRY_DEPRECATED_SDK_FACTORY */ }; } // namespace logs diff --git a/sdk/include/opentelemetry/sdk/metrics/meter_provider_factory.h b/sdk/include/opentelemetry/sdk/metrics/meter_provider_factory.h index cb9106ddc8..499c87ae6a 100644 --- a/sdk/include/opentelemetry/sdk/metrics/meter_provider_factory.h +++ b/sdk/include/opentelemetry/sdk/metrics/meter_provider_factory.h @@ -21,30 +21,6 @@ namespace metrics class OPENTELEMETRY_EXPORT MeterProviderFactory { public: -#ifdef OPENTELEMETRY_DEPRECATED_SDK_FACTORY - -# ifndef OPENTELEMETRY_NO_DEPRECATED_CODE - - OPENTELEMETRY_DEPRECATED - static std::unique_ptr Create(); - - OPENTELEMETRY_DEPRECATED - static std::unique_ptr Create( - std::unique_ptr views); - - OPENTELEMETRY_DEPRECATED - static std::unique_ptr Create( - std::unique_ptr views, - const opentelemetry::sdk::resource::Resource &resource); - - OPENTELEMETRY_DEPRECATED - static std::unique_ptr Create( - std::unique_ptr context); - -# endif /* OPENTELEMETRY_NO_DEPRECATED_CODE */ - -#else - static std::unique_ptr Create(); static std::unique_ptr Create( @@ -56,8 +32,6 @@ class OPENTELEMETRY_EXPORT MeterProviderFactory static std::unique_ptr Create( std::unique_ptr context); - -#endif /* OPENTELEMETRY_DEPRECATED_SDK_FACTORY */ }; } // namespace metrics diff --git a/sdk/include/opentelemetry/sdk/trace/tracer_provider_factory.h b/sdk/include/opentelemetry/sdk/trace/tracer_provider_factory.h index 7c4b6903de..ed451a8c99 100644 --- a/sdk/include/opentelemetry/sdk/trace/tracer_provider_factory.h +++ b/sdk/include/opentelemetry/sdk/trace/tracer_provider_factory.h @@ -28,68 +28,6 @@ namespace trace class OPENTELEMETRY_EXPORT TracerProviderFactory { public: -#ifdef OPENTELEMETRY_DEPRECATED_SDK_FACTORY - -# ifndef OPENTELEMETRY_NO_DEPRECATED_CODE - - /* Serie of builders with a single processor. */ - - OPENTELEMETRY_DEPRECATED - static std::unique_ptr Create( - std::unique_ptr processor); - - OPENTELEMETRY_DEPRECATED - static std::unique_ptr Create( - std::unique_ptr processor, - const opentelemetry::sdk::resource::Resource &resource); - - OPENTELEMETRY_DEPRECATED - static std::unique_ptr Create( - std::unique_ptr processor, - const opentelemetry::sdk::resource::Resource &resource, - std::unique_ptr sampler); - - OPENTELEMETRY_DEPRECATED - static std::unique_ptr Create( - std::unique_ptr processor, - const opentelemetry::sdk::resource::Resource &resource, - std::unique_ptr sampler, - std::unique_ptr id_generator); - - /* Serie of builders with a vector of processor. */ - - OPENTELEMETRY_DEPRECATED - static std::unique_ptr Create( - std::vector> &&processors); - - OPENTELEMETRY_DEPRECATED - static std::unique_ptr Create( - std::vector> &&processors, - const opentelemetry::sdk::resource::Resource &resource); - - OPENTELEMETRY_DEPRECATED - static std::unique_ptr Create( - std::vector> &&processors, - const opentelemetry::sdk::resource::Resource &resource, - std::unique_ptr sampler); - - OPENTELEMETRY_DEPRECATED - static std::unique_ptr Create( - std::vector> &&processors, - const opentelemetry::sdk::resource::Resource &resource, - std::unique_ptr sampler, - std::unique_ptr id_generator); - - /* Create with a tracer context. */ - - OPENTELEMETRY_DEPRECATED - static std::unique_ptr Create( - std::unique_ptr context); - -# endif /* OPENTELEMETRY_NO_DEPRECATED_CODE */ - -#else - /* Serie of builders with a single processor. */ static std::unique_ptr Create( @@ -134,8 +72,6 @@ class OPENTELEMETRY_EXPORT TracerProviderFactory static std::unique_ptr Create( std::unique_ptr context); - -#endif /* OPENTELEMETRY_DEPRECATED_SDK_FACTORY */ }; } // namespace trace diff --git a/sdk/src/logs/event_logger_provider_factory.cc b/sdk/src/logs/event_logger_provider_factory.cc index 7f5c8cadf1..daff8a8590 100644 --- a/sdk/src/logs/event_logger_provider_factory.cc +++ b/sdk/src/logs/event_logger_provider_factory.cc @@ -11,22 +11,11 @@ namespace sdk namespace logs { -#ifdef OPENTELEMETRY_DEPRECATED_SDK_FACTORY - -std::unique_ptr EventLoggerProviderFactory::Create() -{ - return std::unique_ptr(new EventLoggerProvider()); -} - -#else - std::unique_ptr EventLoggerProviderFactory::Create() { return std::unique_ptr(new EventLoggerProvider()); } -#endif /* OPENTELEMETRY_DEPRECATED_SDK_FACTORY */ - } // namespace logs } // namespace sdk OPENTELEMETRY_END_NAMESPACE diff --git a/sdk/src/logs/logger_provider_factory.cc b/sdk/src/logs/logger_provider_factory.cc index 08567c65d9..530d1c2db4 100644 --- a/sdk/src/logs/logger_provider_factory.cc +++ b/sdk/src/logs/logger_provider_factory.cc @@ -18,50 +18,6 @@ namespace sdk namespace logs { -#ifdef OPENTELEMETRY_DEPRECATED_SDK_FACTORY - -std::unique_ptr LoggerProviderFactory::Create( - std::unique_ptr &&processor) -{ - auto resource = opentelemetry::sdk::resource::Resource::Create({}); - return Create(std::move(processor), resource); -} - -std::unique_ptr LoggerProviderFactory::Create( - std::unique_ptr &&processor, - const opentelemetry::sdk::resource::Resource &resource) -{ - std::unique_ptr provider( - new LoggerProvider(std::move(processor), resource)); - return provider; -} - -std::unique_ptr LoggerProviderFactory::Create( - std::vector> &&processors) -{ - auto resource = opentelemetry::sdk::resource::Resource::Create({}); - return Create(std::move(processors), resource); -} - -std::unique_ptr LoggerProviderFactory::Create( - std::vector> &&processors, - const opentelemetry::sdk::resource::Resource &resource) -{ - std::unique_ptr provider( - new LoggerProvider(std::move(processors), resource)); - return provider; -} - -std::unique_ptr LoggerProviderFactory::Create( - std::unique_ptr context) -{ - std::unique_ptr provider( - new LoggerProvider(std::move(context))); - return provider; -} - -#else - std::unique_ptr LoggerProviderFactory::Create( std::unique_ptr &&processor) { @@ -102,8 +58,6 @@ std::unique_ptr LoggerProviderFactory: return provider; } -#endif /* OPENTELEMETRY_DEPRECATED_SDK_FACTORY */ - } // namespace logs } // namespace sdk OPENTELEMETRY_END_NAMESPACE diff --git a/sdk/src/metrics/meter_provider_factory.cc b/sdk/src/metrics/meter_provider_factory.cc index 7749a13124..c5e368aca6 100644 --- a/sdk/src/metrics/meter_provider_factory.cc +++ b/sdk/src/metrics/meter_provider_factory.cc @@ -18,40 +18,6 @@ namespace sdk namespace metrics { -#ifdef OPENTELEMETRY_DEPRECATED_SDK_FACTORY - -std::unique_ptr MeterProviderFactory::Create() -{ - auto views = ViewRegistryFactory::Create(); - return Create(std::move(views)); -} - -std::unique_ptr MeterProviderFactory::Create( - std::unique_ptr views) -{ - auto resource = opentelemetry::sdk::resource::Resource::Create({}); - return Create(std::move(views), resource); -} - -std::unique_ptr MeterProviderFactory::Create( - std::unique_ptr views, - const opentelemetry::sdk::resource::Resource &resource) -{ - std::unique_ptr provider( - new opentelemetry::sdk::metrics::MeterProvider(std::move(views), resource)); - return provider; -} - -std::unique_ptr MeterProviderFactory::Create( - std::unique_ptr context) -{ - std::unique_ptr provider( - new opentelemetry::sdk::metrics::MeterProvider(std::move(context))); - return provider; -} - -#else - std::unique_ptr MeterProviderFactory::Create() { auto views = ViewRegistryFactory::Create(); @@ -82,8 +48,6 @@ std::unique_ptr MeterProviderFactory return provider; } -#endif /* OPENTELEMETRY_DEPRECATED_SDK_FACTORY */ - } // namespace metrics } // namespace sdk OPENTELEMETRY_END_NAMESPACE diff --git a/sdk/src/trace/tracer_provider_factory.cc b/sdk/src/trace/tracer_provider_factory.cc index eeb18a1e59..eaeb669b91 100644 --- a/sdk/src/trace/tracer_provider_factory.cc +++ b/sdk/src/trace/tracer_provider_factory.cc @@ -22,90 +22,6 @@ namespace sdk namespace trace { -#ifdef OPENTELEMETRY_DEPRECATED_SDK_FACTORY - -std::unique_ptr TracerProviderFactory::Create( - std::unique_ptr processor) -{ - auto resource = opentelemetry::sdk::resource::Resource::Create({}); - return Create(std::move(processor), resource); -} - -std::unique_ptr TracerProviderFactory::Create( - std::unique_ptr processor, - const opentelemetry::sdk::resource::Resource &resource) -{ - auto sampler = AlwaysOnSamplerFactory::Create(); - return Create(std::move(processor), resource, std::move(sampler)); -} - -std::unique_ptr TracerProviderFactory::Create( - std::unique_ptr processor, - const opentelemetry::sdk::resource::Resource &resource, - std::unique_ptr sampler) -{ - auto id_generator = RandomIdGeneratorFactory::Create(); - return Create(std::move(processor), resource, std::move(sampler), std::move(id_generator)); -} - -std::unique_ptr TracerProviderFactory::Create( - std::unique_ptr processor, - const opentelemetry::sdk::resource::Resource &resource, - std::unique_ptr sampler, - std::unique_ptr id_generator) -{ - std::unique_ptr provider( - new opentelemetry::sdk::trace::TracerProvider(std::move(processor), resource, - std::move(sampler), std::move(id_generator))); - return provider; -} - -std::unique_ptr TracerProviderFactory::Create( - std::vector> &&processors) -{ - auto resource = opentelemetry::sdk::resource::Resource::Create({}); - return Create(std::move(processors), resource); -} - -std::unique_ptr TracerProviderFactory::Create( - std::vector> &&processors, - const opentelemetry::sdk::resource::Resource &resource) -{ - auto sampler = AlwaysOnSamplerFactory::Create(); - return Create(std::move(processors), resource, std::move(sampler)); -} - -std::unique_ptr TracerProviderFactory::Create( - std::vector> &&processors, - const opentelemetry::sdk::resource::Resource &resource, - std::unique_ptr sampler) -{ - auto id_generator = RandomIdGeneratorFactory::Create(); - return Create(std::move(processors), resource, std::move(sampler), std::move(id_generator)); -} - -std::unique_ptr TracerProviderFactory::Create( - std::vector> &&processors, - const opentelemetry::sdk::resource::Resource &resource, - std::unique_ptr sampler, - std::unique_ptr id_generator) -{ - std::unique_ptr provider( - new opentelemetry::sdk::trace::TracerProvider(std::move(processors), resource, - std::move(sampler), std::move(id_generator))); - return provider; -} - -std::unique_ptr TracerProviderFactory::Create( - std::unique_ptr context) -{ - std::unique_ptr provider( - new opentelemetry::sdk::trace::TracerProvider(std::move(context))); - return provider; -} - -#else - std::unique_ptr TracerProviderFactory::Create( std::unique_ptr processor) { @@ -186,8 +102,6 @@ std::unique_ptr TracerProviderFactory return provider; } -#endif /* OPENTELEMETRY_DEPRECATED_SDK_FACTORY */ - } // namespace trace } // namespace sdk OPENTELEMETRY_END_NAMESPACE