From b94d6ba9875cb7e6273ae56c078d991517387f1f Mon Sep 17 00:00:00 2001 From: Harish Shan <140232061+perhapsmaple@users.noreply.github.com> Date: Sat, 7 Oct 2023 22:27:30 +0530 Subject: [PATCH 1/7] Export Metrics classes from SDK Signed-off-by: Harish Shan <140232061+perhapsmaple@users.noreply.github.com> --- .../metrics/export/periodic_exporting_metric_reader_factory.h | 2 +- sdk/include/opentelemetry/sdk/metrics/meter_context_factory.h | 2 +- sdk/include/opentelemetry/sdk/metrics/meter_provider.h | 2 +- sdk/include/opentelemetry/sdk/metrics/meter_provider_factory.h | 2 +- .../sdk/metrics/view/instrument_selector_factory.h | 2 +- .../opentelemetry/sdk/metrics/view/meter_selector_factory.h | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/sdk/include/opentelemetry/sdk/metrics/export/periodic_exporting_metric_reader_factory.h b/sdk/include/opentelemetry/sdk/metrics/export/periodic_exporting_metric_reader_factory.h index c4254793f3..1c5c1a0d7b 100644 --- a/sdk/include/opentelemetry/sdk/metrics/export/periodic_exporting_metric_reader_factory.h +++ b/sdk/include/opentelemetry/sdk/metrics/export/periodic_exporting_metric_reader_factory.h @@ -16,7 +16,7 @@ namespace metrics class MetricReader; class PushMetricExporter; -class PeriodicExportingMetricReaderFactory +class OPENTELEMETRY_EXPORT PeriodicExportingMetricReaderFactory { public: static std::unique_ptr Create(std::unique_ptr exporter, diff --git a/sdk/include/opentelemetry/sdk/metrics/meter_context_factory.h b/sdk/include/opentelemetry/sdk/metrics/meter_context_factory.h index d5ca16cc27..13e3a9f290 100644 --- a/sdk/include/opentelemetry/sdk/metrics/meter_context_factory.h +++ b/sdk/include/opentelemetry/sdk/metrics/meter_context_factory.h @@ -21,7 +21,7 @@ class ViewRegistry; /** * Factory class for MeterContext. */ -class MeterContextFactory +class OPENTELEMETRY_EXPORT MeterContextFactory { public: /** diff --git a/sdk/include/opentelemetry/sdk/metrics/meter_provider.h b/sdk/include/opentelemetry/sdk/metrics/meter_provider.h index 00f9a35ac2..818e407b32 100644 --- a/sdk/include/opentelemetry/sdk/metrics/meter_provider.h +++ b/sdk/include/opentelemetry/sdk/metrics/meter_provider.h @@ -30,7 +30,7 @@ class MeterContext; class MetricCollector; class MetricReader; -class MeterProvider final : public opentelemetry::metrics::MeterProvider +class OPENTELEMETRY_EXPORT MeterProvider final : public opentelemetry::metrics::MeterProvider { public: /** diff --git a/sdk/include/opentelemetry/sdk/metrics/meter_provider_factory.h b/sdk/include/opentelemetry/sdk/metrics/meter_provider_factory.h index 6c0375ad9d..69e77ebf5e 100644 --- a/sdk/include/opentelemetry/sdk/metrics/meter_provider_factory.h +++ b/sdk/include/opentelemetry/sdk/metrics/meter_provider_factory.h @@ -56,7 +56,7 @@ namespace metrics even if this forces, temporarily, existing applications to use a downcast. */ -class MeterProviderFactory +class OPENTELEMETRY_EXPORT MeterProviderFactory { public: static std::unique_ptr Create(); diff --git a/sdk/include/opentelemetry/sdk/metrics/view/instrument_selector_factory.h b/sdk/include/opentelemetry/sdk/metrics/view/instrument_selector_factory.h index f30b1e27c1..0af1efe04b 100644 --- a/sdk/include/opentelemetry/sdk/metrics/view/instrument_selector_factory.h +++ b/sdk/include/opentelemetry/sdk/metrics/view/instrument_selector_factory.h @@ -14,7 +14,7 @@ namespace metrics class InstrumentSelector; -class InstrumentSelectorFactory +class OPENTELEMETRY_EXPORT InstrumentSelectorFactory { public: static std::unique_ptr Create( diff --git a/sdk/include/opentelemetry/sdk/metrics/view/meter_selector_factory.h b/sdk/include/opentelemetry/sdk/metrics/view/meter_selector_factory.h index f335f725f7..bd599d9c4b 100644 --- a/sdk/include/opentelemetry/sdk/metrics/view/meter_selector_factory.h +++ b/sdk/include/opentelemetry/sdk/metrics/view/meter_selector_factory.h @@ -16,7 +16,7 @@ namespace metrics class MeterSelector; -class MeterSelectorFactory +class OPENTELEMETRY_EXPORT MeterSelectorFactory { public: static std::unique_ptr Create(opentelemetry::nostd::string_view name, From d25ca585c989ad4b8c413568f2695f9c8e524a6f Mon Sep 17 00:00:00 2001 From: Harish Shan <140232061+perhapsmaple@users.noreply.github.com> Date: Sat, 7 Oct 2023 22:35:35 +0530 Subject: [PATCH 2/7] Export OTLP Metric Exporters Signed-off-by: Harish Shan <140232061+perhapsmaple@users.noreply.github.com> --- .../exporters/otlp/otlp_grpc_metric_exporter_factory.h | 2 +- .../exporters/otlp/otlp_http_metric_exporter_factory.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_grpc_metric_exporter_factory.h b/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_grpc_metric_exporter_factory.h index d605100ae6..f8b3ee1fc3 100644 --- a/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_grpc_metric_exporter_factory.h +++ b/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_grpc_metric_exporter_factory.h @@ -15,7 +15,7 @@ namespace otlp /** * Factory class for OtlpGrpcMetricExporter. */ -class OtlpGrpcMetricExporterFactory +class OPENTELEMETRY_EXPORT OtlpGrpcMetricExporterFactory { public: /** diff --git a/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_http_metric_exporter_factory.h b/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_http_metric_exporter_factory.h index 2fe0476575..7fa7980470 100644 --- a/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_http_metric_exporter_factory.h +++ b/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_http_metric_exporter_factory.h @@ -17,7 +17,7 @@ namespace otlp /** * Factory class for OtlpHttpMetricExporter. */ -class OtlpHttpMetricExporterFactory +class OPENTELEMETRY_EXPORT OtlpHttpMetricExporterFactory { public: /** From a177289226a49648c224d84808b4d4c3e963b437 Mon Sep 17 00:00:00 2001 From: Harish Shan <140232061+perhapsmaple@users.noreply.github.com> Date: Sat, 7 Oct 2023 22:36:24 +0530 Subject: [PATCH 3/7] Update Exported Symbols Signed-off-by: Harish Shan <140232061+perhapsmaple@users.noreply.github.com> --- ext/src/dll/CMakeLists.txt | 16 +++++++++++++ ext/src/dll/opentelemetry_cpp.src | 37 +++++++++++++++++++++++++++++++ 2 files changed, 53 insertions(+) diff --git a/ext/src/dll/CMakeLists.txt b/ext/src/dll/CMakeLists.txt index c0b6b91745..109000ea3e 100644 --- a/ext/src/dll/CMakeLists.txt +++ b/ext/src/dll/CMakeLists.txt @@ -22,6 +22,22 @@ if(WITH_OTLP_HTTP) PRIVATE opentelemetry_exporter_otlp_http) endif() +target_link_libraries( + opentelemetry_cpp PRIVATE opentelemetry_metrics + opentelemetry_exporter_ostream_metrics) + +if(WITH_OTLP_GRPC) + add_compile_definitions(WITH_OTLP_GRPC) + target_link_libraries(opentelemetry_cpp + PRIVATE opentelemetry_exporter_otlp_grpc_metrics) +endif() + +if(WITH_OTLP_HTTP) + add_compile_definitions(WITH_OTLP_HTTP) + target_link_libraries(opentelemetry_cpp + PRIVATE opentelemetry_exporter_otlp_http_metric) +endif() + target_link_libraries( opentelemetry_cpp PRIVATE opentelemetry_logs opentelemetry_exporter_ostream_logs) diff --git a/ext/src/dll/opentelemetry_cpp.src b/ext/src/dll/opentelemetry_cpp.src index 5d6d5e0092..0ff375ace8 100644 --- a/ext/src/dll/opentelemetry_cpp.src +++ b/ext/src/dll/opentelemetry_cpp.src @@ -57,15 +57,48 @@ EXPORTS ?ForceFlush@TracerProvider@trace@sdk@v1@opentelemetry@@QEAA_NV?$duration@_JU?$ratio@$00$0PECEA@@std@@@chrono@std@@@Z ?ForceFlush@LoggerProvider@logs@sdk@v1@opentelemetry@@QEAA_NV?$duration@_JU?$ratio@$00$0PECEA@@std@@@chrono@std@@@Z ??0OStreamLogRecordExporter@logs@exporter@v1@opentelemetry@@QEAA@AEAV?$basic_ostream@DU?$char_traits@D@std@@@std@@@Z + + // public: static class std::unique_ptr > __cdecl opentelemetry::v1::exporter::metrics::OStreamMetricExporterFactory::Create(void) + ?Create@OStreamMetricExporterFactory@metrics@exporter@v1@opentelemetry@@SA?AV?$unique_ptr@VPushMetricExporter@metrics@sdk@v1@opentelemetry@@U?$default_delete@VPushMetricExporter@metrics@sdk@v1@opentelemetry@@@std@@@std@@XZ + // public: static class std::unique_ptr > __cdecl opentelemetry::v1::sdk::metrics::PeriodicExportingMetricReaderFactory::Create(class std::unique_ptr >,struct opentelemetry::v1::sdk::metrics::PeriodicExportingMetricReaderOptions const & __ptr64) + ?Create@PeriodicExportingMetricReaderFactory@metrics@sdk@v1@opentelemetry@@SA?AV?$unique_ptr@VMetricReader@metrics@sdk@v1@opentelemetry@@U?$default_delete@VMetricReader@metrics@sdk@v1@opentelemetry@@@std@@@std@@V?$unique_ptr@VPushMetricExporter@metrics@sdk@v1@opentelemetry@@U?$default_delete@VPushMetricExporter@metrics@sdk@v1@opentelemetry@@@std@@@7@AEBUPeriodicExportingMetricReaderOptions@2345@@Z + // public: static class std::unique_ptr > __cdecl opentelemetry::v1::sdk::metrics::MeterProviderFactory::Create(void) + ?Create@MeterProviderFactory@metrics@sdk@v1@opentelemetry@@SA?AV?$unique_ptr@VMeterProvider@metrics@v1@opentelemetry@@U?$default_delete@VMeterProvider@metrics@v1@opentelemetry@@@std@@@std@@XZ + // public: static class std::unique_ptr > __cdecl opentelemetry::v1::sdk::metrics::MeterContextFactory::Create(void) + ?Create@MeterContextFactory@metrics@sdk@v1@opentelemetry@@SA?AV?$unique_ptr@VMeterContext@metrics@sdk@v1@opentelemetry@@U?$default_delete@VMeterContext@metrics@sdk@v1@opentelemetry@@@std@@@std@@XZ + // public: static class std::unique_ptr > __cdecl opentelemetry::v1::sdk::metrics::MeterProviderFactory::Create(class std::unique_ptr >) + ?Create@MeterProviderFactory@metrics@sdk@v1@opentelemetry@@SA?AV?$unique_ptr@VMeterProvider@metrics@v1@opentelemetry@@U?$default_delete@VMeterProvider@metrics@v1@opentelemetry@@@std@@@std@@V?$unique_ptr@VMeterContext@metrics@sdk@v1@opentelemetry@@U?$default_delete@VMeterContext@metrics@sdk@v1@opentelemetry@@@std@@@7@@Z + // public: static class std::unique_ptr > __cdecl opentelemetry::v1::sdk::metrics::ViewFactory::Create(class std::basic_string,class std::allocator > const &,class std::basic_string,class std::allocator > const &,class std::basic_string,class std::allocator > const &,enum opentelemetry::v1::sdk::metrics::AggregationType,class std::shared_ptr) + ?Create@ViewFactory@metrics@sdk@v1@opentelemetry@@SA?AV?$unique_ptr@VView@metrics@sdk@v1@opentelemetry@@U?$default_delete@VView@metrics@sdk@v1@opentelemetry@@@std@@@std@@AEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@7@00W4AggregationType@2345@V?$shared_ptr@VAggregationConfig@metrics@sdk@v1@opentelemetry@@@7@@Z + // public: static class std::unique_ptr > __cdecl opentelemetry::v1::sdk::metrics::ViewFactory::Create(class std::basic_string,class std::allocator > const &,class std::basic_string,class std::allocator > const &,class std::basic_string,class std::allocator > const &,enum opentelemetry::v1::sdk::metrics::AggregationType) + ?Create@ViewFactory@metrics@sdk@v1@opentelemetry@@SA?AV?$unique_ptr@VView@metrics@sdk@v1@opentelemetry@@U?$default_delete@VView@metrics@sdk@v1@opentelemetry@@@std@@@std@@AEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@7@00W4AggregationType@2345@@Z + // public: static class std::unique_ptr > __cdecl opentelemetry::v1::sdk::metrics::MeterSelectorFactory::Create(class opentelemetry::v1::nostd::string_view,class opentelemetry::v1::nostd::string_view,class opentelemetry::v1::nostd::string_view) + ?Create@MeterSelectorFactory@metrics@sdk@v1@opentelemetry@@SA?AV?$unique_ptr@VMeterSelector@metrics@sdk@v1@opentelemetry@@U?$default_delete@VMeterSelector@metrics@sdk@v1@opentelemetry@@@std@@@std@@Vstring_view@nostd@45@00@Z + // public: static class std::unique_ptr > __cdecl opentelemetry::v1::sdk::metrics::InstrumentSelectorFactory::Create(enum opentelemetry::v1::sdk::metrics::InstrumentType,class opentelemetry::v1::nostd::string_view,class opentelemetry::v1::nostd::string_view) + ?Create@InstrumentSelectorFactory@metrics@sdk@v1@opentelemetry@@SA?AV?$unique_ptr@VInstrumentSelector@metrics@sdk@v1@opentelemetry@@U?$default_delete@VInstrumentSelector@metrics@sdk@v1@opentelemetry@@@std@@@std@@W4InstrumentType@2345@Vstring_view@nostd@45@1@Z + + // public: void __cdecl opentelemetry::v1::sdk::metrics::MeterContext::AddMetricReader(class std::shared_ptr) + ?AddMetricReader@MeterContext@metrics@sdk@v1@opentelemetry@@QEAAXV?$shared_ptr@VMetricReader@metrics@sdk@v1@opentelemetry@@@std@@@Z + // public: void __cdecl opentelemetry::v1::sdk::metrics::MeterProvider::AddMetricReader(class std::shared_ptr) + ?AddMetricReader@MeterProvider@metrics@sdk@v1@opentelemetry@@QEAAXV?$shared_ptr@VMetricReader@metrics@sdk@v1@opentelemetry@@@std@@@Z + // public: void __cdecl opentelemetry::v1::sdk::metrics::MeterProvider::AddView(class std::unique_ptr >,class std::unique_ptr >,class std::unique_ptr >) + ?AddView@MeterProvider@metrics@sdk@v1@opentelemetry@@QEAAXV?$unique_ptr@VInstrumentSelector@metrics@sdk@v1@opentelemetry@@U?$default_delete@VInstrumentSelector@metrics@sdk@v1@opentelemetry@@@std@@@std@@V?$unique_ptr@VMeterSelector@metrics@sdk@v1@opentelemetry@@U?$default_delete@VMeterSelector@metrics@sdk@v1@opentelemetry@@@std@@@7@V?$unique_ptr@VView@metrics@sdk@v1@opentelemetry@@U?$default_delete@VView@metrics@sdk@v1@opentelemetry@@@std@@@7@@Z + + #if defined(WITH_OTLP_GRPC) || defined(WITH_OTLP_HTTP) ?GetOtlpDefaultTracesTimeout@otlp@exporter@v1@opentelemetry@@YA?AV?$duration@_JU?$ratio@$00$0JIJGIA@@std@@@chrono@std@@XZ ?GetOtlpDefaultTracesHeaders@otlp@exporter@v1@opentelemetry@@YA?AV?$multimap@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V12@Ucmp_ic@otlp@exporter@v1@opentelemetry@@V?$allocator@U?$pair@$$CBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V12@@std@@@2@@std@@XZ ?GetOtlpDefaultLogsTimeout@otlp@exporter@v1@opentelemetry@@YA?AV?$duration@_JU?$ratio@$00$0JIJGIA@@std@@@chrono@std@@XZ ?GetOtlpDefaultLogsHeaders@otlp@exporter@v1@opentelemetry@@YA?AV?$multimap@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V12@Ucmp_ic@otlp@exporter@v1@opentelemetry@@V?$allocator@U?$pair@$$CBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V12@@std@@@2@@std@@XZ + ?GetOtlpDefaultMetricsTimeout@otlp@exporter@v1@opentelemetry@@YA?AV?$duration@_JU?$ratio@$00$0JIJGIA@@std@@@chrono@std@@XZ + ?GetOtlpDefaultMetricsHeaders@otlp@exporter@v1@opentelemetry@@YA?AV?$multimap@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V12@Ucmp_ic@otlp@exporter@v1@opentelemetry@@V?$allocator@U?$pair@$$CBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V12@@std@@@2@@std@@XZ #endif // defined(WITH_OTLP_GRPC) || defined(WITH_OTLP_HTTP) #if defined(WITH_OTLP_GRPC) // public: static class std::unique_ptr > __cdecl opentelemetry::v1::exporter::otlp::OtlpGrpcLogRecordExporterFactory::Create(struct opentelemetry::v1::exporter::otlp::OtlpGrpcExporterOptions const & __ptr64) ?Create@OtlpGrpcLogRecordExporterFactory@otlp@exporter@v1@opentelemetry@@SA?AV?$unique_ptr@VLogRecordExporter@logs@sdk@v1@opentelemetry@@U?$default_delete@VLogRecordExporter@logs@sdk@v1@opentelemetry@@@std@@@std@@AEBUOtlpGrpcExporterOptions@2345@@Z + // public: static class std::unique_ptr > __cdecl opentelemetry::v1::exporter::otlp::OtlpGrpcMetricExporterFactory::Create(struct opentelemetry::v1::exporter::otlp::OtlpGrpcMetricExporterOptions const & __ptr64) + ?Create@OtlpGrpcMetricExporterFactory@otlp@exporter@v1@opentelemetry@@SA?AV?$unique_ptr@VPushMetricExporter@metrics@sdk@v1@opentelemetry@@U?$default_delete@VPushMetricExporter@metrics@sdk@v1@opentelemetry@@@std@@@std@@AEBUOtlpGrpcMetricExporterOptions@2345@@Z + ?GetOtlpDefaultGrpcTracesEndpoint@otlp@exporter@v1@opentelemetry@@YA?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@XZ ?GetOtlpDefaultGrpcTracesIsInsecure@otlp@exporter@v1@opentelemetry@@YA_NXZ ?GetOtlpDefaultTracesSslCertificatePath@otlp@exporter@v1@opentelemetry@@YA?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@XZ @@ -76,5 +109,9 @@ EXPORTS ?Create@OtlpHttpLogRecordExporterFactory@otlp@exporter@v1@opentelemetry@@SA?AV?$unique_ptr@VLogRecordExporter@logs@sdk@v1@opentelemetry@@U?$default_delete@VLogRecordExporter@logs@sdk@v1@opentelemetry@@@std@@@std@@AEBUOtlpHttpLogRecordExporterOptions@2345@@Z ?GetOtlpDefaultHttpTracesEndpoint@otlp@exporter@v1@opentelemetry@@YA?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@XZ ?GetOtlpDefaultHttpLogsEndpoint@otlp@exporter@v1@opentelemetry@@YA?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@XZ + + // public: static class std::unique_ptr > __cdecl opentelemetry::v1::exporter::otlp::OtlpHttpMetricExporterFactory::Create(struct opentelemetry::v1::exporter::otlp::OtlpHttpMetricExporterOptions const &) + ?Create@OtlpHttpMetricExporterFactory@otlp@exporter@v1@opentelemetry@@SA?AV?$unique_ptr@VPushMetricExporter@metrics@sdk@v1@opentelemetry@@U?$default_delete@VPushMetricExporter@metrics@sdk@v1@opentelemetry@@@std@@@std@@AEBUOtlpHttpMetricExporterOptions@2345@@Z + ?GetOtlpDefaultHttpMetricsEndpoint@otlp@exporter@v1@opentelemetry@@YA?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@XZ #endif // defined(WITH_OTLP_HTTP) // clang-format on From 606aebb7baff9de8808e4ccaf502085e9cddaed6 Mon Sep 17 00:00:00 2001 From: Harish Shan <140232061+perhapsmaple@users.noreply.github.com> Date: Sat, 7 Oct 2023 22:37:31 +0530 Subject: [PATCH 4/7] Build Metrics into DLL Signed-off-by: Harish Shan <140232061+perhapsmaple@users.noreply.github.com> --- .../common/metrics_foo_library/CMakeLists.txt | 8 +++++- examples/metrics_simple/CMakeLists.txt | 18 +++++++++--- examples/otlp/CMakeLists.txt | 28 +++++++++++++------ 3 files changed, 41 insertions(+), 13 deletions(-) diff --git a/examples/common/metrics_foo_library/CMakeLists.txt b/examples/common/metrics_foo_library/CMakeLists.txt index a91b2595b8..8f1435d641 100644 --- a/examples/common/metrics_foo_library/CMakeLists.txt +++ b/examples/common/metrics_foo_library/CMakeLists.txt @@ -1,6 +1,12 @@ # Copyright The OpenTelemetry Authors # SPDX-License-Identifier: Apache-2.0 +if(DEFINED OPENTELEMETRY_BUILD_DLL) + add_definitions(-DOPENTELEMETRY_BUILD_IMPORT_DLL) +endif() + add_library(common_metrics_foo_library foo_library.h foo_library.cc) set_target_version(common_metrics_foo_library) -target_link_libraries(common_metrics_foo_library PUBLIC opentelemetry_api) + +target_link_libraries(common_metrics_foo_library PUBLIC ${CMAKE_THREAD_LIBS_INIT} + opentelemetry_api) diff --git a/examples/metrics_simple/CMakeLists.txt b/examples/metrics_simple/CMakeLists.txt index 2018ed808c..d0f09dfd42 100644 --- a/examples/metrics_simple/CMakeLists.txt +++ b/examples/metrics_simple/CMakeLists.txt @@ -1,9 +1,19 @@ # Copyright The OpenTelemetry Authors # SPDX-License-Identifier: Apache-2.0 +if(DEFINED OPENTELEMETRY_BUILD_DLL) + add_definitions(-DOPENTELEMETRY_BUILD_IMPORT_DLL) +endif() + include_directories(${CMAKE_SOURCE_DIR}/exporters/ostream/include) + 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) +target_link_libraries(metrics_ostream_example ${CMAKE_THREAD_LIBS_INIT} + common_metrics_foo_library) + +if(DEFINED OPENTELEMETRY_BUILD_DLL) + target_link_libraries(metrics_ostream_example opentelemetry_cpp) +else() + target_link_libraries(metrics_ostream_example opentelemetry_metrics + opentelemetry_exporter_ostream_metrics opentelemetry_resources) +endif() diff --git a/examples/otlp/CMakeLists.txt b/examples/otlp/CMakeLists.txt index 398300ab36..5d051a52cc 100644 --- a/examples/otlp/CMakeLists.txt +++ b/examples/otlp/CMakeLists.txt @@ -28,10 +28,15 @@ if(WITH_OTLP_GRPC) add_executable(example_otlp_grpc_metric grpc_metric_main.cc) - target_link_libraries( - example_otlp_grpc_metric ${CMAKE_THREAD_LIBS_INIT} - common_metrics_foo_library opentelemetry_metrics - opentelemetry_exporter_otlp_grpc_metrics) + target_link_libraries(example_otlp_grpc_metric ${CMAKE_THREAD_LIBS_INIT} + common_metrics_foo_library) + + if(DEFINED OPENTELEMETRY_BUILD_DLL) + target_link_libraries(example_otlp_grpc_metric opentelemetry_cpp) + else() + target_link_libraries(example_otlp_grpc_metric opentelemetry_metrics + opentelemetry_exporter_otlp_grpc_metrics) + endif() # LOG @@ -66,10 +71,17 @@ if(WITH_OTLP_HTTP) # METRIC add_executable(example_otlp_http_metric http_metric_main.cc) - target_link_libraries( - example_otlp_http_metric ${CMAKE_THREAD_LIBS_INIT} - common_metrics_foo_library opentelemetry_metrics - opentelemetry_exporter_otlp_http_metric) + target_link_libraries(example_otlp_http_metric ${CMAKE_THREAD_LIBS_INIT} + common_metrics_foo_library) + + if(DEFINED OPENTELEMETRY_BUILD_DLL) + target_link_libraries(example_otlp_http_metric opentelemetry_cpp + opentelemetry_common) + else() + target_link_libraries( + example_otlp_http_metric common_metrics_foo_library opentelemetry_metrics + opentelemetry_exporter_otlp_http_metric) + endif() # LOG From d7c51ef7787165995afde39a5ea64812138f5887 Mon Sep 17 00:00:00 2001 From: Harish Shan <140232061+perhapsmaple@users.noreply.github.com> Date: Tue, 10 Oct 2023 01:17:50 +0530 Subject: [PATCH 5/7] Fix formatting Signed-off-by: Harish Shan <140232061+perhapsmaple@users.noreply.github.com> --- examples/common/metrics_foo_library/CMakeLists.txt | 4 ++-- examples/metrics_simple/CMakeLists.txt | 5 +++-- ext/src/dll/opentelemetry_cpp.src | 2 +- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/examples/common/metrics_foo_library/CMakeLists.txt b/examples/common/metrics_foo_library/CMakeLists.txt index 8f1435d641..abda93c3e6 100644 --- a/examples/common/metrics_foo_library/CMakeLists.txt +++ b/examples/common/metrics_foo_library/CMakeLists.txt @@ -8,5 +8,5 @@ endif() add_library(common_metrics_foo_library foo_library.h foo_library.cc) set_target_version(common_metrics_foo_library) -target_link_libraries(common_metrics_foo_library PUBLIC ${CMAKE_THREAD_LIBS_INIT} - opentelemetry_api) +target_link_libraries(common_metrics_foo_library + PUBLIC ${CMAKE_THREAD_LIBS_INIT} opentelemetry_api) diff --git a/examples/metrics_simple/CMakeLists.txt b/examples/metrics_simple/CMakeLists.txt index d0f09dfd42..0fc8c24621 100644 --- a/examples/metrics_simple/CMakeLists.txt +++ b/examples/metrics_simple/CMakeLists.txt @@ -14,6 +14,7 @@ target_link_libraries(metrics_ostream_example ${CMAKE_THREAD_LIBS_INIT} if(DEFINED OPENTELEMETRY_BUILD_DLL) target_link_libraries(metrics_ostream_example opentelemetry_cpp) else() - target_link_libraries(metrics_ostream_example opentelemetry_metrics - opentelemetry_exporter_ostream_metrics opentelemetry_resources) + target_link_libraries( + metrics_ostream_example opentelemetry_metrics + opentelemetry_exporter_ostream_metrics opentelemetry_resources) endif() diff --git a/ext/src/dll/opentelemetry_cpp.src b/ext/src/dll/opentelemetry_cpp.src index 0ff375ace8..49226ec543 100644 --- a/ext/src/dll/opentelemetry_cpp.src +++ b/ext/src/dll/opentelemetry_cpp.src @@ -98,7 +98,7 @@ EXPORTS ?Create@OtlpGrpcLogRecordExporterFactory@otlp@exporter@v1@opentelemetry@@SA?AV?$unique_ptr@VLogRecordExporter@logs@sdk@v1@opentelemetry@@U?$default_delete@VLogRecordExporter@logs@sdk@v1@opentelemetry@@@std@@@std@@AEBUOtlpGrpcExporterOptions@2345@@Z // public: static class std::unique_ptr > __cdecl opentelemetry::v1::exporter::otlp::OtlpGrpcMetricExporterFactory::Create(struct opentelemetry::v1::exporter::otlp::OtlpGrpcMetricExporterOptions const & __ptr64) ?Create@OtlpGrpcMetricExporterFactory@otlp@exporter@v1@opentelemetry@@SA?AV?$unique_ptr@VPushMetricExporter@metrics@sdk@v1@opentelemetry@@U?$default_delete@VPushMetricExporter@metrics@sdk@v1@opentelemetry@@@std@@@std@@AEBUOtlpGrpcMetricExporterOptions@2345@@Z - + ?GetOtlpDefaultGrpcTracesEndpoint@otlp@exporter@v1@opentelemetry@@YA?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@XZ ?GetOtlpDefaultGrpcTracesIsInsecure@otlp@exporter@v1@opentelemetry@@YA_NXZ ?GetOtlpDefaultTracesSslCertificatePath@otlp@exporter@v1@opentelemetry@@YA?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@XZ From 26b2207e709395de31edbefee0969f22f20fc277 Mon Sep 17 00:00:00 2001 From: Harish Shan <140232061+perhapsmaple@users.noreply.github.com> Date: Tue, 17 Oct 2023 07:08:01 +0530 Subject: [PATCH 6/7] Fix CMakeLists Signed-off-by: Harish Shan <140232061+perhapsmaple@users.noreply.github.com> --- ext/src/dll/CMakeLists.txt | 2 -- 1 file changed, 2 deletions(-) diff --git a/ext/src/dll/CMakeLists.txt b/ext/src/dll/CMakeLists.txt index 109000ea3e..687d55e01f 100644 --- a/ext/src/dll/CMakeLists.txt +++ b/ext/src/dll/CMakeLists.txt @@ -27,13 +27,11 @@ target_link_libraries( opentelemetry_exporter_ostream_metrics) if(WITH_OTLP_GRPC) - add_compile_definitions(WITH_OTLP_GRPC) target_link_libraries(opentelemetry_cpp PRIVATE opentelemetry_exporter_otlp_grpc_metrics) endif() if(WITH_OTLP_HTTP) - add_compile_definitions(WITH_OTLP_HTTP) target_link_libraries(opentelemetry_cpp PRIVATE opentelemetry_exporter_otlp_http_metric) endif() From b1c44484f8f306b91e2a65c536e052129a37e2e8 Mon Sep 17 00:00:00 2001 From: Harish Shan <140232061+perhapsmaple@users.noreply.github.com> Date: Wed, 18 Oct 2023 20:48:47 +0530 Subject: [PATCH 7/7] Add Metrics and Logs Tests to CI Signed-off-by: Harish Shan <140232061+perhapsmaple@users.noreply.github.com> --- ci/do_ci.ps1 | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/ci/do_ci.ps1 b/ci/do_ci.ps1 index e55cf8e536..b97617e96f 100644 --- a/ci/do_ci.ps1 +++ b/ci/do_ci.ps1 @@ -58,7 +58,7 @@ switch ($action) { cmake $SRC_DIR ` -DVCPKG_TARGET_TRIPLET=x64-windows ` -DOPENTELEMETRY_BUILD_DLL=1 ` - "-DCMAKE_TOOLCHAIN_FILE=$VCPKG_DIR/scripts/buildsystems/vcpkg.cmake" + "-DCMAKE_TOOLCHAIN_FILE=$VCPKG_DIR/scripts/buildsystems/vcpkg.cmake" $exit = $LASTEXITCODE if ($exit -ne 0) { exit $exit @@ -79,6 +79,16 @@ switch ($action) { if ($exit -ne 0) { exit $exit } + examples\metrics_simple\Debug\metrics_ostream_example.exe + $exit = $LASTEXITCODE + if ($exit -ne 0) { + exit $exit + } + examples\logs_simple\Debug\example_logs_simple.exe + $exit = $LASTEXITCODE + if ($exit -ne 0) { + exit $exit + } } "cmake.maintainer.test" { cd "$BUILD_DIR"