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..db2562ddde 100644 --- a/exporters/ostream/CMakeLists.txt +++ b/exporters/ostream/CMakeLists.txt @@ -63,6 +63,35 @@ 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 opentelemetry_resources) + gtest_add_tests( + TARGET ostream_metric_test + TEST_PREFIX exporter. + TEST_LIST ostream_metric_test) + endif() endif() if(WITH_LOGS_PREVIEW)