From f69963f587b148d2eb20f7d30f8b4a1ccb184a6f Mon Sep 17 00:00:00 2001 From: WenTao Ou Date: Sun, 13 Oct 2024 23:18:22 +0800 Subject: [PATCH 1/4] Update bzlmod version (#3093) --- MODULE.bazel | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MODULE.bazel b/MODULE.bazel index 13175f2c21..a9171d7424 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -3,7 +3,7 @@ module( name = "opentelemetry-cpp", - version = "1.16.1", + version = "1.17.0", compatibility_level = 0, repo_name = "io_opentelemetry_cpp", ) From 70ed9bcac0739eb3981c5b8d71f1ab23bc279701 Mon Sep 17 00:00:00 2001 From: WenTao Ou Date: Wed, 16 Oct 2024 17:21:59 +0800 Subject: [PATCH 2/4] [BUILD] Remove std::make_unique (#3098) --- exporters/memory/src/in_memory_metric_exporter_factory.cc | 4 ++-- exporters/memory/test/in_memory_metric_data_test.cc | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/exporters/memory/src/in_memory_metric_exporter_factory.cc b/exporters/memory/src/in_memory_metric_exporter_factory.cc index f2577c4e9b..7f6ab83346 100644 --- a/exporters/memory/src/in_memory_metric_exporter_factory.cc +++ b/exporters/memory/src/in_memory_metric_exporter_factory.cc @@ -49,7 +49,7 @@ class InMemoryMetricExporter final : public sdk::metrics::PushMetricExporter OTEL_INTERNAL_LOG_ERROR("[In Memory Metric Exporter] Exporting failed, exporter is shutdown"); return ExportResult::kFailure; } - data_->Add(std::make_unique(data)); + data_->Add(std::unique_ptr(new ResourceMetrics{data})); return ExportResult::kSuccess; } @@ -85,7 +85,7 @@ std::unique_ptr InMemoryMetricExporterFactory::Create( const std::shared_ptr &data, const AggregationTemporalitySelector &temporality) { - return std::make_unique(data, temporality); + return std::unique_ptr(new InMemoryMetricExporter{data, temporality}); } } // namespace memory diff --git a/exporters/memory/test/in_memory_metric_data_test.cc b/exporters/memory/test/in_memory_metric_data_test.cc index ffaba2cfb9..3f2d661759 100644 --- a/exporters/memory/test/in_memory_metric_data_test.cc +++ b/exporters/memory/test/in_memory_metric_data_test.cc @@ -23,8 +23,8 @@ TEST(InMemoryMetricDataTest, CircularBuffer) { CircularBufferInMemoryMetricData buf(10); Resource resource = Resource::GetEmpty(); - buf.Add(std::make_unique( - &resource, std::vector{{nullptr, std::vector{}}})); + buf.Add(std::unique_ptr(new ResourceMetrics{ + &resource, std::vector{{nullptr, std::vector{}}}})); EXPECT_EQ((*buf.Get().begin())->resource_, &resource); } @@ -45,8 +45,8 @@ TEST(InMemoryMetricDataTest, SimpleAggregate) md.instrument_descriptor.name_ = "my-metric"; md.point_data_attr_.push_back(pda); - agg.Add(std::make_unique( - &resource, std::vector{{scope.get(), std::vector{md}}})); + agg.Add(std::unique_ptr(new ResourceMetrics{ + &resource, std::vector{{scope.get(), std::vector{md}}}})); auto it = agg.Get("my-scope", "my-metric").begin(); auto saved_point = opentelemetry::nostd::get(it->second); From 63683c1596484161c085ff642cb0e34b7bdf2bfb Mon Sep 17 00:00:00 2001 From: WenTao Ou Date: Thu, 17 Oct 2024 15:57:10 +0800 Subject: [PATCH 3/4] [BUILD] Fix compiling problems for gcc 4.8 (#3100) * Fix compiling problems for gcc 4.8 * Apply suggestions from code review --------- Co-authored-by: Marc Alff --- exporters/memory/src/in_memory_metric_data.cc | 7 +++++-- exporters/memory/src/in_memory_metric_exporter_factory.cc | 3 ++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/exporters/memory/src/in_memory_metric_data.cc b/exporters/memory/src/in_memory_metric_data.cc index 2a77e0b5a3..90f1c1450f 100644 --- a/exporters/memory/src/in_memory_metric_data.cc +++ b/exporters/memory/src/in_memory_metric_data.cc @@ -31,7 +31,9 @@ void SimpleAggregateInMemoryMetricData::Add(std::unique_ptr res const auto &metric = m.instrument_descriptor.name_; for (const auto &pda : m.point_data_attr_) { - data_[{scope, metric}].insert({pda.attributes, pda.point_data}); + // NOTE: Explicit type conversion added for C++11 (gcc 4.8) + data_[std::tuple{scope, metric}].insert( + {pda.attributes, pda.point_data}); } } } @@ -41,7 +43,8 @@ const SimpleAggregateInMemoryMetricData::AttributeToPoint &SimpleAggregateInMemo const std::string &scope, const std::string &metric) { - return data_[{scope, metric}]; + // NOTE: Explicit type conversion added for C++11 (gcc 4.8) + return data_[std::tuple{scope, metric}]; } void SimpleAggregateInMemoryMetricData::Clear() diff --git a/exporters/memory/src/in_memory_metric_exporter_factory.cc b/exporters/memory/src/in_memory_metric_exporter_factory.cc index 7f6ab83346..0deff73dcd 100644 --- a/exporters/memory/src/in_memory_metric_exporter_factory.cc +++ b/exporters/memory/src/in_memory_metric_exporter_factory.cc @@ -78,7 +78,8 @@ class InMemoryMetricExporter final : public sdk::metrics::PushMetricExporter std::unique_ptr InMemoryMetricExporterFactory::Create( const std::shared_ptr &data) { - return Create(data, [](auto) { return AggregationTemporality::kCumulative; }); + return Create(data, + [](sdk::metrics::InstrumentType) { return AggregationTemporality::kCumulative; }); } std::unique_ptr InMemoryMetricExporterFactory::Create( From 1185405c46290175127f279193a71e2d4f68f7ce Mon Sep 17 00:00:00 2001 From: WenTao Ou Date: Fri, 18 Oct 2024 18:20:42 +0800 Subject: [PATCH 4/4] [TEST] Fix linking order and gmock linking (#3106) * Fix link order * Fix gmock linking --- ext/test/http/CMakeLists.txt | 6 +++--- test_common/src/http/client/nosend/CMakeLists.txt | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/ext/test/http/CMakeLists.txt b/ext/test/http/CMakeLists.txt index 328f78638b..9f5514d07b 100644 --- a/ext/test/http/CMakeLists.txt +++ b/ext/test/http/CMakeLists.txt @@ -5,7 +5,7 @@ if(WITH_HTTP_CLIENT_CURL) set(FILENAME curl_http_test) add_compile_definitions(WITH_CURL) add_executable(${FILENAME} ${FILENAME}.cc) - target_link_libraries(${FILENAME} ${GTEST_BOTH_LIBRARIES} + target_link_libraries(${FILENAME} ${GMOCK_LIB} ${GTEST_BOTH_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT}) if(TARGET CURL::libcurl) @@ -24,8 +24,8 @@ endif() set(URL_PARSER_FILENAME url_parser_test) add_executable(${URL_PARSER_FILENAME} ${URL_PARSER_FILENAME}.cc) -target_link_libraries(${URL_PARSER_FILENAME} ${GTEST_BOTH_LIBRARIES} - ${CMAKE_THREAD_LIBS_INIT} opentelemetry_api) +target_link_libraries(${URL_PARSER_FILENAME} opentelemetry_api ${GMOCK_LIB} + ${GTEST_BOTH_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT}) gtest_add_tests( TARGET ${URL_PARSER_FILENAME} TEST_PREFIX ext.http.urlparser. diff --git a/test_common/src/http/client/nosend/CMakeLists.txt b/test_common/src/http/client/nosend/CMakeLists.txt index 92a2c1f98c..7394053a22 100644 --- a/test_common/src/http/client/nosend/CMakeLists.txt +++ b/test_common/src/http/client/nosend/CMakeLists.txt @@ -28,7 +28,7 @@ if(${BUILD_TESTING}) endif() target_link_libraries( - opentelemetry_http_client_nosend ${GTEST_BOTH_LIBRARIES} opentelemetry_ext - opentelemetry_test_common) + opentelemetry_http_client_nosend opentelemetry_ext + opentelemetry_test_common ${GMOCK_LIB} ${GTEST_BOTH_LIBRARIES}) endif()