From 78ccc23f307a814e04d1d23c803400cef905ce4d Mon Sep 17 00:00:00 2001 From: mishal23 Date: Mon, 26 Oct 2020 14:53:50 +0530 Subject: [PATCH] etw exporter headers added --- .../opentelemetry/common/key_value_iterable.h | 16 +++++ .../opentelemetry/trace/key_value_iterable.h | 51 --------------- .../trace/key_value_iterable_view.h | 65 ------------------- .../exporters/etw/etw_tracer_exporter.h | 12 ++-- 4 files changed, 22 insertions(+), 122 deletions(-) delete mode 100644 api/include/opentelemetry/trace/key_value_iterable.h delete mode 100644 api/include/opentelemetry/trace/key_value_iterable_view.h diff --git a/api/include/opentelemetry/common/key_value_iterable.h b/api/include/opentelemetry/common/key_value_iterable.h index f4e4a92bc3..9e950a489f 100644 --- a/api/include/opentelemetry/common/key_value_iterable.h +++ b/api/include/opentelemetry/common/key_value_iterable.h @@ -30,5 +30,21 @@ class KeyValueIterable */ virtual size_t size() const noexcept = 0; }; + +// +// NULL object pattern empty iterable. +// +class NullKeyValueIterable : public KeyValueIterable +{ +public: + NullKeyValueIterable(){}; + virtual bool ForEachKeyValue( + nostd::function_ref) const noexcept + { + return true; + }; + virtual size_t size() const noexcept { return 0; } +}; + } // namespace common OPENTELEMETRY_END_NAMESPACE diff --git a/api/include/opentelemetry/trace/key_value_iterable.h b/api/include/opentelemetry/trace/key_value_iterable.h deleted file mode 100644 index 94caf64749..0000000000 --- a/api/include/opentelemetry/trace/key_value_iterable.h +++ /dev/null @@ -1,51 +0,0 @@ -#pragma once - -#include "opentelemetry/common/attribute_value.h" -#include "opentelemetry/nostd/function_ref.h" -#include "opentelemetry/version.h" - -OPENTELEMETRY_BEGIN_NAMESPACE -namespace trace -{ -/** - * Supports internal iteration over a collection of key-value pairs. - */ -class KeyValueIterable -{ -public: - virtual ~KeyValueIterable() = default; - - /** - * Iterate over key-value pairs - * @param callback a callback to invoke for each key-value. If the callback returns false, - * the iteration is aborted. - * @return true if every key-value pair was iterated over - */ - virtual bool ForEachKeyValue(nostd::function_ref - callback) const noexcept = 0; - - /** - * @return the number of key-value pairs - */ - virtual size_t size() const noexcept = 0; -}; - -// -// NULL object pattern empty iterable. -// -class NullKeyValueIterable : public KeyValueIterable -{ -public: - NullKeyValueIterable(){}; - - virtual bool ForEachKeyValue( - nostd::function_ref) const noexcept - { - return true; - }; - - virtual size_t size() const noexcept { return 0; } -}; - -} // namespace trace -OPENTELEMETRY_END_NAMESPACE \ No newline at end of file diff --git a/api/include/opentelemetry/trace/key_value_iterable_view.h b/api/include/opentelemetry/trace/key_value_iterable_view.h deleted file mode 100644 index 0f2eced602..0000000000 --- a/api/include/opentelemetry/trace/key_value_iterable_view.h +++ /dev/null @@ -1,65 +0,0 @@ -#pragma once - -#include -#include -#include - -#include "opentelemetry/nostd/utility.h" -#include "opentelemetry/trace/key_value_iterable.h" -#include "opentelemetry/version.h" - -OPENTELEMETRY_BEGIN_NAMESPACE -namespace trace -{ -namespace detail -{ -inline void take_key_value(nostd::string_view, common::AttributeValue) {} - -template -auto is_key_value_iterable_impl(T iterable) - -> decltype(take_key_value(std::begin(iterable)->first, std::begin(iterable)->second), - nostd::size(iterable), - std::true_type{}); - -std::false_type is_key_value_iterable_impl(...); - -template -struct is_key_value_iterable -{ - static const bool value = decltype(detail::is_key_value_iterable_impl(std::declval()))::value; -}; -} // namespace detail - -template -class KeyValueIterableView final : public KeyValueIterable -{ -#if 0 // TODO: [MG] - confirm if we really need this - static_assert(detail::is_key_value_iterable::value, "Must be a key-value iterable"); -#endif - -public: - explicit KeyValueIterableView(const T &container) noexcept : container_{&container} {}; - - // KeyValueIterable - bool ForEachKeyValue(nostd::function_ref - callback) const noexcept override - { - auto iter = std::begin(*container_); - auto last = std::end(*container_); - for (; iter != last; ++iter) - { - if (!callback(iter->first, iter->second)) - { - return false; - } - } - return true; - } - - size_t size() const noexcept override { return nostd::size(*container_); } - -private: - const T *container_; -}; -} // namespace trace -OPENTELEMETRY_END_NAMESPACE \ No newline at end of file diff --git a/exporters/etw/include/opentelemetry/exporters/etw/etw_tracer_exporter.h b/exporters/etw/include/opentelemetry/exporters/etw/etw_tracer_exporter.h index 7db1af321d..daee93f70d 100644 --- a/exporters/etw/include/opentelemetry/exporters/etw/etw_tracer_exporter.h +++ b/exporters/etw/include/opentelemetry/exporters/etw/etw_tracer_exporter.h @@ -23,7 +23,7 @@ #include #include -#include +#include #include #include #include @@ -115,7 +115,7 @@ class Tracer : public trace::Tracer /// Span virtual nostd::shared_ptr StartSpan( nostd::string_view name, - const trace::KeyValueIterable &attributes, + const common::KeyValueIterable &attributes, const trace::StartSpanOptions &options = {}) noexcept override { // TODO: support attributes @@ -151,7 +151,7 @@ class Tracer : public trace::Tracer void AddEvent(Span &span, nostd::string_view name, core::SystemTimestamp timestamp, - const trace::KeyValueIterable &attributes) noexcept + const common::KeyValueIterable &attributes) noexcept { // TODO: associate events with span (void)span; @@ -192,7 +192,7 @@ class Tracer : public trace::Tracer /// void AddEvent(Span &span, nostd::string_view name, core::SystemTimestamp timestamp) noexcept { - AddEvent(span, name, timestamp, trace::NullKeyValueIterable()); + AddEvent(span, name, timestamp, common::NullKeyValueIterable()); }; /// @@ -202,7 +202,7 @@ class Tracer : public trace::Tracer /// void AddEvent(Span &span, nostd::string_view name) { - AddEvent(span, name, std::chrono::system_clock::now(), trace::NullKeyValueIterable()); + AddEvent(span, name, std::chrono::system_clock::now(), common::NullKeyValueIterable()); }; virtual ~Tracer() { CloseWithMicroseconds(0); }; @@ -264,7 +264,7 @@ class Span : public trace::Span /// void AddEvent(nostd::string_view name, core::SystemTimestamp timestamp, - const trace::KeyValueIterable &attributes) noexcept override + const common::KeyValueIterable &attributes) noexcept override { owner.AddEvent(*this, name, timestamp, attributes); }