From 48678dee404c751c437ea3ffed7885e9eb002ef9 Mon Sep 17 00:00:00 2001 From: Albert Kharisov Date: Wed, 20 Nov 2024 19:31:13 +0400 Subject: [PATCH 1/5] [BUILD] Fix build for esp32 Fix for toolchains that alias int32_t as long int and in this way confuse all the honest people. --- sdk/include/opentelemetry/sdk/common/empty_attributes.h | 6 +++--- sdk/include/opentelemetry/sdk/trace/span_data.h | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/sdk/include/opentelemetry/sdk/common/empty_attributes.h b/sdk/include/opentelemetry/sdk/common/empty_attributes.h index 0afe439ee6..4a699e7d32 100644 --- a/sdk/include/opentelemetry/sdk/common/empty_attributes.h +++ b/sdk/include/opentelemetry/sdk/common/empty_attributes.h @@ -21,12 +21,12 @@ namespace sdk * with default attributes. */ static const opentelemetry::common::KeyValueIterableView< - std::array, 0>> & + std::array, 0>> & GetEmptyAttributes() noexcept { - static const std::array, 0> array{}; + static const std::array, 0> array{}; static const opentelemetry::common::KeyValueIterableView< - std::array, 0>> + std::array, 0>> kEmptyAttributes(array); return kEmptyAttributes; diff --git a/sdk/include/opentelemetry/sdk/trace/span_data.h b/sdk/include/opentelemetry/sdk/trace/span_data.h index 2bd8b2112b..96b8e5deee 100644 --- a/sdk/include/opentelemetry/sdk/trace/span_data.h +++ b/sdk/include/opentelemetry/sdk/trace/span_data.h @@ -257,7 +257,7 @@ class SpanData final : public Recordable opentelemetry::common::SystemTimestamp timestamp = opentelemetry::common::SystemTimestamp(std::chrono::system_clock::now()), const opentelemetry::common::KeyValueIterable &attributes = - opentelemetry::common::KeyValueIterableView>( + opentelemetry::common::KeyValueIterableView>( {})) noexcept override { SpanDataEvent event(std::string(name), timestamp, attributes); From 444d86926a7d3b3a2dfde00ef81167dc0217aa5f Mon Sep 17 00:00:00 2001 From: Albert Kharisov Date: Sun, 24 Nov 2024 12:56:59 +0400 Subject: [PATCH 2/5] Remove unused default params --- sdk/include/opentelemetry/sdk/trace/span_data.h | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/sdk/include/opentelemetry/sdk/trace/span_data.h b/sdk/include/opentelemetry/sdk/trace/span_data.h index 96b8e5deee..09e17284d9 100644 --- a/sdk/include/opentelemetry/sdk/trace/span_data.h +++ b/sdk/include/opentelemetry/sdk/trace/span_data.h @@ -254,11 +254,8 @@ class SpanData final : public Recordable } void AddEvent(nostd::string_view name, - opentelemetry::common::SystemTimestamp timestamp = - opentelemetry::common::SystemTimestamp(std::chrono::system_clock::now()), - const opentelemetry::common::KeyValueIterable &attributes = - opentelemetry::common::KeyValueIterableView>( - {})) noexcept override + opentelemetry::common::SystemTimestamp timestamp, + const opentelemetry::common::KeyValueIterable &attributes) noexcept override { SpanDataEvent event(std::string(name), timestamp, attributes); events_.push_back(event); From d160f8a5a8c46a0ff7c1f9998690eff8bd038276 Mon Sep 17 00:00:00 2001 From: Albert Kharisov Date: Sun, 24 Nov 2024 18:12:27 +0400 Subject: [PATCH 3/5] Fix broken test --- sdk/test/trace/span_data_test.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sdk/test/trace/span_data_test.cc b/sdk/test/trace/span_data_test.cc index 054af65330..6ad0b37341 100644 --- a/sdk/test/trace/span_data_test.cc +++ b/sdk/test/trace/span_data_test.cc @@ -69,7 +69,8 @@ TEST(SpanData, Set) data.SetStartTime(now); data.SetDuration(std::chrono::nanoseconds(1000000)); data.SetAttribute("attr1", static_cast(314159)); - data.AddEvent("event1", now); + data.AddEvent("event1", now, + opentelemetry::common::KeyValueIterableView>({})); ASSERT_EQ(data.GetTraceId(), trace_id); ASSERT_EQ(data.GetSpanId(), span_id); From 9db948dcb9781c75d5a72488bf1a155561f95d56 Mon Sep 17 00:00:00 2001 From: Marc Alff Date: Sun, 24 Nov 2024 21:09:42 +0100 Subject: [PATCH 4/5] Apply suggestions from code review --- sdk/include/opentelemetry/sdk/trace/span_data.h | 6 ++++-- sdk/test/trace/span_data_test.cc | 3 +-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/sdk/include/opentelemetry/sdk/trace/span_data.h b/sdk/include/opentelemetry/sdk/trace/span_data.h index 09e17284d9..98f66f7286 100644 --- a/sdk/include/opentelemetry/sdk/trace/span_data.h +++ b/sdk/include/opentelemetry/sdk/trace/span_data.h @@ -254,8 +254,10 @@ class SpanData final : public Recordable } void AddEvent(nostd::string_view name, - opentelemetry::common::SystemTimestamp timestamp, - const opentelemetry::common::KeyValueIterable &attributes) noexcept override + opentelemetry::common::SystemTimestamp timestamp = + opentelemetry::common::SystemTimestamp(std::chrono::system_clock::now()), + const opentelemetry::common::KeyValueIterable &attributes = + opentelemetry::common::KeyValueIterableView>) noexcept override { SpanDataEvent event(std::string(name), timestamp, attributes); events_.push_back(event); diff --git a/sdk/test/trace/span_data_test.cc b/sdk/test/trace/span_data_test.cc index 6ad0b37341..054af65330 100644 --- a/sdk/test/trace/span_data_test.cc +++ b/sdk/test/trace/span_data_test.cc @@ -69,8 +69,7 @@ TEST(SpanData, Set) data.SetStartTime(now); data.SetDuration(std::chrono::nanoseconds(1000000)); data.SetAttribute("attr1", static_cast(314159)); - data.AddEvent("event1", now, - opentelemetry::common::KeyValueIterableView>({})); + data.AddEvent("event1", now); ASSERT_EQ(data.GetTraceId(), trace_id); ASSERT_EQ(data.GetSpanId(), span_id); From 851da955424e241d895d6030b6646a45aaedb2e6 Mon Sep 17 00:00:00 2001 From: Marc Alff Date: Sun, 24 Nov 2024 21:11:44 +0100 Subject: [PATCH 5/5] Update sdk/include/opentelemetry/sdk/trace/span_data.h --- sdk/include/opentelemetry/sdk/trace/span_data.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sdk/include/opentelemetry/sdk/trace/span_data.h b/sdk/include/opentelemetry/sdk/trace/span_data.h index 98f66f7286..96b8e5deee 100644 --- a/sdk/include/opentelemetry/sdk/trace/span_data.h +++ b/sdk/include/opentelemetry/sdk/trace/span_data.h @@ -257,7 +257,8 @@ class SpanData final : public Recordable opentelemetry::common::SystemTimestamp timestamp = opentelemetry::common::SystemTimestamp(std::chrono::system_clock::now()), const opentelemetry::common::KeyValueIterable &attributes = - opentelemetry::common::KeyValueIterableView>) noexcept override + opentelemetry::common::KeyValueIterableView>( + {})) noexcept override { SpanDataEvent event(std::string(name), timestamp, attributes); events_.push_back(event);