From 2566fb62f35454060dd54c7e10854a91d042e8cd Mon Sep 17 00:00:00 2001 From: Doug Barker Date: Mon, 24 Mar 2025 03:02:42 -0600 Subject: [PATCH 1/2] [EXPORTER] fix test failure with elasticsearch exporter on cxx20 (#3308) --- exporters/elasticsearch/src/es_log_recordable.cc | 7 ------- 1 file changed, 7 deletions(-) diff --git a/exporters/elasticsearch/src/es_log_recordable.cc b/exporters/elasticsearch/src/es_log_recordable.cc index 39979a26fd..7376a9c78a 100644 --- a/exporters/elasticsearch/src/es_log_recordable.cc +++ b/exporters/elasticsearch/src/es_log_recordable.cc @@ -88,12 +88,6 @@ void ElasticSearchRecordable::SetTimestamp( { const std::chrono::system_clock::time_point timePoint{timestamp}; - // If built with with at least cpp 20 then use std::format - // Otherwise use the old style to format the timestamp in UTC - // @see https://en.cppreference.com/w/cpp/feature_test#cpp_lib_format -#if defined(__cpp_lib_format) && __cpp_lib_format >= 201907 - const std::string dateStr = std::format("{:%FT%T%Ez}", timePoint); -#else std::time_t time = std::chrono::system_clock::to_time_t(timePoint); std::tm tm = *std::gmtime(&time); auto microseconds = @@ -108,7 +102,6 @@ void ElasticSearchRecordable::SetTimestamp( static_cast(microseconds.count())); const std::string dateStr(bufferDate); -#endif json_["@timestamp"] = dateStr; } From 4af490ffeddeb37e754b30cc4b55d3ada69ca5a6 Mon Sep 17 00:00:00 2001 From: Doug Barker Date: Mon, 24 Mar 2025 05:08:35 -0600 Subject: [PATCH 2/2] [TEST] otlp grpc exporter retry test fix (#3311) --- exporters/otlp/test/otlp_grpc_exporter_test.cc | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/exporters/otlp/test/otlp_grpc_exporter_test.cc b/exporters/otlp/test/otlp_grpc_exporter_test.cc index b57dc6604f..365d98cecd 100644 --- a/exporters/otlp/test/otlp_grpc_exporter_test.cc +++ b/exporters/otlp/test/otlp_grpc_exporter_test.cc @@ -37,6 +37,7 @@ # include # include +# include # if defined(_MSC_VER) # include "opentelemetry/sdk/common/env_variables.h" @@ -510,15 +511,21 @@ TEST_P(OtlpGrpcExporterRetryIntegrationTests, StatusCodes) TestTraceService service(status_codes); std::unique_ptr server; - std::thread server_thread([&server, &service]() { + std::promise server_ready; + auto server_ready_future = server_ready.get_future(); + + std::thread server_thread([&server, &service, &server_ready]() { std::string address("localhost:4317"); grpc::ServerBuilder builder; builder.RegisterService(&service); builder.AddListeningPort(address, grpc::InsecureServerCredentials()); server = builder.BuildAndStart(); + server_ready.set_value(); server->Wait(); }); + server_ready_future.wait(); + otlp::OtlpGrpcExporterOptions opts{}; if (is_retry_enabled)