From 2f4e3a08edbeb96ca9228811d81f303c7809cda7 Mon Sep 17 00:00:00 2001 From: Oblivion Date: Thu, 21 Apr 2022 20:19:13 +0000 Subject: [PATCH 1/3] ostream metrics cmake --- examples/CMakeLists.txt | 4 +-- examples/common/CMakeLists.txt | 1 + .../common/metrics_foo_library/CMakeLists.txt | 2 ++ examples/metrics_simple/CMakeLists.txt | 17 +++++++---- exporters/ostream/CMakeLists.txt | 28 +++++++++++++++++++ 5 files changed, 44 insertions(+), 8 deletions(-) create mode 100644 examples/common/metrics_foo_library/CMakeLists.txt diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 70bca10221..db0fe159be 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -18,9 +18,7 @@ endif() add_subdirectory(plugin) add_subdirectory(simple) add_subdirectory(batch) -if(WITH_METRICS_PREVIEW) - add_subdirectory(metrics_simple) -endif() +add_subdirectory(metrics_simple) add_subdirectory(multithreaded) add_subdirectory(multi_processor) add_subdirectory(http) diff --git a/examples/common/CMakeLists.txt b/examples/common/CMakeLists.txt index f89faf4a2f..c2fdca2594 100644 --- a/examples/common/CMakeLists.txt +++ b/examples/common/CMakeLists.txt @@ -2,3 +2,4 @@ add_subdirectory(foo_library) if(WITH_LOGS_PREVIEW) add_subdirectory(logs_foo_library) endif() +add_subdirectory(metrics_foo_library) diff --git a/examples/common/metrics_foo_library/CMakeLists.txt b/examples/common/metrics_foo_library/CMakeLists.txt new file mode 100644 index 0000000000..4f2bca2a0b --- /dev/null +++ b/examples/common/metrics_foo_library/CMakeLists.txt @@ -0,0 +1,2 @@ +add_library(common_metrics_foo_library foo_library.h foo_library.cc) +target_link_libraries(common_metrics_foo_library PUBLIC opentelemetry_api) diff --git a/examples/metrics_simple/CMakeLists.txt b/examples/metrics_simple/CMakeLists.txt index 94b441061b..a2088fd510 100644 --- a/examples/metrics_simple/CMakeLists.txt +++ b/examples/metrics_simple/CMakeLists.txt @@ -1,6 +1,13 @@ include_directories(${CMAKE_SOURCE_DIR}/exporters/ostream/include) - -add_executable(simple_metrics main.cc) -target_link_libraries( - simple_metrics ${CMAKE_THREAD_LIBS_INIT} opentelemetry_metrics_deprecated - opentelemetry_exporter_ostream_metrics_deprecated) +if(WITH_METRICS_PREVIEW) + add_executable(simple_metrics main.cc) + target_link_libraries( + simple_metrics ${CMAKE_THREAD_LIBS_INIT} opentelemetry_metrics_deprecated + opentelemetry_exporter_ostream_metrics_deprecated) +else() + add_executable(metrics_ostream_example metrics_ostream.cc) + target_link_libraries( + metrics_ostream_example ${CMAKE_THREAD_LIBS_INIT} opentelemetry_metrics + opentelemetry_exporter_ostream_metrics opentelemetry_resources + common_metrics_foo_library) +endif() diff --git a/exporters/ostream/CMakeLists.txt b/exporters/ostream/CMakeLists.txt index 31f1e9b0d0..516a1066ba 100644 --- a/exporters/ostream/CMakeLists.txt +++ b/exporters/ostream/CMakeLists.txt @@ -63,6 +63,34 @@ if(WITH_METRICS_PREVIEW) TEST_PREFIX exporter. TEST_LIST ostream_metrics_test) endif() +else() + add_library(opentelemetry_exporter_ostream_metrics src/metric_exporter.cc) + set_target_properties(opentelemetry_exporter_ostream_metrics + PROPERTIES EXPORT_NAME ostream_metrics_exporter) + target_include_directories( + opentelemetry_exporter_ostream_metrics + PUBLIC "$") + target_link_libraries(opentelemetry_exporter_ostream_metrics + PUBLIC opentelemetry_metrics) + install( + TARGETS opentelemetry_exporter_ostream_metrics + 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 "metric_exporter.h") + if(BUILD_TESTING) + add_executable(ostream_metric_test test/ostream_metric_test.cc) + target_link_libraries(ostream_metric_test ${GTEST_BOTH_LIBRARIES} + opentelemetry_exporter_ostream_metrics) + gtest_add_tests( + TARGET ostream_metric_test + TEST_PREFIX exporter. + TEST_LIST ostream_metric_test) + endif() endif() if(WITH_LOGS_PREVIEW) From 00be1ab63fdf1382a1f3e01627fe128675771a42 Mon Sep 17 00:00:00 2001 From: Ehsan Saei <71217171+esigo@users.noreply.github.com> Date: Thu, 21 Apr 2022 22:30:57 +0200 Subject: [PATCH 2/3] fix CI --- exporters/ostream/CMakeLists.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/exporters/ostream/CMakeLists.txt b/exporters/ostream/CMakeLists.txt index 516a1066ba..8e24437ec4 100644 --- a/exporters/ostream/CMakeLists.txt +++ b/exporters/ostream/CMakeLists.txt @@ -85,7 +85,8 @@ else() if(BUILD_TESTING) add_executable(ostream_metric_test test/ostream_metric_test.cc) target_link_libraries(ostream_metric_test ${GTEST_BOTH_LIBRARIES} - opentelemetry_exporter_ostream_metrics) + opentelemetry_exporter_ostream_metrics + opentelemetry_resources) gtest_add_tests( TARGET ostream_metric_test TEST_PREFIX exporter. From 990da7e3975b139f3ab5ed6e518c70895abec5fb Mon Sep 17 00:00:00 2001 From: Oblivion Date: Thu, 21 Apr 2022 20:43:29 +0000 Subject: [PATCH 3/3] fix format --- exporters/ostream/CMakeLists.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/exporters/ostream/CMakeLists.txt b/exporters/ostream/CMakeLists.txt index 8e24437ec4..db2562ddde 100644 --- a/exporters/ostream/CMakeLists.txt +++ b/exporters/ostream/CMakeLists.txt @@ -84,9 +84,9 @@ else() PATTERN "metric_exporter.h") if(BUILD_TESTING) add_executable(ostream_metric_test test/ostream_metric_test.cc) - target_link_libraries(ostream_metric_test ${GTEST_BOTH_LIBRARIES} - opentelemetry_exporter_ostream_metrics - opentelemetry_resources) + target_link_libraries( + ostream_metric_test ${GTEST_BOTH_LIBRARIES} + opentelemetry_exporter_ostream_metrics opentelemetry_resources) gtest_add_tests( TARGET ostream_metric_test TEST_PREFIX exporter.