diff --git a/CMakeLists.txt b/CMakeLists.txt index 5f0009d1d1..2f2f7ef7cc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -116,6 +116,12 @@ if(WITH_METRICS_PREVIEW) add_definitions(-DENABLE_METRICS_PREVIEW) endif() +option(WITH_LOGS_PREVIEW "Whether to build logs preview" OFF) + +if(WITH_LOGS_PREVIEW) + add_definitions(-DENABLE_LOGS_PREVIEW) +endif() + find_package(Threads) function(install_windows_deps) diff --git a/api/CMakeLists.txt b/api/CMakeLists.txt index 13c4d0fe7c..20d786e0cb 100644 --- a/api/CMakeLists.txt +++ b/api/CMakeLists.txt @@ -13,6 +13,11 @@ install( LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) +set(LOGS_EXCLUDE_PATTERN "") +if(NOT WITH_LOGS_PREVIEW) + set(LOGS_EXCLUDE_PATTERN "logs") +endif() + set(METRICS_EXCLUDE_PATTERN "") if(NOT WITH_METRICS_PREVIEW) set(METRICS_EXCLUDE_PATTERN "metrics") @@ -25,6 +30,13 @@ install( PATTERN "*.h" PATTERN "${METRICS_EXCLUDE_PATTERN}" EXCLUDE) +install( + DIRECTORY include/opentelemetry + DESTINATION include + FILES_MATCHING + PATTERN "*.h" + PATTERN "${LOGS_EXCLUDE_PATTERN}" EXCLUDE) + if(BUILD_TESTING) add_subdirectory(test) endif() diff --git a/api/include/opentelemetry/logs/logger.h b/api/include/opentelemetry/logs/logger.h index 6cc21a5abc..38b79e8bdf 100644 --- a/api/include/opentelemetry/logs/logger.h +++ b/api/include/opentelemetry/logs/logger.h @@ -2,24 +2,25 @@ // SPDX-License-Identifier: Apache-2.0 #pragma once - -#include -#include -#include - -#include "opentelemetry/common/attribute_value.h" -#include "opentelemetry/common/key_value_iterable.h" -#include "opentelemetry/common/key_value_iterable_view.h" -#include "opentelemetry/common/timestamp.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/nostd/type_traits.h" -#include "opentelemetry/trace/span_id.h" -#include "opentelemetry/trace/trace_flags.h" -#include "opentelemetry/trace/trace_id.h" -#include "opentelemetry/version.h" +#ifdef ENABLE_LOGS_PREVIEW + +# include +# include +# include + +# include "opentelemetry/common/attribute_value.h" +# include "opentelemetry/common/key_value_iterable.h" +# include "opentelemetry/common/key_value_iterable_view.h" +# include "opentelemetry/common/timestamp.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/nostd/type_traits.h" +# include "opentelemetry/trace/span_id.h" +# include "opentelemetry/trace/trace_flags.h" +# include "opentelemetry/trace/trace_id.h" +# include "opentelemetry/version.h" OPENTELEMETRY_BEGIN_NAMESPACE namespace logs @@ -568,3 +569,4 @@ class Logger }; } // namespace logs OPENTELEMETRY_END_NAMESPACE +#endif diff --git a/api/include/opentelemetry/logs/logger_provider.h b/api/include/opentelemetry/logs/logger_provider.h index 94ef7c6f55..93ba683f94 100644 --- a/api/include/opentelemetry/logs/logger_provider.h +++ b/api/include/opentelemetry/logs/logger_provider.h @@ -2,10 +2,11 @@ // SPDX-License-Identifier: Apache-2.0 #pragma once +#ifdef ENABLE_LOGS_PREVIEW -#include "opentelemetry/logs/logger.h" -#include "opentelemetry/nostd/shared_ptr.h" -#include "opentelemetry/nostd/string_view.h" +# include "opentelemetry/logs/logger.h" +# include "opentelemetry/nostd/shared_ptr.h" +# include "opentelemetry/nostd/string_view.h" OPENTELEMETRY_BEGIN_NAMESPACE namespace logs @@ -37,3 +38,4 @@ class LoggerProvider }; } // namespace logs OPENTELEMETRY_END_NAMESPACE +#endif diff --git a/api/include/opentelemetry/logs/noop.h b/api/include/opentelemetry/logs/noop.h index ecfdfa3ad1..a61507093c 100644 --- a/api/include/opentelemetry/logs/noop.h +++ b/api/include/opentelemetry/logs/noop.h @@ -2,30 +2,32 @@ // SPDX-License-Identifier: Apache-2.0 #pragma once +#ifdef ENABLE_LOGS_PREVIEW + // Please refer to provider.h for documentation on how to obtain a Logger object. // // This file is part of the internal implementation of OpenTelemetry. Nothing in this file should be // used directly. Please refer to logger.h for documentation on these interfaces. -#include +# include -#include "opentelemetry/common/attribute_value.h" -#include "opentelemetry/common/key_value_iterable.h" -#include "opentelemetry/common/timestamp.h" -#include "opentelemetry/context/runtime_context.h" -#include "opentelemetry/logs/logger.h" -#include "opentelemetry/logs/logger_provider.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/nostd/unique_ptr.h" -#include "opentelemetry/trace/span_id.h" -#include "opentelemetry/trace/trace_flags.h" -#include "opentelemetry/trace/trace_id.h" -#include "opentelemetry/version.h" +# include "opentelemetry/common/attribute_value.h" +# include "opentelemetry/common/key_value_iterable.h" +# include "opentelemetry/common/timestamp.h" +# include "opentelemetry/context/runtime_context.h" +# include "opentelemetry/logs/logger.h" +# include "opentelemetry/logs/logger_provider.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/nostd/unique_ptr.h" +# include "opentelemetry/trace/span_id.h" +# include "opentelemetry/trace/trace_flags.h" +# include "opentelemetry/trace/trace_id.h" +# include "opentelemetry/version.h" -#include "opentelemetry/version.h" +# include "opentelemetry/version.h" OPENTELEMETRY_BEGIN_NAMESPACE namespace logs @@ -79,3 +81,4 @@ class NoopLoggerProvider final : public opentelemetry::logs::LoggerProvider }; } // namespace logs OPENTELEMETRY_END_NAMESPACE +#endif diff --git a/api/include/opentelemetry/logs/provider.h b/api/include/opentelemetry/logs/provider.h index 57a4ee8bba..38186bbe75 100644 --- a/api/include/opentelemetry/logs/provider.h +++ b/api/include/opentelemetry/logs/provider.h @@ -2,13 +2,14 @@ // SPDX-License-Identifier: Apache-2.0 #pragma once +#ifdef ENABLE_LOGS_PREVIEW -#include +# include -#include "opentelemetry/common/spin_lock_mutex.h" -#include "opentelemetry/logs/logger_provider.h" -#include "opentelemetry/logs/noop.h" -#include "opentelemetry/nostd/shared_ptr.h" +# include "opentelemetry/common/spin_lock_mutex.h" +# include "opentelemetry/logs/logger_provider.h" +# include "opentelemetry/logs/noop.h" +# include "opentelemetry/nostd/shared_ptr.h" OPENTELEMETRY_BEGIN_NAMESPACE namespace logs @@ -56,3 +57,4 @@ class Provider } // namespace logs OPENTELEMETRY_END_NAMESPACE +#endif diff --git a/api/include/opentelemetry/logs/severity.h b/api/include/opentelemetry/logs/severity.h index 252acb3504..9fcf457b26 100644 --- a/api/include/opentelemetry/logs/severity.h +++ b/api/include/opentelemetry/logs/severity.h @@ -2,7 +2,9 @@ // SPDX-License-Identifier: Apache-2.0 #pragma once -#include "opentelemetry/version.h" +#ifdef ENABLE_LOGS_PREVIEW + +# include "opentelemetry/version.h" OPENTELEMETRY_BEGIN_NAMESPACE namespace logs @@ -56,3 +58,4 @@ const opentelemetry::nostd::string_view SeverityNumToText[25] = { } // namespace logs OPENTELEMETRY_END_NAMESPACE +#endif diff --git a/api/test/CMakeLists.txt b/api/test/CMakeLists.txt index 63f9369a1a..0e4c9bd0f3 100644 --- a/api/test/CMakeLists.txt +++ b/api/test/CMakeLists.txt @@ -6,6 +6,8 @@ add_subdirectory(trace) if(WITH_METRICS_PREVIEW) add_subdirectory(metrics) endif() -add_subdirectory(logs) +if(WITH_LOGS_PREVIEW) + add_subdirectory(logs) +endif() add_subdirectory(common) add_subdirectory(baggage) diff --git a/api/test/logs/logger_test.cc b/api/test/logs/logger_test.cc index 1919edb6fe..107dbe5ec0 100644 --- a/api/test/logs/logger_test.cc +++ b/api/test/logs/logger_test.cc @@ -1,13 +1,15 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -#include -#include +#ifdef ENABLE_LOGS_PREVIEW -#include "opentelemetry/common/timestamp.h" -#include "opentelemetry/logs/logger.h" -#include "opentelemetry/logs/provider.h" -#include "opentelemetry/nostd/shared_ptr.h" +# include +# include + +# include "opentelemetry/common/timestamp.h" +# include "opentelemetry/logs/logger.h" +# include "opentelemetry/logs/provider.h" +# include "opentelemetry/nostd/shared_ptr.h" using opentelemetry::logs::Logger; using opentelemetry::logs::LoggerProvider; @@ -109,4 +111,5 @@ TEST(Logger, PushLoggerImplementation) // Check that the implementation was pushed by calling TestLogger's GetName() auto logger = lp->GetLogger("TestLogger"); ASSERT_EQ("test logger", logger->GetName()); -} \ No newline at end of file +} +#endif diff --git a/api/test/logs/provider_test.cc b/api/test/logs/provider_test.cc index d61de52eb0..c9eb7bddc7 100644 --- a/api/test/logs/provider_test.cc +++ b/api/test/logs/provider_test.cc @@ -1,13 +1,15 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -#include -#include +#ifdef ENABLE_LOGS_PREVIEW -#include "opentelemetry/logs/provider.h" -#include "opentelemetry/nostd/shared_ptr.h" -#include "opentelemetry/nostd/span.h" -#include "opentelemetry/nostd/string_view.h" +# include +# include + +# include "opentelemetry/logs/provider.h" +# include "opentelemetry/nostd/shared_ptr.h" +# include "opentelemetry/nostd/span.h" +# include "opentelemetry/nostd/string_view.h" using opentelemetry::logs::Logger; using opentelemetry::logs::LoggerProvider; @@ -66,3 +68,4 @@ TEST(Provider, GetLogger) auto logger2 = tf->GetLogger("logger2", args); EXPECT_EQ(nullptr, logger2); } +#endif diff --git a/ci/do_ci.ps1 b/ci/do_ci.ps1 index 367d76e080..fdc141768e 100644 --- a/ci/do_ci.ps1 +++ b/ci/do_ci.ps1 @@ -5,7 +5,7 @@ $action = $args[0] $SRC_DIR=(Get-Item -Path ".\").FullName -$BAZEL_OPTIONS="" +$BAZEL_OPTIONS="--copt=-DENABLE_METRICS_PREVIEW --copt=-DENABLE_LOGS_PREVIEW" $BAZEL_TEST_OPTIONS="$BAZEL_OPTIONS --test_output=errors" if (!(test-path build)) { @@ -22,7 +22,7 @@ $VCPKG_DIR="$SRC_DIR\vcpkg" switch ($action) { "bazel.build" { - bazel build $BAZEL_OPTIONS -- //... //api/test/... //sdk/test/... + bazel build $BAZEL_OPTIONS -- //... $exit = $LASTEXITCODE if ($exit -ne 0) { exit $exit diff --git a/ci/do_ci.sh b/ci/do_ci.sh index 6dba3e384d..c78024a04f 100755 --- a/ci/do_ci.sh +++ b/ci/do_ci.sh @@ -23,7 +23,7 @@ mkdir -p "${BUILD_DIR}" [ -z "${PLUGIN_DIR}" ] && export PLUGIN_DIR=$HOME/plugin mkdir -p "${PLUGIN_DIR}" -BAZEL_OPTIONS="" +BAZEL_OPTIONS="--copt=-DENABLE_METRICS_PREVIEW --copt=-DENABLE_LOGS_PREVIEW" BAZEL_TEST_OPTIONS="$BAZEL_OPTIONS --test_output=errors" BAZEL_STARTUP_OPTIONS="--output_user_root=$HOME/.cache/bazel" @@ -39,6 +39,7 @@ if [[ "$1" == "cmake.test" ]]; then -DWITH_JAEGER=ON \ -DWITH_ELASTICSEARCH=ON \ -DWITH_METRICS_PREVIEW=ON \ + -DWITH_LOGS_PREVIEW=ON \ -DCMAKE_CXX_FLAGS="-Werror" \ "${SRC_DIR}" make @@ -114,7 +115,7 @@ EOF examples/plugin/load/load_plugin_example ${PLUGIN_DIR}/libexample_plugin.so /dev/null exit 0 elif [[ "$1" == "bazel.test" ]]; then - bazel $BAZEL_STARTUP_OPTIONS build --copt=-DENABLE_METRICS_PREVIEW $BAZEL_OPTIONS //... + bazel $BAZEL_STARTUP_OPTIONS build $BAZEL_OPTIONS //... bazel $BAZEL_STARTUP_OPTIONS test $BAZEL_TEST_OPTIONS //... exit 0 elif [[ "$1" == "bazel.legacy.test" ]]; then diff --git a/exporters/CMakeLists.txt b/exporters/CMakeLists.txt index f48b3bedb7..2ae8fd92bb 100644 --- a/exporters/CMakeLists.txt +++ b/exporters/CMakeLists.txt @@ -27,7 +27,7 @@ if(WITH_ZIPKIN) add_subdirectory(zipkin) endif() -if(WITH_ELASTICSEARCH) +if(WITH_ELASTICSEARCH AND WITH_LOGS_PREVIEW) add_subdirectory(elasticsearch) endif() diff --git a/exporters/elasticsearch/include/opentelemetry/exporters/elasticsearch/es_log_exporter.h b/exporters/elasticsearch/include/opentelemetry/exporters/elasticsearch/es_log_exporter.h index 5656ec4f13..74d1edeba6 100644 --- a/exporters/elasticsearch/include/opentelemetry/exporters/elasticsearch/es_log_exporter.h +++ b/exporters/elasticsearch/include/opentelemetry/exporters/elasticsearch/es_log_exporter.h @@ -2,15 +2,16 @@ // SPDX-License-Identifier: Apache-2.0 #pragma once +#ifdef ENABLE_LOGS_PREVIEW -#include "nlohmann/json.hpp" -#include "opentelemetry/ext/http/client/curl/http_client_curl.h" -#include "opentelemetry/nostd/type_traits.h" -#include "opentelemetry/sdk/logs/exporter.h" -#include "opentelemetry/sdk/logs/log_record.h" +# include "nlohmann/json.hpp" +# include "opentelemetry/ext/http/client/curl/http_client_curl.h" +# include "opentelemetry/nostd/type_traits.h" +# include "opentelemetry/sdk/logs/exporter.h" +# include "opentelemetry/sdk/logs/log_record.h" -#include -#include +# include +# include namespace nostd = opentelemetry::nostd; namespace sdklogs = opentelemetry::sdk::logs; @@ -109,3 +110,4 @@ class ElasticsearchLogExporter final : public sdklogs::LogExporter } // namespace logs } // namespace exporter OPENTELEMETRY_END_NAMESPACE +#endif diff --git a/exporters/elasticsearch/include/opentelemetry/exporters/elasticsearch/es_log_recordable.h b/exporters/elasticsearch/include/opentelemetry/exporters/elasticsearch/es_log_recordable.h index 7dc96ba2bd..a2742b1062 100644 --- a/exporters/elasticsearch/include/opentelemetry/exporters/elasticsearch/es_log_recordable.h +++ b/exporters/elasticsearch/include/opentelemetry/exporters/elasticsearch/es_log_recordable.h @@ -2,13 +2,14 @@ // SPDX-License-Identifier: Apache-2.0 #pragma once +#ifdef ENABLE_LOGS_PREVIEW -#include -#include -#include "nlohmann/json.hpp" -#include "opentelemetry/sdk/common/attribute_utils.h" -#include "opentelemetry/sdk/logs/recordable.h" -#include "opentelemetry/version.h" +# include +# include +# include "nlohmann/json.hpp" +# include "opentelemetry/sdk/common/attribute_utils.h" +# include "opentelemetry/sdk/logs/recordable.h" +# include "opentelemetry/version.h" OPENTELEMETRY_BEGIN_NAMESPACE namespace exporter @@ -158,3 +159,4 @@ class ElasticSearchRecordable final : public sdk::logs::Recordable } // namespace logs } // namespace exporter OPENTELEMETRY_END_NAMESPACE +#endif diff --git a/exporters/elasticsearch/src/es_log_exporter.cc b/exporters/elasticsearch/src/es_log_exporter.cc index c4805d3d94..28d59ac4f8 100644 --- a/exporters/elasticsearch/src/es_log_exporter.cc +++ b/exporters/elasticsearch/src/es_log_exporter.cc @@ -1,8 +1,10 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -#include "opentelemetry/exporters/elasticsearch/es_log_exporter.h" -#include "opentelemetry/exporters/elasticsearch/es_log_recordable.h" +#ifdef ENABLE_LOGS_PREVIEW + +# include "opentelemetry/exporters/elasticsearch/es_log_exporter.h" +# include "opentelemetry/exporters/elasticsearch/es_log_recordable.h" namespace nostd = opentelemetry::nostd; namespace sdklogs = opentelemetry::sdk::logs; @@ -215,3 +217,4 @@ bool ElasticsearchLogExporter::Shutdown(std::chrono::microseconds timeout) noexc } // namespace logs } // namespace exporter OPENTELEMETRY_END_NAMESPACE +#endif diff --git a/exporters/elasticsearch/test/es_log_exporter_test.cc b/exporters/elasticsearch/test/es_log_exporter_test.cc index 9424232631..8aa5cd654c 100644 --- a/exporters/elasticsearch/test/es_log_exporter_test.cc +++ b/exporters/elasticsearch/test/es_log_exporter_test.cc @@ -1,16 +1,18 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -#include "opentelemetry/exporters/elasticsearch/es_log_exporter.h" -#include "opentelemetry/ext/http/server/http_server.h" -#include "opentelemetry/logs/provider.h" -#include "opentelemetry/sdk/logs/exporter.h" -#include "opentelemetry/sdk/logs/log_record.h" -#include "opentelemetry/sdk/logs/logger_provider.h" -#include "opentelemetry/sdk/logs/simple_log_processor.h" +#ifdef ENABLE_LOGS_PREVIEW -#include -#include +# include "opentelemetry/exporters/elasticsearch/es_log_exporter.h" +# include "opentelemetry/ext/http/server/http_server.h" +# include "opentelemetry/logs/provider.h" +# include "opentelemetry/sdk/logs/exporter.h" +# include "opentelemetry/sdk/logs/log_record.h" +# include "opentelemetry/sdk/logs/logger_provider.h" +# include "opentelemetry/sdk/logs/simple_log_processor.h" + +# include +# include namespace sdklogs = opentelemetry::sdk::logs; namespace logs_api = opentelemetry::logs; @@ -22,7 +24,7 @@ TEST(ElasticsearchLogsExporterTests, Dummy) // to enable linking } -#if 0 +# if 0 // Attempt to write a log to an invalid host/port, test that the Export() returns failure TEST(ElasticsearchLogsExporterTests, InvalidEndpoint) { @@ -80,4 +82,5 @@ TEST(ElasticsearchLogsExporterTests, RecordableCreation) exporter->Export(nostd::span>(&record, 1)); } -#endif +# endif +#endif \ No newline at end of file diff --git a/exporters/ostream/CMakeLists.txt b/exporters/ostream/CMakeLists.txt index 196fa4d1b2..fbbf7b231d 100644 --- a/exporters/ostream/CMakeLists.txt +++ b/exporters/ostream/CMakeLists.txt @@ -1,29 +1,17 @@ -add_library(opentelemetry_exporter_ostream_logs src/log_exporter.cc) add_library(opentelemetry_exporter_ostream_span src/span_exporter.cc) -set_target_properties(opentelemetry_exporter_ostream_logs - PROPERTIES EXPORT_NAME ostream_log_exporter) - set_target_properties(opentelemetry_exporter_ostream_span PROPERTIES EXPORT_NAME ostream_span_exporter) -target_include_directories( - opentelemetry_exporter_ostream_logs - PUBLIC "$") - target_include_directories( opentelemetry_exporter_ostream_span PUBLIC "$") -target_link_libraries(opentelemetry_exporter_ostream_logs - PUBLIC opentelemetry_logs) - target_link_libraries(opentelemetry_exporter_ostream_span PUBLIC opentelemetry_trace) install( - TARGETS opentelemetry_exporter_ostream_logs - opentelemetry_exporter_ostream_span + TARGETS opentelemetry_exporter_ostream_span EXPORT "${PROJECT_NAME}-target" RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} @@ -32,30 +20,18 @@ install( install( DIRECTORY include/opentelemetry/exporters/ostream DESTINATION include/opentelemetry/exporters/ - FILES_MATCHING + PATTERN "*.h" PATTERN "metrics_exporter.h" EXCLUDE - PATTERN "*.h") + PATTERN "log_Exporter.h" EXCLUDE) if(BUILD_TESTING) add_executable(ostream_span_test test/ostream_span_test.cc) - add_executable(ostream_log_test test/ostream_log_test.cc) - target_link_libraries(ostream_span_test ${GTEST_BOTH_LIBRARIES} opentelemetry_exporter_ostream_span) - - target_link_libraries(ostream_log_test ${GTEST_BOTH_LIBRARIES} - opentelemetry_exporter_ostream_logs) - - gtest_add_tests( - TARGET ostream_log_test - TEST_PREFIX exporter. - TEST_LIST ostream_log_test) - gtest_add_tests( TARGET ostream_span_test TEST_PREFIX exporter. TEST_LIST ostream_span_test) - endif() # BUILD_TESTING if(WITH_METRICS_PREVIEW) @@ -76,7 +52,6 @@ if(WITH_METRICS_PREVIEW) install( DIRECTORY include/opentelemetry/exporters/ostream DESTINATION include/opentelemetry/exporters/ - FILES_MATCHING PATTERN "metrics_exporter.h") if(BUILD_TESTING) add_executable(ostream_metrics_test test/ostream_metrics_test.cc) @@ -88,3 +63,33 @@ if(WITH_METRICS_PREVIEW) TEST_LIST ostream_metrics_test) endif() endif() + +if(WITH_LOGS_PREVIEW) + add_library(opentelemetry_exporter_ostream_logs src/log_exporter.cc) + set_target_properties(opentelemetry_exporter_ostream_logs + PROPERTIES EXPORT_NAME ostream_log_exporter) + target_include_directories( + opentelemetry_exporter_ostream_logs + PUBLIC "$") + target_link_libraries(opentelemetry_exporter_ostream_logs + PUBLIC opentelemetry_logs) + install( + TARGETS opentelemetry_exporter_ostream_logs + EXPORT "${PROJECT_NAME}-target" + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) + install( + DIRECTORY include/opentelemetry/exporters/ostream + DESTINATION include/opentelemetry/exporters/ + PATTERN "log_exporter.h") + if(BUILD_TESTING) + add_executable(ostream_log_test test/ostream_log_test.cc) + target_link_libraries(ostream_log_test ${GTEST_BOTH_LIBRARIES} + opentelemetry_exporter_ostream_logs) + gtest_add_tests( + TARGET ostream_log_test + TEST_PREFIX exporter. + TEST_LIST ostream_log_test) + endif() +endif() diff --git a/exporters/ostream/include/opentelemetry/exporters/ostream/log_exporter.h b/exporters/ostream/include/opentelemetry/exporters/ostream/log_exporter.h index 4ef7858126..f4ab0be58a 100644 --- a/exporters/ostream/include/opentelemetry/exporters/ostream/log_exporter.h +++ b/exporters/ostream/include/opentelemetry/exporters/ostream/log_exporter.h @@ -2,14 +2,15 @@ // SPDX-License-Identifier: Apache-2.0 #pragma once +#ifdef ENABLE_LOGS_PREVIEW -#include "opentelemetry/nostd/type_traits.h" -#include "opentelemetry/sdk/logs/exporter.h" -#include "opentelemetry/sdk/logs/log_record.h" -#include "opentelemetry/version.h" +# include "opentelemetry/nostd/type_traits.h" +# include "opentelemetry/sdk/logs/exporter.h" +# include "opentelemetry/sdk/logs/log_record.h" +# include "opentelemetry/version.h" -#include -#include +# include +# include OPENTELEMETRY_BEGIN_NAMESPACE namespace exporter @@ -52,3 +53,4 @@ class OStreamLogExporter final : public opentelemetry::sdk::logs::LogExporter } // namespace logs } // namespace exporter OPENTELEMETRY_END_NAMESPACE +#endif diff --git a/exporters/ostream/src/log_exporter.cc b/exporters/ostream/src/log_exporter.cc index 150b66c49b..1def9ed1e6 100644 --- a/exporters/ostream/src/log_exporter.cc +++ b/exporters/ostream/src/log_exporter.cc @@ -1,9 +1,10 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -#include "opentelemetry/exporters/ostream/log_exporter.h" +#ifdef ENABLE_LOGS_PREVIEW +# include "opentelemetry/exporters/ostream/log_exporter.h" -#include +# include namespace nostd = opentelemetry::nostd; namespace sdklogs = opentelemetry::sdk::logs; @@ -44,7 +45,7 @@ void print_value(const std::vector &vec, std::ostream &sout) } // Prior to C++14, generic lambda is not available so fallback to functor. -#if __cplusplus < 201402L +# if __cplusplus < 201402L class OwnedAttributeValueVisitor { @@ -62,15 +63,15 @@ class OwnedAttributeValueVisitor std::ostream &sout_; }; -#endif +# endif void print_value(sdk::common::OwnedAttributeValue &value, std::ostream &sout) { -#if __cplusplus < 201402L +# if __cplusplus < 201402L nostd::visit(OwnedAttributeValueVisitor(sout), value); -#else +# else nostd::visit([&sout](auto &&arg) { print_value(arg, sout); }, value); -#endif +# endif } void printMap(std::unordered_map map, @@ -174,3 +175,4 @@ bool OStreamLogExporter::Shutdown(std::chrono::microseconds timeout) noexcept } // namespace logs } // namespace exporter OPENTELEMETRY_END_NAMESPACE +#endif diff --git a/exporters/ostream/test/ostream_log_test.cc b/exporters/ostream/test/ostream_log_test.cc index c7fd647935..80589a8898 100644 --- a/exporters/ostream/test/ostream_log_test.cc +++ b/exporters/ostream/test/ostream_log_test.cc @@ -1,15 +1,17 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -#include -#include "opentelemetry/exporters/ostream/log_exporter.h" -#include "opentelemetry/logs/provider.h" -#include "opentelemetry/nostd/span.h" -#include "opentelemetry/sdk/logs/logger_provider.h" -#include "opentelemetry/sdk/logs/simple_log_processor.h" +#ifdef ENABLE_LOGS_PREVIEW -#include -#include +# include +# include "opentelemetry/exporters/ostream/log_exporter.h" +# include "opentelemetry/logs/provider.h" +# include "opentelemetry/nostd/span.h" +# include "opentelemetry/sdk/logs/logger_provider.h" +# include "opentelemetry/sdk/logs/simple_log_processor.h" + +# include +# include namespace sdklogs = opentelemetry::sdk::logs; namespace logs_api = opentelemetry::logs; @@ -286,3 +288,4 @@ TEST(OStreamLogExporter, IntegrationTest) } // namespace logs } // namespace exporter OPENTELEMETRY_END_NAMESPACE +#endif diff --git a/sdk/CMakeLists.txt b/sdk/CMakeLists.txt index 3be79afbb3..3f217544d8 100644 --- a/sdk/CMakeLists.txt +++ b/sdk/CMakeLists.txt @@ -13,6 +13,11 @@ install( LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) +set(LOGS_EXCLUDE_PATTERN "") +if(NOT WITH_LOGS_PREVIEW) + set(LOGS_EXCLUDE_PATTERN "logs") +endif() + set(METRICS_EXCLUDE_PATTERN "") if(NOT WITH_METRICS_PREVIEW) set(METRICS_EXCLUDE_PATTERN "metrics") @@ -25,6 +30,13 @@ install( PATTERN "*.h" PATTERN "${METRICS_EXCLUDE_PATTERN}" EXCLUDE) +install( + DIRECTORY include/opentelemetry/sdk + DESTINATION include/opentelemetry/ + FILES_MATCHING + PATTERN "*.h" + PATTERN "${LOGS_EXCLUDE_PATTERN}" EXCLUDE) + add_subdirectory(src) if(BUILD_TESTING) diff --git a/sdk/include/opentelemetry/sdk/logs/batch_log_processor.h b/sdk/include/opentelemetry/sdk/logs/batch_log_processor.h index 4ac55d44a2..6d5d7fde3c 100644 --- a/sdk/include/opentelemetry/sdk/logs/batch_log_processor.h +++ b/sdk/include/opentelemetry/sdk/logs/batch_log_processor.h @@ -2,14 +2,15 @@ // SPDX-License-Identifier: Apache-2.0 #pragma once +#ifdef ENABLE_LOGS_PREVIEW -#include "opentelemetry/sdk/common/circular_buffer.h" -#include "opentelemetry/sdk/logs/exporter.h" -#include "opentelemetry/sdk/logs/processor.h" +# include "opentelemetry/sdk/common/circular_buffer.h" +# include "opentelemetry/sdk/logs/exporter.h" +# include "opentelemetry/sdk/logs/processor.h" -#include -#include -#include +# include +# include +# include OPENTELEMETRY_BEGIN_NAMESPACE namespace sdk @@ -124,3 +125,4 @@ class BatchLogProcessor : public LogProcessor } // namespace logs } // namespace sdk OPENTELEMETRY_END_NAMESPACE +#endif diff --git a/sdk/include/opentelemetry/sdk/logs/exporter.h b/sdk/include/opentelemetry/sdk/logs/exporter.h index fe08f0355a..85c58e9f12 100644 --- a/sdk/include/opentelemetry/sdk/logs/exporter.h +++ b/sdk/include/opentelemetry/sdk/logs/exporter.h @@ -2,13 +2,14 @@ // SPDX-License-Identifier: Apache-2.0 #pragma once +#ifdef ENABLE_LOGS_PREVIEW -#include -#include -#include "opentelemetry/nostd/span.h" -#include "opentelemetry/sdk/common/exporter_utils.h" -#include "opentelemetry/sdk/logs/processor.h" -#include "opentelemetry/sdk/logs/recordable.h" +# include +# include +# include "opentelemetry/nostd/span.h" +# include "opentelemetry/sdk/common/exporter_utils.h" +# include "opentelemetry/sdk/logs/processor.h" +# include "opentelemetry/sdk/logs/recordable.h" OPENTELEMETRY_BEGIN_NAMESPACE namespace sdk @@ -58,3 +59,4 @@ class LogExporter } // namespace logs } // namespace sdk OPENTELEMETRY_END_NAMESPACE +#endif diff --git a/sdk/include/opentelemetry/sdk/logs/log_record.h b/sdk/include/opentelemetry/sdk/logs/log_record.h index a49b7d8138..34ef5befb0 100644 --- a/sdk/include/opentelemetry/sdk/logs/log_record.h +++ b/sdk/include/opentelemetry/sdk/logs/log_record.h @@ -2,12 +2,13 @@ // SPDX-License-Identifier: Apache-2.0 #pragma once +#ifdef ENABLE_LOGS_PREVIEW -#include -#include -#include "opentelemetry/sdk/common/attribute_utils.h" -#include "opentelemetry/sdk/logs/recordable.h" -#include "opentelemetry/version.h" +# include +# include +# include "opentelemetry/sdk/common/attribute_utils.h" +# include "opentelemetry/sdk/logs/recordable.h" +# include "opentelemetry/version.h" OPENTELEMETRY_BEGIN_NAMESPACE namespace sdk @@ -184,3 +185,4 @@ class LogRecord final : public Recordable } // namespace logs } // namespace sdk OPENTELEMETRY_END_NAMESPACE +#endif diff --git a/sdk/include/opentelemetry/sdk/logs/logger.h b/sdk/include/opentelemetry/sdk/logs/logger.h index f972756990..a1d758be4c 100644 --- a/sdk/include/opentelemetry/sdk/logs/logger.h +++ b/sdk/include/opentelemetry/sdk/logs/logger.h @@ -2,12 +2,13 @@ // SPDX-License-Identifier: Apache-2.0 #pragma once +#ifdef ENABLE_LOGS_PREVIEW -#include "opentelemetry/logs/logger.h" -#include "opentelemetry/sdk/logs/logger_provider.h" -#include "opentelemetry/sdk/logs/processor.h" +# include "opentelemetry/logs/logger.h" +# include "opentelemetry/sdk/logs/logger_provider.h" +# include "opentelemetry/sdk/logs/processor.h" -#include +# include OPENTELEMETRY_BEGIN_NAMESPACE namespace sdk @@ -68,3 +69,4 @@ class Logger final : public opentelemetry::logs::Logger } // namespace logs } // namespace sdk OPENTELEMETRY_END_NAMESPACE +#endif diff --git a/sdk/include/opentelemetry/sdk/logs/logger_provider.h b/sdk/include/opentelemetry/sdk/logs/logger_provider.h index c2e35edcf1..db07ba5f66 100644 --- a/sdk/include/opentelemetry/sdk/logs/logger_provider.h +++ b/sdk/include/opentelemetry/sdk/logs/logger_provider.h @@ -2,23 +2,24 @@ // SPDX-License-Identifier: Apache-2.0/ #pragma once +#ifdef ENABLE_LOGS_PREVIEW -#include -#include -#include -#include -#include +# include +# include +# include +# include +# include -#include "opentelemetry/logs/logger_provider.h" -#include "opentelemetry/logs/noop.h" -#include "opentelemetry/nostd/shared_ptr.h" -#include "opentelemetry/sdk/common/atomic_shared_ptr.h" -#include "opentelemetry/sdk/logs/logger.h" -#include "opentelemetry/sdk/logs/processor.h" +# include "opentelemetry/logs/logger_provider.h" +# include "opentelemetry/logs/noop.h" +# include "opentelemetry/nostd/shared_ptr.h" +# include "opentelemetry/sdk/common/atomic_shared_ptr.h" +# include "opentelemetry/sdk/logs/logger.h" +# include "opentelemetry/sdk/logs/processor.h" // Define the maximum number of loggers that are allowed to be registered to the loggerprovider. // TODO: Add link to logging spec once this is added to it -#define MAX_LOGGER_COUNT 100 +# define MAX_LOGGER_COUNT 100 OPENTELEMETRY_BEGIN_NAMESPACE namespace sdk @@ -87,3 +88,4 @@ class LoggerProvider final : public opentelemetry::logs::LoggerProvider, } // namespace logs } // namespace sdk OPENTELEMETRY_END_NAMESPACE +#endif diff --git a/sdk/include/opentelemetry/sdk/logs/processor.h b/sdk/include/opentelemetry/sdk/logs/processor.h index 458632e7fb..36da036f31 100644 --- a/sdk/include/opentelemetry/sdk/logs/processor.h +++ b/sdk/include/opentelemetry/sdk/logs/processor.h @@ -2,10 +2,11 @@ // SPDX-License-Identifier: Apache-2.0 #pragma once +#ifdef ENABLE_LOGS_PREVIEW -#include -#include -#include "opentelemetry/sdk/logs/recordable.h" +# include +# include +# include "opentelemetry/sdk/logs/recordable.h" OPENTELEMETRY_BEGIN_NAMESPACE namespace sdk @@ -57,3 +58,4 @@ class LogProcessor } // namespace logs } // namespace sdk OPENTELEMETRY_END_NAMESPACE +#endif diff --git a/sdk/include/opentelemetry/sdk/logs/recordable.h b/sdk/include/opentelemetry/sdk/logs/recordable.h index 1dba6967b1..cbc8fa1c85 100644 --- a/sdk/include/opentelemetry/sdk/logs/recordable.h +++ b/sdk/include/opentelemetry/sdk/logs/recordable.h @@ -2,19 +2,20 @@ // SPDX-License-Identifier: Apache-2.0 #pragma once +#ifdef ENABLE_LOGS_PREVIEW -#include "opentelemetry/common/attribute_value.h" -#include "opentelemetry/common/key_value_iterable.h" -#include "opentelemetry/common/timestamp.h" -#include "opentelemetry/logs/severity.h" -#include "opentelemetry/trace/span.h" -#include "opentelemetry/trace/span_context.h" -#include "opentelemetry/trace/span_id.h" -#include "opentelemetry/trace/trace_flags.h" -#include "opentelemetry/trace/trace_id.h" -#include "opentelemetry/version.h" +# include "opentelemetry/common/attribute_value.h" +# include "opentelemetry/common/key_value_iterable.h" +# include "opentelemetry/common/timestamp.h" +# include "opentelemetry/logs/severity.h" +# include "opentelemetry/trace/span.h" +# include "opentelemetry/trace/span_context.h" +# include "opentelemetry/trace/span_id.h" +# include "opentelemetry/trace/trace_flags.h" +# include "opentelemetry/trace/trace_id.h" +# include "opentelemetry/version.h" -#include +# include OPENTELEMETRY_BEGIN_NAMESPACE namespace sdk @@ -92,3 +93,4 @@ class Recordable } // namespace logs } // namespace sdk OPENTELEMETRY_END_NAMESPACE +#endif diff --git a/sdk/include/opentelemetry/sdk/logs/simple_log_processor.h b/sdk/include/opentelemetry/sdk/logs/simple_log_processor.h index 5a055534ef..cc3aec47b2 100644 --- a/sdk/include/opentelemetry/sdk/logs/simple_log_processor.h +++ b/sdk/include/opentelemetry/sdk/logs/simple_log_processor.h @@ -2,13 +2,14 @@ // SPDX-License-Identifier: Apache-2.0 #pragma once +#ifdef ENABLE_LOGS_PREVIEW -#include -#include +# include +# include -#include "opentelemetry/common/spin_lock_mutex.h" -#include "opentelemetry/sdk/logs/exporter.h" -#include "opentelemetry/sdk/logs/processor.h" +# include "opentelemetry/common/spin_lock_mutex.h" +# include "opentelemetry/sdk/logs/exporter.h" +# include "opentelemetry/sdk/logs/processor.h" OPENTELEMETRY_BEGIN_NAMESPACE namespace sdk @@ -51,3 +52,4 @@ class SimpleLogProcessor : public LogProcessor } // namespace logs } // namespace sdk OPENTELEMETRY_END_NAMESPACE +#endif diff --git a/sdk/src/CMakeLists.txt b/sdk/src/CMakeLists.txt index 47f76ac170..2261454239 100644 --- a/sdk/src/CMakeLists.txt +++ b/sdk/src/CMakeLists.txt @@ -3,6 +3,8 @@ add_subdirectory(trace) if(WITH_METRICS_PREVIEW) add_subdirectory(metrics) endif() -add_subdirectory(logs) +if(WITH_LOGS_PREVIEW) + add_subdirectory(logs) +endif() add_subdirectory(version) add_subdirectory(resource) diff --git a/sdk/src/logs/batch_log_processor.cc b/sdk/src/logs/batch_log_processor.cc index 477adc0e3d..4628bb1449 100644 --- a/sdk/src/logs/batch_log_processor.cc +++ b/sdk/src/logs/batch_log_processor.cc @@ -1,9 +1,10 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -#include "opentelemetry/sdk/logs/batch_log_processor.h" +#ifdef ENABLE_LOGS_PREVIEW +# include "opentelemetry/sdk/logs/batch_log_processor.h" -#include +# include using opentelemetry::sdk::common::AtomicUniquePtr; using opentelemetry::sdk::common::CircularBufferRange; @@ -198,3 +199,4 @@ BatchLogProcessor::~BatchLogProcessor() } // namespace logs } // namespace sdk OPENTELEMETRY_END_NAMESPACE +#endif diff --git a/sdk/src/logs/logger.cc b/sdk/src/logs/logger.cc index d08e30368b..970f61b7e9 100644 --- a/sdk/src/logs/logger.cc +++ b/sdk/src/logs/logger.cc @@ -1,9 +1,10 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -#include "opentelemetry/sdk/logs/logger.h" -#include "opentelemetry/sdk/logs/log_record.h" -#include "opentelemetry/trace/provider.h" +#ifdef ENABLE_LOGS_PREVIEW +# include "opentelemetry/sdk/logs/logger.h" +# include "opentelemetry/sdk/logs/log_record.h" +# include "opentelemetry/trace/provider.h" OPENTELEMETRY_BEGIN_NAMESPACE namespace sdk @@ -114,3 +115,4 @@ void Logger::Log(opentelemetry::logs::Severity severity, } // namespace logs } // namespace sdk OPENTELEMETRY_END_NAMESPACE +#endif diff --git a/sdk/src/logs/logger_provider.cc b/sdk/src/logs/logger_provider.cc index beab4e3139..24718a3c22 100644 --- a/sdk/src/logs/logger_provider.cc +++ b/sdk/src/logs/logger_provider.cc @@ -1,7 +1,9 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -#include "opentelemetry/sdk/logs/logger_provider.h" +#ifdef ENABLE_LOGS_PREVIEW + +# include "opentelemetry/sdk/logs/logger_provider.h" OPENTELEMETRY_BEGIN_NAMESPACE namespace sdk @@ -66,3 +68,4 @@ void LoggerProvider::SetProcessor(std::shared_ptr processor) noexc } // namespace logs } // namespace sdk OPENTELEMETRY_END_NAMESPACE +#endif diff --git a/sdk/src/logs/simple_log_processor.cc b/sdk/src/logs/simple_log_processor.cc index 73224be8a5..ebcd6a4642 100644 --- a/sdk/src/logs/simple_log_processor.cc +++ b/sdk/src/logs/simple_log_processor.cc @@ -1,10 +1,11 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -#include "opentelemetry/sdk/logs/simple_log_processor.h" +#ifdef ENABLE_LOGS_PREVIEW +# include "opentelemetry/sdk/logs/simple_log_processor.h" -#include -#include +# include +# include OPENTELEMETRY_BEGIN_NAMESPACE namespace sdk @@ -60,3 +61,4 @@ bool SimpleLogProcessor::Shutdown(std::chrono::microseconds timeout) noexcept } // namespace logs } // namespace sdk OPENTELEMETRY_END_NAMESPACE +#endif diff --git a/sdk/test/CMakeLists.txt b/sdk/test/CMakeLists.txt index f574b688fb..6c9955d23d 100644 --- a/sdk/test/CMakeLists.txt +++ b/sdk/test/CMakeLists.txt @@ -3,6 +3,8 @@ add_subdirectory(trace) if(WITH_METRICS_PREVIEW) add_subdirectory(metrics) endif() -add_subdirectory(logs) +if(WITH_LOGS_PREVIEW) + add_subdirectory(logs) +endif() add_subdirectory(resource) add_subdirectory(instrumentationlibrary) diff --git a/sdk/test/logs/batch_log_processor_test.cc b/sdk/test/logs/batch_log_processor_test.cc index 65ead5601d..ebd0be069e 100644 --- a/sdk/test/logs/batch_log_processor_test.cc +++ b/sdk/test/logs/batch_log_processor_test.cc @@ -1,13 +1,15 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -#include "opentelemetry/sdk/logs/batch_log_processor.h" -#include "opentelemetry/sdk/logs/exporter.h" -#include "opentelemetry/sdk/logs/log_record.h" +#ifdef ENABLE_LOGS_PREVIEW -#include -#include -#include +# include "opentelemetry/sdk/logs/batch_log_processor.h" +# include "opentelemetry/sdk/logs/exporter.h" +# include "opentelemetry/sdk/logs/log_record.h" + +# include +# include +# include using namespace opentelemetry::sdk::logs; using namespace opentelemetry::sdk::common; @@ -262,3 +264,4 @@ TEST_F(BatchLogProcessorTest, TestScheduledDelayMillis) EXPECT_EQ("Log" + std::to_string(i), logs_received->at(i)->GetName()); } } +#endif diff --git a/sdk/test/logs/log_record_test.cc b/sdk/test/logs/log_record_test.cc index f93176517a..8750627d5b 100644 --- a/sdk/test/logs/log_record_test.cc +++ b/sdk/test/logs/log_record_test.cc @@ -1,12 +1,14 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -#include "opentelemetry/sdk/logs/log_record.h" -#include "opentelemetry/nostd/variant.h" -#include "opentelemetry/trace/span_id.h" -#include "opentelemetry/trace/trace_id.h" +#ifdef ENABLE_LOGS_PREVIEW -#include +# include "opentelemetry/sdk/logs/log_record.h" +# include "opentelemetry/nostd/variant.h" +# include "opentelemetry/trace/span_id.h" +# include "opentelemetry/trace/trace_id.h" + +# include using opentelemetry::sdk::logs::LogRecord; @@ -60,3 +62,4 @@ TEST(LogRecord, SetAndGet) ASSERT_EQ(record.GetTraceFlags(), trace_flags); ASSERT_EQ(record.GetTimestamp().time_since_epoch(), now.time_since_epoch()); } +#endif diff --git a/sdk/test/logs/logger_provider_sdk_test.cc b/sdk/test/logs/logger_provider_sdk_test.cc index fbcb20125c..fd2d70415e 100644 --- a/sdk/test/logs/logger_provider_sdk_test.cc +++ b/sdk/test/logs/logger_provider_sdk_test.cc @@ -1,15 +1,17 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -#include -#include "opentelemetry/logs/provider.h" -#include "opentelemetry/nostd/shared_ptr.h" -#include "opentelemetry/nostd/string_view.h" -#include "opentelemetry/sdk/logs/log_record.h" -#include "opentelemetry/sdk/logs/logger.h" -#include "opentelemetry/sdk/logs/logger_provider.h" +#ifdef ENABLE_LOGS_PREVIEW -#include +# include +# include "opentelemetry/logs/provider.h" +# include "opentelemetry/nostd/shared_ptr.h" +# include "opentelemetry/nostd/string_view.h" +# include "opentelemetry/sdk/logs/log_record.h" +# include "opentelemetry/sdk/logs/logger.h" +# include "opentelemetry/sdk/logs/logger_provider.h" + +# include using namespace opentelemetry::sdk::logs; @@ -86,3 +88,4 @@ TEST(LoggerProviderSDK, GetAndSetProcessor) lp.SetProcessor(proc2); ASSERT_EQ(proc2, lp.GetProcessor()); } +#endif diff --git a/sdk/test/logs/logger_sdk_test.cc b/sdk/test/logs/logger_sdk_test.cc index a635840850..fbc7947752 100644 --- a/sdk/test/logs/logger_sdk_test.cc +++ b/sdk/test/logs/logger_sdk_test.cc @@ -1,10 +1,12 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -#include "opentelemetry/sdk/logs/log_record.h" -#include "opentelemetry/sdk/logs/logger.h" +#ifdef ENABLE_LOGS_PREVIEW -#include +# include "opentelemetry/sdk/logs/log_record.h" +# include "opentelemetry/sdk/logs/logger.h" + +# include using namespace opentelemetry::sdk::logs; @@ -85,3 +87,4 @@ TEST(LoggerSDK, LogToAProcessor) ASSERT_EQ(shared_recordable->GetName(), "Log Name"); ASSERT_EQ(shared_recordable->GetBody(), "Log Message"); } +#endif diff --git a/sdk/test/logs/simple_log_processor_test.cc b/sdk/test/logs/simple_log_processor_test.cc index d87aabbf0e..e2f2ad2b6e 100644 --- a/sdk/test/logs/simple_log_processor_test.cc +++ b/sdk/test/logs/simple_log_processor_test.cc @@ -1,15 +1,17 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -#include "opentelemetry/sdk/logs/simple_log_processor.h" -#include "opentelemetry/nostd/span.h" -#include "opentelemetry/sdk/logs/exporter.h" -#include "opentelemetry/sdk/logs/log_record.h" +#ifdef ENABLE_LOGS_PREVIEW -#include +# include "opentelemetry/sdk/logs/simple_log_processor.h" +# include "opentelemetry/nostd/span.h" +# include "opentelemetry/sdk/logs/exporter.h" +# include "opentelemetry/sdk/logs/log_record.h" -#include -#include +# include + +# include +# include using namespace opentelemetry::sdk::logs; using namespace opentelemetry::sdk::common; @@ -152,3 +154,4 @@ TEST(SimpleLogProcessorTest, ShutDownFail) // Expect failure result when processor given a negative timeout allowed to shutdown EXPECT_EQ(false, processor.Shutdown(std::chrono::microseconds(-1))); } +#endif