diff --git a/api/include/opentelemetry/trace/key_value_iterable.h b/api/include/opentelemetry/common/key_value_iterable.h similarity index 95% rename from api/include/opentelemetry/trace/key_value_iterable.h rename to api/include/opentelemetry/common/key_value_iterable.h index 8b1f2e1124..f4e4a92bc3 100644 --- a/api/include/opentelemetry/trace/key_value_iterable.h +++ b/api/include/opentelemetry/common/key_value_iterable.h @@ -5,7 +5,7 @@ #include "opentelemetry/version.h" OPENTELEMETRY_BEGIN_NAMESPACE -namespace trace +namespace common { /** * Supports internal iteration over a collection of key-value pairs. @@ -30,5 +30,5 @@ class KeyValueIterable */ virtual size_t size() const noexcept = 0; }; -} // namespace trace +} // namespace common OPENTELEMETRY_END_NAMESPACE diff --git a/api/include/opentelemetry/trace/key_value_iterable_view.h b/api/include/opentelemetry/common/key_value_iterable_view.h similarity index 94% rename from api/include/opentelemetry/trace/key_value_iterable_view.h rename to api/include/opentelemetry/common/key_value_iterable_view.h index 2daf83c713..a9b61cd87b 100644 --- a/api/include/opentelemetry/trace/key_value_iterable_view.h +++ b/api/include/opentelemetry/common/key_value_iterable_view.h @@ -4,12 +4,12 @@ #include #include +#include "opentelemetry/common/key_value_iterable.h" #include "opentelemetry/nostd/utility.h" -#include "opentelemetry/trace/key_value_iterable.h" #include "opentelemetry/version.h" OPENTELEMETRY_BEGIN_NAMESPACE -namespace trace +namespace common { namespace detail { @@ -60,5 +60,5 @@ class KeyValueIterableView final : public KeyValueIterable private: const T *container_; }; -} // namespace trace +} // namespace common OPENTELEMETRY_END_NAMESPACE diff --git a/api/include/opentelemetry/metrics/async_instruments.h b/api/include/opentelemetry/metrics/async_instruments.h index bfe43015f3..24eab3467e 100644 --- a/api/include/opentelemetry/metrics/async_instruments.h +++ b/api/include/opentelemetry/metrics/async_instruments.h @@ -28,7 +28,7 @@ class ValueObserver : virtual public AsynchronousInstrument * @param value is the numerical representation of the metric being captured * @param labels the set of labels, as key-value pairs */ - virtual void observe(T value, const trace::KeyValueIterable &labels) override = 0; + virtual void observe(T value, const common::KeyValueIterable &labels) override = 0; /** * Captures data by activating the callback function associated with the @@ -55,7 +55,7 @@ class SumObserver : virtual public AsynchronousInstrument void (*callback)(ObserverResult)) {} - virtual void observe(T value, const trace::KeyValueIterable &labels) override = 0; + virtual void observe(T value, const common::KeyValueIterable &labels) override = 0; virtual void run() override = 0; }; @@ -74,7 +74,7 @@ class UpDownSumObserver : virtual public AsynchronousInstrument void (*callback)(ObserverResult)) {} - virtual void observe(T value, const trace::KeyValueIterable &labels) override = 0; + virtual void observe(T value, const common::KeyValueIterable &labels) override = 0; virtual void run() override = 0; }; diff --git a/api/include/opentelemetry/metrics/instrument.h b/api/include/opentelemetry/metrics/instrument.h index 2a7ac8b6d2..45d8339481 100644 --- a/api/include/opentelemetry/metrics/instrument.h +++ b/api/include/opentelemetry/metrics/instrument.h @@ -2,9 +2,9 @@ #include #include "opentelemetry/common/attribute_value.h" +#include "opentelemetry/common/key_value_iterable_view.h" #include "opentelemetry/nostd/shared_ptr.h" #include "opentelemetry/nostd/string_view.h" -#include "opentelemetry/trace/key_value_iterable_view.h" OPENTELEMETRY_BEGIN_NAMESPACE namespace metrics @@ -135,7 +135,7 @@ class SynchronousInstrument : virtual public Instrument * @return a Bound Instrument */ virtual nostd::shared_ptr> bind( - const trace::KeyValueIterable &labels) + const common::KeyValueIterable &labels) { return nostd::shared_ptr>(); } @@ -152,7 +152,7 @@ class SynchronousInstrument : virtual public Instrument * @param value is the numerical representation of the metric being captured * @return void */ - virtual void update(T value, const trace::KeyValueIterable &labels) = 0; + virtual void update(T value, const common::KeyValueIterable &labels) = 0; }; template @@ -181,7 +181,7 @@ class AsynchronousInstrument : virtual public Instrument * @param labels is the numerical representation of the metric being captured * @return none */ - virtual void observe(T value, const trace::KeyValueIterable &labels) = 0; + virtual void observe(T value, const common::KeyValueIterable &labels) = 0; /** * Captures data by activating the callback function associated with the diff --git a/api/include/opentelemetry/metrics/meter.h b/api/include/opentelemetry/metrics/meter.h index c58c489f2a..3d8c2e037d 100644 --- a/api/include/opentelemetry/metrics/meter.h +++ b/api/include/opentelemetry/metrics/meter.h @@ -263,19 +263,19 @@ class Meter * @param values a span of values to record to the instruments in the corresponding * position in the instruments span. */ - virtual void RecordShortBatch(const trace::KeyValueIterable &labels, + virtual void RecordShortBatch(const common::KeyValueIterable &labels, nostd::span *> instruments, nostd::span values) noexcept = 0; - virtual void RecordIntBatch(const trace::KeyValueIterable &labels, + virtual void RecordIntBatch(const common::KeyValueIterable &labels, nostd::span *> instruments, nostd::span values) noexcept = 0; - virtual void RecordFloatBatch(const trace::KeyValueIterable &labels, + virtual void RecordFloatBatch(const common::KeyValueIterable &labels, nostd::span *> instruments, nostd::span values) noexcept = 0; - virtual void RecordDoubleBatch(const trace::KeyValueIterable &labels, + virtual void RecordDoubleBatch(const common::KeyValueIterable &labels, nostd::span *> instruments, nostd::span values) noexcept = 0; }; diff --git a/api/include/opentelemetry/metrics/noop.h b/api/include/opentelemetry/metrics/noop.h index c5569fd4e9..552e125dd0 100644 --- a/api/include/opentelemetry/metrics/noop.h +++ b/api/include/opentelemetry/metrics/noop.h @@ -15,6 +15,9 @@ #include +// TODO: Create generic short pattern for opentelemetry::common and opentelemetry::trace and others +// as necessary + OPENTELEMETRY_BEGIN_NAMESPACE namespace metrics { @@ -38,7 +41,7 @@ class NoopValueObserver : public ValueObserver virtual nostd::string_view GetUnits() override { return nostd::string_view(""); } - virtual void observe(T value, const trace::KeyValueIterable &labels) override {} + virtual void observe(T value, const common::KeyValueIterable &labels) override {} virtual void run() override {} @@ -65,7 +68,7 @@ class NoopSumObserver : public SumObserver virtual nostd::string_view GetUnits() override { return nostd::string_view(""); } - virtual void observe(T value, const trace::KeyValueIterable &labels) override {} + virtual void observe(T value, const common::KeyValueIterable &labels) override {} virtual void run() override {} @@ -92,7 +95,7 @@ class NoopUpDownSumObserver : public UpDownSumObserver virtual nostd::string_view GetUnits() override { return nostd::string_view(""); } - virtual void observe(T value, const trace::KeyValueIterable &labels) override {} + virtual void observe(T value, const common::KeyValueIterable &labels) override {} virtual void run() override {} @@ -138,14 +141,15 @@ class NoopCounter : public Counter bool /*enabled*/) {} - nostd::shared_ptr> bindNoopCounter(const trace::KeyValueIterable & /*labels*/) + nostd::shared_ptr> bindNoopCounter( + const common::KeyValueIterable & /*labels*/) { return nostd::shared_ptr>(new BoundNoopCounter()); } - virtual void add(T value, const trace::KeyValueIterable & /*labels*/) override {} + virtual void add(T value, const common::KeyValueIterable & /*labels*/) override {} - virtual void update(T value, const trace::KeyValueIterable & /*labels*/) override {} + virtual void update(T value, const common::KeyValueIterable & /*labels*/) override {} virtual bool IsEnabled() override { return false; } @@ -198,14 +202,14 @@ class NoopUpDownCounter : public UpDownCounter {} nostd::shared_ptr> bindNoopUpDownCounter( - const trace::KeyValueIterable & /*labels*/) + const common::KeyValueIterable & /*labels*/) { return nostd::shared_ptr>(new BoundNoopUpDownCounter()); } - virtual void add(T value, const trace::KeyValueIterable & /*labels*/) override {} + virtual void add(T value, const common::KeyValueIterable & /*labels*/) override {} - virtual void update(T value, const trace::KeyValueIterable & /*labels*/) override {} + virtual void update(T value, const common::KeyValueIterable & /*labels*/) override {} virtual bool IsEnabled() override { return false; } @@ -258,14 +262,14 @@ class NoopValueRecorder : public ValueRecorder {} nostd::shared_ptr> bindNoopValueRecorder( - const trace::KeyValueIterable & /*labels*/) + const common::KeyValueIterable & /*labels*/) { return nostd::shared_ptr>(new BoundNoopValueRecorder()); } - virtual void record(T value, const trace::KeyValueIterable & /*labels*/) override {} + virtual void record(T value, const common::KeyValueIterable & /*labels*/) override {} - virtual void update(T value, const trace::KeyValueIterable & /*labels*/) override {} + virtual void update(T value, const common::KeyValueIterable & /*labels*/) override {} virtual bool IsEnabled() override { return false; } @@ -296,36 +300,36 @@ class NoopMeter : public Meter * @param enabled a boolean that turns the metric instrument on and off. * @return */ - opentelemetry::nostd::shared_ptr> NewShortCounter(nostd::string_view name, - nostd::string_view description, - nostd::string_view unit, - const bool enabled) override + nostd::shared_ptr> NewShortCounter(nostd::string_view name, + nostd::string_view description, + nostd::string_view unit, + const bool enabled) override { return nostd::shared_ptr>{ new NoopCounter(name, description, unit, enabled)}; } - opentelemetry::nostd::shared_ptr> NewIntCounter(nostd::string_view name, - nostd::string_view description, - nostd::string_view unit, - const bool enabled) override + nostd::shared_ptr> NewIntCounter(nostd::string_view name, + nostd::string_view description, + nostd::string_view unit, + const bool enabled) override { return nostd::shared_ptr>{new NoopCounter(name, description, unit, enabled)}; } - opentelemetry::nostd::shared_ptr> NewFloatCounter(nostd::string_view name, - nostd::string_view description, - nostd::string_view unit, - const bool enabled) override + nostd::shared_ptr> NewFloatCounter(nostd::string_view name, + nostd::string_view description, + nostd::string_view unit, + const bool enabled) override { return nostd::shared_ptr>{ new NoopCounter(name, description, unit, enabled)}; } - opentelemetry::nostd::shared_ptr> NewDoubleCounter(nostd::string_view name, - nostd::string_view description, - nostd::string_view unit, - const bool enabled) override + nostd::shared_ptr> NewDoubleCounter(nostd::string_view name, + nostd::string_view description, + nostd::string_view unit, + const bool enabled) override { return nostd::shared_ptr>{ new NoopCounter(name, description, unit, enabled)}; @@ -341,41 +345,37 @@ class NoopMeter : public Meter * @param enabled a boolean that turns the metric instrument on and off. * @return */ - opentelemetry::nostd::shared_ptr> NewShortUpDownCounter( - nostd::string_view name, - nostd::string_view description, - nostd::string_view unit, - const bool enabled) override + nostd::shared_ptr> NewShortUpDownCounter(nostd::string_view name, + nostd::string_view description, + nostd::string_view unit, + const bool enabled) override { return nostd::shared_ptr>{ new NoopUpDownCounter(name, description, unit, enabled)}; } - opentelemetry::nostd::shared_ptr> NewIntUpDownCounter( - nostd::string_view name, - nostd::string_view description, - nostd::string_view unit, - const bool enabled) override + nostd::shared_ptr> NewIntUpDownCounter(nostd::string_view name, + nostd::string_view description, + nostd::string_view unit, + const bool enabled) override { return nostd::shared_ptr>{ new NoopUpDownCounter(name, description, unit, enabled)}; } - opentelemetry::nostd::shared_ptr> NewFloatUpDownCounter( - nostd::string_view name, - nostd::string_view description, - nostd::string_view unit, - const bool enabled) override + nostd::shared_ptr> NewFloatUpDownCounter(nostd::string_view name, + nostd::string_view description, + nostd::string_view unit, + const bool enabled) override { return nostd::shared_ptr>{ new NoopUpDownCounter(name, description, unit, enabled)}; } - opentelemetry::nostd::shared_ptr> NewDoubleUpDownCounter( - nostd::string_view name, - nostd::string_view description, - nostd::string_view unit, - const bool enabled) override + nostd::shared_ptr> NewDoubleUpDownCounter(nostd::string_view name, + nostd::string_view description, + nostd::string_view unit, + const bool enabled) override { return nostd::shared_ptr>{ new NoopUpDownCounter(name, description, unit, enabled)}; @@ -391,41 +391,37 @@ class NoopMeter : public Meter * @param enabled a boolean that turns the metric instrument on and off. * @return */ - opentelemetry::nostd::shared_ptr> NewShortValueRecorder( - nostd::string_view name, - nostd::string_view description, - nostd::string_view unit, - const bool enabled) override + nostd::shared_ptr> NewShortValueRecorder(nostd::string_view name, + nostd::string_view description, + nostd::string_view unit, + const bool enabled) override { return nostd::shared_ptr>{ new NoopValueRecorder(name, description, unit, enabled)}; } - opentelemetry::nostd::shared_ptr> NewIntValueRecorder( - nostd::string_view name, - nostd::string_view description, - nostd::string_view unit, - const bool enabled) override + nostd::shared_ptr> NewIntValueRecorder(nostd::string_view name, + nostd::string_view description, + nostd::string_view unit, + const bool enabled) override { return nostd::shared_ptr>{ new NoopValueRecorder(name, description, unit, enabled)}; } - opentelemetry::nostd::shared_ptr> NewFloatValueRecorder( - nostd::string_view name, - nostd::string_view description, - nostd::string_view unit, - const bool enabled) override + nostd::shared_ptr> NewFloatValueRecorder(nostd::string_view name, + nostd::string_view description, + nostd::string_view unit, + const bool enabled) override { return nostd::shared_ptr>{ new NoopValueRecorder(name, description, unit, enabled)}; } - opentelemetry::nostd::shared_ptr> NewDoubleValueRecorder( - nostd::string_view name, - nostd::string_view description, - nostd::string_view unit, - const bool enabled) override + nostd::shared_ptr> NewDoubleValueRecorder(nostd::string_view name, + nostd::string_view description, + nostd::string_view unit, + const bool enabled) override { return nostd::shared_ptr>{ new NoopValueRecorder(name, description, unit, enabled)}; @@ -441,7 +437,7 @@ class NoopMeter : public Meter * @param enabled a boolean that turns the metric instrument on and off. * @return */ - opentelemetry::nostd::shared_ptr> NewShortSumObserver( + nostd::shared_ptr> NewShortSumObserver( nostd::string_view name, nostd::string_view description, nostd::string_view unit, @@ -452,7 +448,7 @@ class NoopMeter : public Meter new NoopSumObserver(name, description, unit, enabled, callback)}; } - opentelemetry::nostd::shared_ptr> NewIntSumObserver( + nostd::shared_ptr> NewIntSumObserver( nostd::string_view name, nostd::string_view description, nostd::string_view unit, @@ -463,7 +459,7 @@ class NoopMeter : public Meter new NoopSumObserver(name, description, unit, enabled, callback)}; } - opentelemetry::nostd::shared_ptr> NewFloatSumObserver( + nostd::shared_ptr> NewFloatSumObserver( nostd::string_view name, nostd::string_view description, nostd::string_view unit, @@ -474,7 +470,7 @@ class NoopMeter : public Meter new NoopSumObserver(name, description, unit, enabled, callback)}; } - opentelemetry::nostd::shared_ptr> NewDoubleSumObserver( + nostd::shared_ptr> NewDoubleSumObserver( nostd::string_view name, nostd::string_view description, nostd::string_view unit, @@ -495,7 +491,7 @@ class NoopMeter : public Meter * @param enabled a boolean that turns the metric instrument on and off. * @return */ - opentelemetry::nostd::shared_ptr> NewShortUpDownSumObserver( + nostd::shared_ptr> NewShortUpDownSumObserver( nostd::string_view name, nostd::string_view description, nostd::string_view unit, @@ -506,7 +502,7 @@ class NoopMeter : public Meter new NoopUpDownSumObserver(name, description, unit, enabled, callback)}; } - opentelemetry::nostd::shared_ptr> NewIntUpDownSumObserver( + nostd::shared_ptr> NewIntUpDownSumObserver( nostd::string_view name, nostd::string_view description, nostd::string_view unit, @@ -517,7 +513,7 @@ class NoopMeter : public Meter new NoopUpDownSumObserver(name, description, unit, enabled, callback)}; } - opentelemetry::nostd::shared_ptr> NewFloatUpDownSumObserver( + nostd::shared_ptr> NewFloatUpDownSumObserver( nostd::string_view name, nostd::string_view description, nostd::string_view unit, @@ -528,7 +524,7 @@ class NoopMeter : public Meter new NoopUpDownSumObserver(name, description, unit, enabled, callback)}; } - opentelemetry::nostd::shared_ptr> NewDoubleUpDownSumObserver( + nostd::shared_ptr> NewDoubleUpDownSumObserver( nostd::string_view name, nostd::string_view description, nostd::string_view unit, @@ -549,7 +545,7 @@ class NoopMeter : public Meter * @param enabled a boolean that turns the metric instrument on and off. * @return */ - opentelemetry::nostd::shared_ptr> NewShortValueObserver( + nostd::shared_ptr> NewShortValueObserver( nostd::string_view name, nostd::string_view description, nostd::string_view unit, @@ -560,7 +556,7 @@ class NoopMeter : public Meter new NoopValueObserver(name, description, unit, enabled, callback)}; } - opentelemetry::nostd::shared_ptr> NewIntValueObserver( + nostd::shared_ptr> NewIntValueObserver( nostd::string_view name, nostd::string_view description, nostd::string_view unit, @@ -571,7 +567,7 @@ class NoopMeter : public Meter new NoopValueObserver(name, description, unit, enabled, callback)}; } - opentelemetry::nostd::shared_ptr> NewFloatValueObserver( + nostd::shared_ptr> NewFloatValueObserver( nostd::string_view name, nostd::string_view description, nostd::string_view unit, @@ -582,7 +578,7 @@ class NoopMeter : public Meter new NoopValueObserver(name, description, unit, enabled, callback)}; } - opentelemetry::nostd::shared_ptr> NewDoubleValueObserver( + nostd::shared_ptr> NewDoubleValueObserver( nostd::string_view name, nostd::string_view description, nostd::string_view unit, @@ -602,28 +598,28 @@ class NoopMeter : public Meter * @param instrs the instruments to record to. * @param values the value to record to those instruments. */ - void RecordShortBatch(const trace::KeyValueIterable &labels, + void RecordShortBatch(const common::KeyValueIterable &labels, nostd::span *> instruments, nostd::span values) noexcept override { // No-op } - void RecordIntBatch(const trace::KeyValueIterable &labels, + void RecordIntBatch(const common::KeyValueIterable &labels, nostd::span *> instruments, nostd::span values) noexcept override { // No-op } - void RecordFloatBatch(const trace::KeyValueIterable &labels, + void RecordFloatBatch(const common::KeyValueIterable &labels, nostd::span *> instruments, nostd::span values) noexcept override { // No-op } - void RecordDoubleBatch(const trace::KeyValueIterable &labels, + void RecordDoubleBatch(const common::KeyValueIterable &labels, nostd::span *> instruments, nostd::span values) noexcept override { diff --git a/api/include/opentelemetry/metrics/observer_result.h b/api/include/opentelemetry/metrics/observer_result.h index a16b5a3815..c7733c75e4 100644 --- a/api/include/opentelemetry/metrics/observer_result.h +++ b/api/include/opentelemetry/metrics/observer_result.h @@ -23,7 +23,7 @@ class ObserverResult ObserverResult(AsynchronousInstrument *instrument) : instrument_(instrument) {} - virtual void observe(T value, const trace::KeyValueIterable &labels) + virtual void observe(T value, const common::KeyValueIterable &labels) { instrument_->observe(value, labels); } diff --git a/api/include/opentelemetry/metrics/sync_instruments.h b/api/include/opentelemetry/metrics/sync_instruments.h index 8823d83e4d..c5ab128074 100644 --- a/api/include/opentelemetry/metrics/sync_instruments.h +++ b/api/include/opentelemetry/metrics/sync_instruments.h @@ -48,7 +48,7 @@ class Counter : virtual public SynchronousInstrument * @param labels the set of labels, as key-value pairs. * @return a BoundIntCounter tied to the specified labels */ - virtual nostd::shared_ptr> bindCounter(const trace::KeyValueIterable &labels) + virtual nostd::shared_ptr> bindCounter(const common::KeyValueIterable &labels) { return nostd::shared_ptr>(); } @@ -61,9 +61,9 @@ class Counter : virtual public SynchronousInstrument * @param value the numerical representation of the metric being captured * @param labels the set of labels, as key-value pairs */ - virtual void add(T value, const trace::KeyValueIterable &labels) = 0; + virtual void add(T value, const common::KeyValueIterable &labels) = 0; - virtual void update(T value, const trace::KeyValueIterable &labels) override = 0; + virtual void update(T value, const common::KeyValueIterable &labels) override = 0; }; template @@ -101,7 +101,7 @@ class UpDownCounter : virtual public SynchronousInstrument bool enabled); virtual nostd::shared_ptr> bindUpDownCounter( - const trace::KeyValueIterable &labels) + const common::KeyValueIterable &labels) { return nostd::shared_ptr>(); } @@ -114,9 +114,9 @@ class UpDownCounter : virtual public SynchronousInstrument * @param value the numerical representation of the metric being captured * @param labels the set of labels, as key-value pairs */ - virtual void add(T value, const trace::KeyValueIterable &labels) = 0; + virtual void add(T value, const common::KeyValueIterable &labels) = 0; - virtual void update(T value, const trace::KeyValueIterable &labels) override = 0; + virtual void update(T value, const common::KeyValueIterable &labels) override = 0; }; template @@ -154,7 +154,7 @@ class ValueRecorder : virtual public SynchronousInstrument bool enabled); virtual nostd::shared_ptr> bindValueRecorder( - const trace::KeyValueIterable &labels) + const common::KeyValueIterable &labels) { return nostd::shared_ptr>(); } @@ -167,9 +167,9 @@ class ValueRecorder : virtual public SynchronousInstrument * @param value the numerical representation of the metric being captured * @param labels the set of labels, as key-value pairs */ - virtual void record(T value, const trace::KeyValueIterable &labels) = 0; + virtual void record(T value, const common::KeyValueIterable &labels) = 0; - virtual void update(T value, const trace::KeyValueIterable &labels) override = 0; + virtual void update(T value, const common::KeyValueIterable &labels) override = 0; }; } // namespace metrics diff --git a/api/include/opentelemetry/plugin/tracer.h b/api/include/opentelemetry/plugin/tracer.h index aed1d26d28..ffd865031f 100644 --- a/api/include/opentelemetry/plugin/tracer.h +++ b/api/include/opentelemetry/plugin/tracer.h @@ -2,6 +2,7 @@ #include +#include "opentelemetry/common/key_value_iterable.h" #include "opentelemetry/plugin/detail/dynamic_library_handle.h" #include "opentelemetry/plugin/detail/tracer_handle.h" #include "opentelemetry/trace/tracer.h" @@ -32,7 +33,7 @@ class Span final : public trace::Span void AddEvent(nostd::string_view name, core::SystemTimestamp timestamp, - const trace::KeyValueIterable &attributes) noexcept override + const common::KeyValueIterable &attributes) noexcept override { span_->AddEvent(name, timestamp, attributes); } @@ -66,7 +67,7 @@ class Tracer final : public trace::Tracer, public std::enable_shared_from_this StartSpan( nostd::string_view name, - const trace::KeyValueIterable &attributes, + const common::KeyValueIterable &attributes, const trace::StartSpanOptions &options = {}) noexcept override { auto span = tracer_handle_->tracer().StartSpan(name, attributes, options); diff --git a/api/include/opentelemetry/trace/default_span.h b/api/include/opentelemetry/trace/default_span.h index bfe46ae2ca..15d5f4bf84 100644 --- a/api/include/opentelemetry/trace/default_span.h +++ b/api/include/opentelemetry/trace/default_span.h @@ -25,10 +25,10 @@ class DefaultSpan : public Span void AddEvent(nostd::string_view name, core::SystemTimestamp timestamp, - const KeyValueIterable &attributes) noexcept + const common::KeyValueIterable &attributes) noexcept {} - void AddEvent(nostd::string_view name, const KeyValueIterable &attributes) noexcept + void AddEvent(nostd::string_view name, const common::KeyValueIterable &attributes) noexcept { this->AddEvent(name, std::chrono::system_clock::now(), attributes); } diff --git a/api/include/opentelemetry/trace/default_tracer.h b/api/include/opentelemetry/trace/default_tracer.h index f6b24aede0..384c0115a1 100644 --- a/api/include/opentelemetry/trace/default_tracer.h +++ b/api/include/opentelemetry/trace/default_tracer.h @@ -21,7 +21,7 @@ class DefaultTracer : public Tracer * key will be overwritten. */ nostd::unique_ptr StartSpan(nostd::string_view name, - const KeyValueIterable &attributes, + const common::KeyValueIterable &attributes, const StartSpanOptions &options = {}) override noexcept { return nostd::unique_ptr(new DefaultSpan::GetInvalid()); diff --git a/api/include/opentelemetry/trace/noop.h b/api/include/opentelemetry/trace/noop.h index b4d950fd60..2997e9579f 100644 --- a/api/include/opentelemetry/trace/noop.h +++ b/api/include/opentelemetry/trace/noop.h @@ -39,7 +39,7 @@ class NoopSpan final : public Span void AddEvent(nostd::string_view /*name*/, core::SystemTimestamp /*timestamp*/, - const trace::KeyValueIterable & /*attributes*/) noexcept override + const common::KeyValueIterable & /*attributes*/) noexcept override {} void SetStatus(CanonicalCode /*code*/, nostd::string_view /*description*/) noexcept override {} @@ -65,7 +65,7 @@ class NoopTracer final : public Tracer, public std::enable_shared_from_this StartSpan(nostd::string_view /*name*/, - const KeyValueIterable & /*attributes*/, + const common::KeyValueIterable & /*attributes*/, const StartSpanOptions & /*options*/) noexcept override { // Don't allocate a no-op span for every StartSpan call, but use a static diff --git a/api/include/opentelemetry/trace/propagation/http_trace_context.h b/api/include/opentelemetry/trace/propagation/http_trace_context.h index 07467b7ef6..d4b249970b 100644 --- a/api/include/opentelemetry/trace/propagation/http_trace_context.h +++ b/api/include/opentelemetry/trace/propagation/http_trace_context.h @@ -16,13 +16,13 @@ #include #include #include +#include "opentelemetry/common/key_value_iterable.h" #include "opentelemetry/context/context.h" #include "opentelemetry/nostd/shared_ptr.h" #include "opentelemetry/nostd/span.h" #include "opentelemetry/nostd/string_view.h" #include "opentelemetry/nostd/variant.h" #include "opentelemetry/trace/default_span.h" -#include "opentelemetry/trace/key_value_iterable.h" #include "opentelemetry/trace/propagation/http_text_format.h" #include "opentelemetry/trace/span.h" #include "opentelemetry/trace/span_context.h" diff --git a/api/include/opentelemetry/trace/span.h b/api/include/opentelemetry/trace/span.h index 016cd557e5..f324658740 100644 --- a/api/include/opentelemetry/trace/span.h +++ b/api/include/opentelemetry/trace/span.h @@ -3,12 +3,12 @@ #include #include "opentelemetry/common/attribute_value.h" +#include "opentelemetry/common/key_value_iterable_view.h" #include "opentelemetry/core/timestamp.h" #include "opentelemetry/nostd/span.h" #include "opentelemetry/nostd/string_view.h" #include "opentelemetry/nostd/unique_ptr.h" #include "opentelemetry/trace/canonical_code.h" -#include "opentelemetry/trace/key_value_iterable_view.h" #include "opentelemetry/trace/span_context.h" #include "opentelemetry/version.h" @@ -100,25 +100,28 @@ class Span // Adds an event to the Span, with a custom timestamp, and attributes. virtual void AddEvent(nostd::string_view name, core::SystemTimestamp timestamp, - const KeyValueIterable &attributes) noexcept = 0; + const common::KeyValueIterable &attributes) noexcept = 0; - virtual void AddEvent(nostd::string_view name, const KeyValueIterable &attributes) noexcept + virtual void AddEvent(nostd::string_view name, + const common::KeyValueIterable &attributes) noexcept { this->AddEvent(name, std::chrono::system_clock::now(), attributes); } - template ::value> * = nullptr> + template ::value> * = nullptr> void AddEvent(nostd::string_view name, core::SystemTimestamp timestamp, const T &attributes) noexcept { - this->AddEvent(name, timestamp, KeyValueIterableView{attributes}); + this->AddEvent(name, timestamp, common::KeyValueIterableView{attributes}); } - template ::value> * = nullptr> + template ::value> * = nullptr> void AddEvent(nostd::string_view name, const T &attributes) noexcept { - this->AddEvent(name, KeyValueIterableView{attributes}); + this->AddEvent(name, common::KeyValueIterableView{attributes}); } void AddEvent(nostd::string_view name, diff --git a/api/include/opentelemetry/trace/tracer.h b/api/include/opentelemetry/trace/tracer.h index 34a34be99e..9ca8b94b8c 100644 --- a/api/include/opentelemetry/trace/tracer.h +++ b/api/include/opentelemetry/trace/tracer.h @@ -32,7 +32,7 @@ class Tracer * key will be overwritten. */ virtual nostd::shared_ptr StartSpan(nostd::string_view name, - const KeyValueIterable &attributes, + const common::KeyValueIterable &attributes, const StartSpanOptions &options = {}) noexcept = 0; nostd::shared_ptr StartSpan(nostd::string_view name, @@ -41,12 +41,13 @@ class Tracer return this->StartSpan(name, {}, options); } - template ::value> * = nullptr> + template ::value> * = nullptr> nostd::shared_ptr StartSpan(nostd::string_view name, const T &attributes, const StartSpanOptions &options = {}) noexcept { - return this->StartSpan(name, KeyValueIterableView(attributes), options); + return this->StartSpan(name, common::KeyValueIterableView(attributes), options); } nostd::shared_ptr StartSpan( diff --git a/api/test/metrics/noop_instrument_test.cc b/api/test/metrics/noop_instrument_test.cc index 5e53599f50..c6bb8c7b81 100644 --- a/api/test/metrics/noop_instrument_test.cc +++ b/api/test/metrics/noop_instrument_test.cc @@ -11,7 +11,7 @@ namespace metrics void noopIntCallback(ObserverResult result) { std::map labels = {{"key", "value"}}; - auto labelkv = trace::KeyValueIterableView{labels}; + auto labelkv = common::KeyValueIterableView{labels}; result.observe(1, labelkv); result.observe(-1, labelkv); } @@ -19,7 +19,7 @@ void noopIntCallback(ObserverResult result) void noopDoubleCallback(ObserverResult result) { std::map labels = {{"key", "value"}}; - auto labelkv = trace::KeyValueIterableView{labels}; + auto labelkv = common::KeyValueIterableView{labels}; result.observe(1.5, labelkv); result.observe(-1.5, labelkv); } @@ -31,7 +31,7 @@ TEST(ValueObserver, Observe) NoopValueObserver beta("test", "none", "unitless", true, &noopDoubleCallback); std::map labels = {{"key", "value"}}; - auto labelkv = trace::KeyValueIterableView{labels}; + auto labelkv = common::KeyValueIterableView{labels}; alpha.observe(1, labelkv); beta.observe(1.5, labelkv); @@ -44,7 +44,7 @@ TEST(SumObserver, DefaultConstruction) NoopSumObserver beta("test", "none", "unitless", true, &noopDoubleCallback); std::map labels = {{"key", "value"}}; - auto labelkv = trace::KeyValueIterableView{labels}; + auto labelkv = common::KeyValueIterableView{labels}; alpha.observe(1, labelkv); beta.observe(1.5, labelkv); @@ -57,7 +57,7 @@ TEST(UpDownSumObserver, DefaultConstruction) NoopUpDownSumObserver beta("test", "none", "unitless", true, &noopDoubleCallback); std::map labels = {{"key", "value"}}; - auto labelkv = trace::KeyValueIterableView{labels}; + auto labelkv = common::KeyValueIterableView{labels}; alpha.observe(1, labelkv); beta.observe(1.0, labelkv); @@ -71,7 +71,7 @@ TEST(Counter, DefaultConstruction) NoopCounter beta("other", "none", "unitless", true); std::map labels = {{"key", "value"}}; - auto labelkv = trace::KeyValueIterableView{labels}; + auto labelkv = common::KeyValueIterableView{labels}; alpha.bind(labelkv); @@ -88,7 +88,7 @@ TEST(Counter, Add) NoopCounter beta("other", "none", "unitless", true); std::map labels = {{"key", "value"}}; - auto labelkv = trace::KeyValueIterableView{labels}; + auto labelkv = common::KeyValueIterableView{labels}; alpha.add(1, labelkv); beta.add(1.5, labelkv); @@ -109,7 +109,7 @@ TEST(UpDownCounter, DefaultConstruction) NoopUpDownCounter beta("other", "none", "unitless", true); std::map labels = {{"key", "value"}}; - auto labelkv = trace::KeyValueIterableView{labels}; + auto labelkv = common::KeyValueIterableView{labels}; alpha.bind(labelkv); @@ -126,7 +126,7 @@ TEST(UpDownCounter, Add) NoopUpDownCounter beta("other", "none", "unitless", true); std::map labels = {{"key", "value"}}; - auto labelkv = trace::KeyValueIterableView{labels}; + auto labelkv = common::KeyValueIterableView{labels}; alpha.add(1, labelkv); beta.add(1.5, labelkv); @@ -149,7 +149,7 @@ TEST(ValueRecorder, DefaultConstruction) NoopValueRecorder beta("other", "none", "unitless", true); std::map labels = {{"key", "value"}}; - auto labelkv = trace::KeyValueIterableView{labels}; + auto labelkv = common::KeyValueIterableView{labels}; alpha.bind(labelkv); @@ -166,7 +166,7 @@ TEST(ValueRecorder, Record) NoopValueRecorder beta("other", "none", "unitless", true); std::map labels = {{"key", "value"}}; - auto labelkv = trace::KeyValueIterableView{labels}; + auto labelkv = common::KeyValueIterableView{labels}; alpha.record(1, labelkv); beta.record(1.5, labelkv); diff --git a/api/test/metrics/noop_metrics_test.cc b/api/test/metrics/noop_metrics_test.cc index 9580ebede5..8e43f78180 100644 --- a/api/test/metrics/noop_metrics_test.cc +++ b/api/test/metrics/noop_metrics_test.cc @@ -12,12 +12,10 @@ OPENTELEMETRY_BEGIN_NAMESPACE using opentelemetry::metrics::Meter; using opentelemetry::metrics::NoopMeter; -namespace metrics_api = opentelemetry::metrics; - void Callback(opentelemetry::metrics::ObserverResult result) { std::map labels = {{"key", "value"}}; - auto labelkv = trace::KeyValueIterableView{labels}; + auto labelkv = common::KeyValueIterableView{labels}; result.observe(1, labelkv); } @@ -43,7 +41,7 @@ TEST(NoopMeter, RecordBatch) std::unique_ptr m{std::unique_ptr(new NoopMeter{})}; std::map labels = {{"Key", "Value"}}; - auto labelkv = opentelemetry::trace::KeyValueIterableView{labels}; + auto labelkv = opentelemetry::common::KeyValueIterableView{labels}; auto s = m->NewShortCounter("Test short counter", "For testing", "Unitless", true); diff --git a/api/test/trace/key_value_iterable_view_test.cc b/api/test/trace/key_value_iterable_view_test.cc index 641e649473..9fba29734f 100644 --- a/api/test/trace/key_value_iterable_view_test.cc +++ b/api/test/trace/key_value_iterable_view_test.cc @@ -1,4 +1,4 @@ -#include "opentelemetry/trace/key_value_iterable_view.h" +#include "opentelemetry/common/key_value_iterable_view.h" #include #include @@ -6,7 +6,7 @@ using namespace opentelemetry; -static int TakeKeyValues(const trace::KeyValueIterable &iterable) +static int TakeKeyValues(const common::KeyValueIterable &iterable) { std::map result; int count = 0; @@ -17,27 +17,27 @@ static int TakeKeyValues(const trace::KeyValueIterable &iterable) return count; } -template ::value> * = nullptr> +template ::value> * = nullptr> static int TakeKeyValues(const T &iterable) { - return TakeKeyValues(trace::KeyValueIterableView{iterable}); + return TakeKeyValues(common::KeyValueIterableView{iterable}); } TEST(KeyValueIterableViewTest, is_key_value_iterable) { using M1 = std::map; - EXPECT_TRUE(bool{trace::detail::is_key_value_iterable::value}); + EXPECT_TRUE(bool{common::detail::is_key_value_iterable::value}); using M2 = std::map; - EXPECT_TRUE(bool{trace::detail::is_key_value_iterable::value}); + EXPECT_TRUE(bool{common::detail::is_key_value_iterable::value}); using M3 = std::map; - EXPECT_TRUE(bool{trace::detail::is_key_value_iterable::value}); + EXPECT_TRUE(bool{common::detail::is_key_value_iterable::value}); struct A {}; using M4 = std::map; - EXPECT_FALSE(bool{trace::detail::is_key_value_iterable::value}); + EXPECT_FALSE(bool{common::detail::is_key_value_iterable::value}); } TEST(KeyValueIterableViewTest, ForEachKeyValue) @@ -53,7 +53,7 @@ TEST(KeyValueIterableViewTest, ForEachKeyValueWithExit) { using M = std::map; M m1 = {{"abc", "123"}, {"xyz", "456"}}; - trace::KeyValueIterableView iterable{m1}; + common::KeyValueIterableView iterable{m1}; int count = 0; auto exit = iterable.ForEachKeyValue([&count](nostd::string_view /*key*/, common::AttributeValue /*value*/) noexcept { diff --git a/examples/metrics_simple/README.md b/examples/metrics_simple/README.md index 7581dfb2f8..f840fa1e89 100644 --- a/examples/metrics_simple/README.md +++ b/examples/metrics_simple/README.md @@ -33,7 +33,7 @@ shared_ptr processor = shared_ptr(new Ungrou // Observer callback function void SumObserverCallback(metrics_api::ObserverResult result){ std::map labels = {{"key", "value"}}; - auto labelkv = trace::KeyValueIterableView{labels}; + auto labelkv = common::KeyValueIterableView{labels}; result.observe(1,labelkv); } @@ -43,7 +43,7 @@ auto obs= meter->NewIntSumObserver("Counter","none", "none", true, &SumObserverC // Create a label set which annotates metric values std::map labels = {{"key", "value"}}; -auto labelkv = trace::KeyValueIterableView{labels}; +auto labelkv = common::KeyValueIterableView{labels}; // Capture data from instruments. Note that the asynchronous instrument is updates // automatically though its callback at the collection interval. Additional measurments diff --git a/examples/metrics_simple/main.cc b/examples/metrics_simple/main.cc index 4f0637371d..ca8bb2bda3 100644 --- a/examples/metrics_simple/main.cc +++ b/examples/metrics_simple/main.cc @@ -7,7 +7,6 @@ namespace sdkmetrics = opentelemetry::sdk::metrics; namespace nostd = opentelemetry::nostd; -namespace trace = opentelemetry::trace; int main() { @@ -33,7 +32,7 @@ int main() // Create a labelset std::map labels = {{"key", "value"}}; - auto labelkv = trace::KeyValueIterableView{labels}; + auto labelkv = opentelemetry::common::KeyValueIterableView{labels}; // Create arrays of instrument and values to add to them metrics_api::SynchronousInstrument *iinstr_arr[] = {intupdowncounter.get(), diff --git a/examples/plugin/plugin/tracer.cc b/examples/plugin/plugin/tracer.cc index 31b9367c7c..14703c7064 100644 --- a/examples/plugin/plugin/tracer.cc +++ b/examples/plugin/plugin/tracer.cc @@ -18,7 +18,7 @@ class Span final : public trace::Span public: Span(std::shared_ptr &&tracer, nostd::string_view name, - const opentelemetry::trace::KeyValueIterable & /*attributes*/, + const opentelemetry::common::KeyValueIterable & /*attributes*/, const trace::StartSpanOptions & /*options*/) noexcept : tracer_{std::move(tracer)}, name_{name}, span_context_{trace::SpanContext::GetInvalid()} { @@ -39,7 +39,7 @@ class Span final : public trace::Span void AddEvent(nostd::string_view /*name*/, core::SystemTimestamp /*timestamp*/, - const trace::KeyValueIterable & /*attributes*/) noexcept override + const common::KeyValueIterable & /*attributes*/) noexcept override {} void SetStatus(trace::CanonicalCode /*code*/, @@ -65,7 +65,7 @@ Tracer::Tracer(nostd::string_view /*output*/) {} nostd::shared_ptr Tracer::StartSpan( nostd::string_view name, - const opentelemetry::trace::KeyValueIterable &attributes, + const opentelemetry::common::KeyValueIterable &attributes, const trace::StartSpanOptions &options) noexcept { return nostd::shared_ptr{ diff --git a/examples/plugin/plugin/tracer.h b/examples/plugin/plugin/tracer.h index c50b5f458b..7d6048c88d 100644 --- a/examples/plugin/plugin/tracer.h +++ b/examples/plugin/plugin/tracer.h @@ -13,7 +13,7 @@ class Tracer final : public opentelemetry::trace::Tracer, // opentelemetry::trace::Tracer opentelemetry::nostd::shared_ptr StartSpan( opentelemetry::nostd::string_view name, - const opentelemetry::trace::KeyValueIterable & /*attributes*/, + const opentelemetry::common::KeyValueIterable & /*attributes*/, const opentelemetry::trace::StartSpanOptions & /*options */) noexcept override; void ForceFlushWithMicroseconds(uint64_t /*timeout*/) noexcept override {} diff --git a/exporters/otlp/include/opentelemetry/exporters/otlp/recordable.h b/exporters/otlp/include/opentelemetry/exporters/otlp/recordable.h index 5dc4de02f0..3e1c14c208 100644 --- a/exporters/otlp/include/opentelemetry/exporters/otlp/recordable.h +++ b/exporters/otlp/include/opentelemetry/exporters/otlp/recordable.h @@ -23,10 +23,10 @@ class Recordable final : public sdk::trace::Recordable void AddEvent(nostd::string_view name, core::SystemTimestamp timestamp, - const trace::KeyValueIterable &attributes) noexcept override; + const common::KeyValueIterable &attributes) noexcept override; void AddLink(opentelemetry::trace::SpanContext span_context, - const trace::KeyValueIterable &attributes) noexcept override; + const common::KeyValueIterable &attributes) noexcept override; void SetStatus(trace::CanonicalCode code, nostd::string_view description) noexcept override; diff --git a/exporters/otlp/src/recordable.cc b/exporters/otlp/src/recordable.cc index 4d19e3ecd1..a48f6a95f8 100644 --- a/exporters/otlp/src/recordable.cc +++ b/exporters/otlp/src/recordable.cc @@ -120,7 +120,7 @@ void Recordable::SetAttribute(nostd::string_view key, void Recordable::AddEvent(nostd::string_view name, core::SystemTimestamp timestamp, - const trace::KeyValueIterable &attributes) noexcept + const common::KeyValueIterable &attributes) noexcept { auto *event = span_.add_events(); event->set_name(name.data(), name.size()); @@ -133,7 +133,7 @@ void Recordable::AddEvent(nostd::string_view name, } void Recordable::AddLink(opentelemetry::trace::SpanContext span_context, - const trace::KeyValueIterable &attributes) noexcept + const common::KeyValueIterable &attributes) noexcept { auto *link = span_.add_links(); attributes.ForEachKeyValue([&](nostd::string_view key, common::AttributeValue value) noexcept { diff --git a/exporters/otlp/test/recordable_test.cc b/exporters/otlp/test/recordable_test.cc index 8a3d07369c..665fcc0003 100644 --- a/exporters/otlp/test/recordable_test.cc +++ b/exporters/otlp/test/recordable_test.cc @@ -105,7 +105,7 @@ TEST(Recordable, AddEventWithAttributes) {keys[0], values[0]}, {keys[1], values[1]}, {keys[2], values[2]}}; rec.AddEvent("Test Event", std::chrono::system_clock::now(), - trace::KeyValueIterableView>(attributes)); + common::KeyValueIterableView>(attributes)); for (int i = 0; i < kNumAttributes; i++) { @@ -124,7 +124,7 @@ TEST(Recordable, AddLink) {keys[0], values[0]}, {keys[1], values[1]}, {keys[2], values[2]}}; rec.AddLink(trace::SpanContext(false, false), - trace::KeyValueIterableView>(attributes)); + common::KeyValueIterableView>(attributes)); for (int i = 0; i < kNumAttributes; i++) { diff --git a/ext/include/opentelemetry/ext/zpages/threadsafe_span_data.h b/ext/include/opentelemetry/ext/zpages/threadsafe_span_data.h index 1c7595aae6..4d937bd8b7 100644 --- a/ext/include/opentelemetry/ext/zpages/threadsafe_span_data.h +++ b/ext/include/opentelemetry/ext/zpages/threadsafe_span_data.h @@ -17,7 +17,9 @@ using opentelemetry::sdk::trace::AttributeConverter; using opentelemetry::sdk::trace::SpanDataAttributeValue; using opentelemetry::sdk::trace::SpanDataEvent; -namespace trace_api = opentelemetry::trace; + +// TODO: Create generic short pattern for opentelemetry::common and opentelemetry::trace and others +// as necessary OPENTELEMETRY_BEGIN_NAMESPACE namespace ext @@ -137,7 +139,8 @@ class ThreadsafeSpanData final : public opentelemetry::sdk::trace::Recordable attributes_[std::string(key)] = nostd::visit(converter_, value); } - void SetStatus(trace_api::CanonicalCode code, nostd::string_view description) noexcept override + void SetStatus(opentelemetry::trace::CanonicalCode code, + nostd::string_view description) noexcept override { std::lock_guard lock(mutex_); status_code_ = code; @@ -162,10 +165,10 @@ class ThreadsafeSpanData final : public opentelemetry::sdk::trace::Recordable duration_ = duration; } - void AddLink( - opentelemetry::trace::SpanContext span_context, - const trace_api::KeyValueIterable &attributes = - trace_api::KeyValueIterableView>({})) noexcept override + void AddLink(opentelemetry::trace::SpanContext span_context, + const opentelemetry::common::KeyValueIterable &attributes = + opentelemetry::common::KeyValueIterableView>( + {})) noexcept override { std::lock_guard lock(mutex_); (void)span_context; @@ -175,8 +178,9 @@ class ThreadsafeSpanData final : public opentelemetry::sdk::trace::Recordable void AddEvent( nostd::string_view name, core::SystemTimestamp timestamp = core::SystemTimestamp(std::chrono::system_clock::now()), - const trace_api::KeyValueIterable &attributes = - trace_api::KeyValueIterableView>({})) noexcept override + const opentelemetry::common::KeyValueIterable &attributes = + opentelemetry::common::KeyValueIterableView>( + {})) noexcept override { std::lock_guard lock(mutex_); events_.push_back(SpanDataEvent(std::string(name), timestamp, attributes)); diff --git a/sdk/include/opentelemetry/sdk/common/empty_attributes.h b/sdk/include/opentelemetry/sdk/common/empty_attributes.h index b9741cd3a9..d030d2d118 100644 --- a/sdk/include/opentelemetry/sdk/common/empty_attributes.h +++ b/sdk/include/opentelemetry/sdk/common/empty_attributes.h @@ -1,4 +1,4 @@ -#include "opentelemetry/trace/key_value_iterable_view.h" +#include "opentelemetry/common/key_value_iterable_view.h" #include #include @@ -13,11 +13,11 @@ namespace sdk * This helps to avoid constructing a new empty container every time a call is made * with default attributes. */ -static const opentelemetry::trace::KeyValueIterableView, 0>> +static const opentelemetry::common::KeyValueIterableView, 0>> &GetEmptyAttributes() noexcept { static const std::array, 0> array{}; - static const opentelemetry::trace::KeyValueIterableView< + static const opentelemetry::common::KeyValueIterableView< std::array, 0>> kEmptyAttributes(array); diff --git a/sdk/include/opentelemetry/sdk/metrics/async_instruments.h b/sdk/include/opentelemetry/sdk/metrics/async_instruments.h index 9eccb86466..69a723bb62 100644 --- a/sdk/include/opentelemetry/sdk/metrics/async_instruments.h +++ b/sdk/include/opentelemetry/sdk/metrics/async_instruments.h @@ -46,7 +46,7 @@ class ValueObserver : public AsynchronousInstrument, virtual public metrics_a * @param value is the numerical representation of the metric being captured * @param labels the set of labels, as key-value pairs */ - virtual void observe(T value, const trace::KeyValueIterable &labels) override + virtual void observe(T value, const common::KeyValueIterable &labels) override { this->mu_.lock(); std::string labelset = KvToString(labels); @@ -121,7 +121,7 @@ class SumObserver : public AsynchronousInstrument, virtual public metrics_api * @param value is the numerical representation of the metric being captured * @param labels the set of labels, as key-value pairs */ - virtual void observe(T value, const trace::KeyValueIterable &labels) override + virtual void observe(T value, const common::KeyValueIterable &labels) override { this->mu_.lock(); std::string labelset = KvToString(labels); @@ -219,7 +219,7 @@ class UpDownSumObserver : public AsynchronousInstrument, * @param value is the numerical representation of the metric being captured * @param labels the set of labels, as key-value pairs */ - virtual void observe(T value, const trace::KeyValueIterable &labels) override + virtual void observe(T value, const common::KeyValueIterable &labels) override { this->mu_.lock(); std::string labelset = KvToString(labels); diff --git a/sdk/include/opentelemetry/sdk/metrics/controller.h b/sdk/include/opentelemetry/sdk/metrics/controller.h index 8a99012670..c36d789e72 100644 --- a/sdk/include/opentelemetry/sdk/metrics/controller.h +++ b/sdk/include/opentelemetry/sdk/metrics/controller.h @@ -14,7 +14,6 @@ #include "opentelemetry/version.h" namespace metrics_api = opentelemetry::metrics; -namespace trace_api = opentelemetry::trace; OPENTELEMETRY_BEGIN_NAMESPACE namespace sdk diff --git a/sdk/include/opentelemetry/sdk/metrics/instrument.h b/sdk/include/opentelemetry/sdk/metrics/instrument.h index 802e201bc6..41257541f3 100644 --- a/sdk/include/opentelemetry/sdk/metrics/instrument.h +++ b/sdk/include/opentelemetry/sdk/metrics/instrument.h @@ -13,7 +13,6 @@ #include "opentelemetry/version.h" namespace metrics_api = opentelemetry::metrics; -namespace trace_api = opentelemetry::trace; OPENTELEMETRY_BEGIN_NAMESPACE namespace sdk @@ -174,13 +173,13 @@ class SynchronousInstrument : public Instrument, * @return a Bound Instrument */ virtual nostd::shared_ptr> bind( - const trace::KeyValueIterable &labels) override + const common::KeyValueIterable &labels) override { return nostd::shared_ptr>(); } // This function is necessary for batch recording and should NOT be called by the user - virtual void update(T value, const trace::KeyValueIterable &labels) override = 0; + virtual void update(T value, const common::KeyValueIterable &labels) override = 0; /** * Checkpoints instruments and returns a set of records which are ready for processing. @@ -221,7 +220,7 @@ class AsynchronousInstrument : public Instrument, * @param labels is the numerical representation of the metric being captured * @return none */ - virtual void observe(T value, const trace::KeyValueIterable &labels) override = 0; + virtual void observe(T value, const common::KeyValueIterable &labels) override = 0; virtual std::vector GetRecords() = 0; @@ -236,7 +235,7 @@ class AsynchronousInstrument : public Instrument, virtual void run() override = 0; }; -// Helper functions for turning a trace::KeyValueIterable into a string +// Helper functions for turning a common::KeyValueIterable into a string inline void print_value(std::stringstream &ss, common::AttributeValue &value, bool jsonTypes = false) @@ -271,7 +270,7 @@ inline std::string mapToString(const std::map &conv) return ss.str(); } -inline std::string KvToString(const trace::KeyValueIterable &kv) noexcept +inline std::string KvToString(const common::KeyValueIterable &kv) noexcept { std::stringstream ss; ss << "{"; diff --git a/sdk/include/opentelemetry/sdk/metrics/meter.h b/sdk/include/opentelemetry/sdk/metrics/meter.h index 001866dd99..2f2592a858 100644 --- a/sdk/include/opentelemetry/sdk/metrics/meter.h +++ b/sdk/include/opentelemetry/sdk/metrics/meter.h @@ -253,19 +253,19 @@ class Meter : public metrics_api::Meter * @param values a span of pairs where the first element of the pair is a metric instrument * to record to, and the second element is the value to update that instrument with. */ - void RecordShortBatch(const trace::KeyValueIterable &labels, + void RecordShortBatch(const common::KeyValueIterable &labels, nostd::span *> instruments, nostd::span values) noexcept override; - void RecordIntBatch(const trace::KeyValueIterable &labels, + void RecordIntBatch(const common::KeyValueIterable &labels, nostd::span *> instruments, nostd::span values) noexcept override; - void RecordFloatBatch(const trace::KeyValueIterable &labels, + void RecordFloatBatch(const common::KeyValueIterable &labels, nostd::span *> instruments, nostd::span values) noexcept override; - void RecordDoubleBatch(const trace::KeyValueIterable &labels, + void RecordDoubleBatch(const common::KeyValueIterable &labels, nostd::span *> instruments, nostd::span values) noexcept override; diff --git a/sdk/include/opentelemetry/sdk/metrics/sync_instruments.h b/sdk/include/opentelemetry/sdk/metrics/sync_instruments.h index aab0c4e86f..14d15ccf22 100644 --- a/sdk/include/opentelemetry/sdk/metrics/sync_instruments.h +++ b/sdk/include/opentelemetry/sdk/metrics/sync_instruments.h @@ -90,7 +90,7 @@ class Counter final : public SynchronousInstrument, public metrics_api::Count */ virtual nostd::shared_ptr> bindCounter( - const trace::KeyValueIterable &labels) override + const common::KeyValueIterable &labels) override { this->mu_.lock(); std::string labelset = KvToString(labels); @@ -119,7 +119,7 @@ class Counter final : public SynchronousInstrument, public metrics_api::Count * @param value the numerical representation of the metric being captured * @param labels the set of labels, as key-value pairs */ - virtual void add(T value, const trace::KeyValueIterable &labels) override + virtual void add(T value, const common::KeyValueIterable &labels) override { if (value < 0) { @@ -163,7 +163,7 @@ class Counter final : public SynchronousInstrument, public metrics_api::Count return ret; } - virtual void update(T val, const trace::KeyValueIterable &labels) override { add(val, labels); } + virtual void update(T val, const common::KeyValueIterable &labels) override { add(val, labels); } // A collection of the bound instruments created by this unbound instrument identified by their // labels. @@ -228,7 +228,7 @@ class UpDownCounter final : public SynchronousInstrument, public metrics_api: * @return a BoundIntCounter tied to the specified labels */ nostd::shared_ptr> bindUpDownCounter( - const trace::KeyValueIterable &labels) override + const common::KeyValueIterable &labels) override { this->mu_.lock(); std::string labelset = KvToString(labels); @@ -257,7 +257,7 @@ class UpDownCounter final : public SynchronousInstrument, public metrics_api: * @param value the numerical representation of the metric being captured * @param labels the set of labels, as key-value pairs */ - void add(T value, const trace::KeyValueIterable &labels) override + void add(T value, const common::KeyValueIterable &labels) override { auto sp = bindUpDownCounter(labels); sp->update(value); @@ -290,7 +290,7 @@ class UpDownCounter final : public SynchronousInstrument, public metrics_api: return ret; } - virtual void update(T val, const trace::KeyValueIterable &labels) override { add(val, labels); } + virtual void update(T val, const common::KeyValueIterable &labels) override { add(val, labels); } std::unordered_map>> boundInstruments_; @@ -354,7 +354,7 @@ class ValueRecorder final : public SynchronousInstrument, public metrics_api: * @return a BoundIntCounter tied to the specified labels */ nostd::shared_ptr> bindValueRecorder( - const trace::KeyValueIterable &labels) override + const common::KeyValueIterable &labels) override { this->mu_.lock(); std::string labelset = KvToString(labels); @@ -383,7 +383,7 @@ class ValueRecorder final : public SynchronousInstrument, public metrics_api: * @param value the numerical representation of the metric being captured * @param labels the set of labels, as key-value pairs */ - void record(T value, const trace::KeyValueIterable &labels) override + void record(T value, const common::KeyValueIterable &labels) override { auto sp = bindValueRecorder(labels); sp->update(value); @@ -416,7 +416,7 @@ class ValueRecorder final : public SynchronousInstrument, public metrics_api: return ret; } - virtual void update(T value, const trace::KeyValueIterable &labels) override + virtual void update(T value, const common::KeyValueIterable &labels) override { record(value, labels); } diff --git a/sdk/include/opentelemetry/sdk/trace/attribute_utils.h b/sdk/include/opentelemetry/sdk/trace/attribute_utils.h index b836afbaee..2b1c082441 100644 --- a/sdk/include/opentelemetry/sdk/trace/attribute_utils.h +++ b/sdk/include/opentelemetry/sdk/trace/attribute_utils.h @@ -3,7 +3,7 @@ #include #include #include "opentelemetry/common/attribute_value.h" -#include "opentelemetry/trace/key_value_iterable_view.h" +#include "opentelemetry/common/key_value_iterable_view.h" OPENTELEMETRY_BEGIN_NAMESPACE namespace sdk @@ -94,7 +94,7 @@ class AttributeMap AttributeMap(){}; // Contruct attribute map and populate with attributes - AttributeMap(const opentelemetry::trace::KeyValueIterable &attributes) + AttributeMap(const opentelemetry::common::KeyValueIterable &attributes) { attributes.ForEachKeyValue([&](nostd::string_view key, opentelemetry::common::AttributeValue value) noexcept { diff --git a/sdk/include/opentelemetry/sdk/trace/recordable.h b/sdk/include/opentelemetry/sdk/trace/recordable.h index 68124db0e6..95c89c2ce5 100644 --- a/sdk/include/opentelemetry/sdk/trace/recordable.h +++ b/sdk/include/opentelemetry/sdk/trace/recordable.h @@ -1,11 +1,11 @@ #pragma once #include "opentelemetry/common/attribute_value.h" +#include "opentelemetry/common/key_value_iterable.h" #include "opentelemetry/core/timestamp.h" #include "opentelemetry/nostd/string_view.h" #include "opentelemetry/sdk/common/empty_attributes.h" #include "opentelemetry/trace/canonical_code.h" -#include "opentelemetry/trace/key_value_iterable.h" #include "opentelemetry/trace/span_context.h" #include "opentelemetry/trace/span_id.h" #include "opentelemetry/trace/trace_id.h" @@ -13,10 +13,11 @@ #include +// TODO: Create generic short pattern for opentelemetry::common and opentelemetry::trace + OPENTELEMETRY_BEGIN_NAMESPACE namespace sdk { -namespace trace_api = opentelemetry::trace; namespace trace { /** @@ -55,7 +56,7 @@ class Recordable */ virtual void AddEvent(nostd::string_view name, core::SystemTimestamp timestamp, - const trace_api::KeyValueIterable &attributes) noexcept = 0; + const opentelemetry::common::KeyValueIterable &attributes) noexcept = 0; /** * Add an event to a span with default timestamp and attributes. @@ -83,7 +84,7 @@ class Recordable * @param attributes the attributes associated with the link */ virtual void AddLink(opentelemetry::trace::SpanContext span_context, - const trace_api::KeyValueIterable &attributes) noexcept = 0; + const opentelemetry::common::KeyValueIterable &attributes) noexcept = 0; /** * Add a link to a span with default (empty) attributes. @@ -99,7 +100,7 @@ class Recordable * @param code the status code * @param description a description of the status */ - virtual void SetStatus(trace_api::CanonicalCode code, + virtual void SetStatus(opentelemetry::trace::CanonicalCode code, nostd::string_view description) noexcept = 0; /** diff --git a/sdk/include/opentelemetry/sdk/trace/sampler.h b/sdk/include/opentelemetry/sdk/trace/sampler.h index 45b5b6d5bf..dc084dca22 100644 --- a/sdk/include/opentelemetry/sdk/trace/sampler.h +++ b/sdk/include/opentelemetry/sdk/trace/sampler.h @@ -65,11 +65,12 @@ class Sampler * @since 0.1.0 */ - virtual SamplingResult ShouldSample(const trace_api::SpanContext &parent_context, - trace_api::TraceId trace_id, - nostd::string_view name, - trace_api::SpanKind span_kind, - const trace_api::KeyValueIterable &attributes) noexcept = 0; + virtual SamplingResult ShouldSample( + const trace_api::SpanContext &parent_context, + trace_api::TraceId trace_id, + nostd::string_view name, + trace_api::SpanKind span_kind, + const opentelemetry::common::KeyValueIterable &attributes) noexcept = 0; /** * Returns the sampler name or short description with the configuration. diff --git a/sdk/include/opentelemetry/sdk/trace/samplers/always_off.h b/sdk/include/opentelemetry/sdk/trace/samplers/always_off.h index e7943991d0..7fd862be89 100644 --- a/sdk/include/opentelemetry/sdk/trace/samplers/always_off.h +++ b/sdk/include/opentelemetry/sdk/trace/samplers/always_off.h @@ -19,11 +19,12 @@ class AlwaysOffSampler : public Sampler /** * @return Returns DROP always */ - SamplingResult ShouldSample(const trace_api::SpanContext & /*parent_context*/, - trace_api::TraceId /*trace_id*/, - nostd::string_view /*name*/, - trace_api::SpanKind /*span_kind*/, - const trace_api::KeyValueIterable & /*attributes*/) noexcept override + SamplingResult ShouldSample( + const trace_api::SpanContext & /*parent_context*/, + trace_api::TraceId /*trace_id*/, + nostd::string_view /*name*/, + trace_api::SpanKind /*span_kind*/, + const opentelemetry::common::KeyValueIterable & /*attributes*/) noexcept override { return {Decision::DROP, nullptr}; } diff --git a/sdk/include/opentelemetry/sdk/trace/samplers/always_on.h b/sdk/include/opentelemetry/sdk/trace/samplers/always_on.h index 729a9a12d7..0a75eb1e00 100644 --- a/sdk/include/opentelemetry/sdk/trace/samplers/always_on.h +++ b/sdk/include/opentelemetry/sdk/trace/samplers/always_on.h @@ -23,7 +23,7 @@ class AlwaysOnSampler : public Sampler trace_api::TraceId /*trace_id*/, nostd::string_view /*name*/, trace_api::SpanKind /*span_kind*/, - const trace_api::KeyValueIterable & /*attributes*/) noexcept override + const opentelemetry::common::KeyValueIterable & /*attributes*/) noexcept override { return {Decision::RECORD_AND_SAMPLE, nullptr}; } diff --git a/sdk/include/opentelemetry/sdk/trace/samplers/parent.h b/sdk/include/opentelemetry/sdk/trace/samplers/parent.h index 74272567f9..91337bd497 100644 --- a/sdk/include/opentelemetry/sdk/trace/samplers/parent.h +++ b/sdk/include/opentelemetry/sdk/trace/samplers/parent.h @@ -22,11 +22,12 @@ class ParentBasedSampler : public Sampler * delegateSampler for root spans * @return Returns DROP always */ - SamplingResult ShouldSample(const trace_api::SpanContext &parent_context, - trace_api::TraceId trace_id, - nostd::string_view name, - trace_api::SpanKind span_kind, - const trace_api::KeyValueIterable &attributes) noexcept override; + SamplingResult ShouldSample( + const trace_api::SpanContext &parent_context, + trace_api::TraceId trace_id, + nostd::string_view name, + trace_api::SpanKind span_kind, + const opentelemetry::common::KeyValueIterable &attributes) noexcept override; /** * @return Description MUST be ParentBased{delegate_sampler_.getDescription()} diff --git a/sdk/include/opentelemetry/sdk/trace/samplers/trace_id_ratio.h b/sdk/include/opentelemetry/sdk/trace/samplers/trace_id_ratio.h index a07de397e5..80be8ae80d 100644 --- a/sdk/include/opentelemetry/sdk/trace/samplers/trace_id_ratio.h +++ b/sdk/include/opentelemetry/sdk/trace/samplers/trace_id_ratio.h @@ -29,11 +29,12 @@ class TraceIdRatioBasedSampler : public Sampler * is used as a pseudorandom value in conjunction with the predefined * ratio to determine whether this trace should be sampled */ - SamplingResult ShouldSample(const trace_api::SpanContext & /*parent_context*/, - trace_api::TraceId trace_id, - nostd::string_view /*name*/, - trace_api::SpanKind /*span_kind*/, - const trace_api::KeyValueIterable & /*attributes*/) noexcept override; + SamplingResult ShouldSample( + const trace_api::SpanContext & /*parent_context*/, + trace_api::TraceId trace_id, + nostd::string_view /*name*/, + trace_api::SpanKind /*span_kind*/, + const opentelemetry::common::KeyValueIterable & /*attributes*/) noexcept override; /** * @return Description MUST be TraceIdRatioBasedSampler{0.000100} diff --git a/sdk/include/opentelemetry/sdk/trace/span_data.h b/sdk/include/opentelemetry/sdk/trace/span_data.h index b745a3f33f..6fde43c342 100644 --- a/sdk/include/opentelemetry/sdk/trace/span_data.h +++ b/sdk/include/opentelemetry/sdk/trace/span_data.h @@ -25,7 +25,7 @@ class SpanDataEvent public: SpanDataEvent(std::string name, core::SystemTimestamp timestamp, - const trace_api::KeyValueIterable &attributes) + const opentelemetry::common::KeyValueIterable &attributes) : name_(name), timestamp_(timestamp), attribute_map_(attributes) {} @@ -64,7 +64,7 @@ class SpanDataLink { public: SpanDataLink(opentelemetry::trace::SpanContext span_context, - const trace_api::KeyValueIterable &attributes) + const opentelemetry::common::KeyValueIterable &attributes) : span_context_(span_context), attribute_map_(attributes) {} @@ -174,20 +174,21 @@ class SpanData final : public Recordable void AddEvent(nostd::string_view name, core::SystemTimestamp timestamp, - const trace_api::KeyValueIterable &attributes) noexcept override + const opentelemetry::common::KeyValueIterable &attributes) noexcept override { SpanDataEvent event(std::string(name), timestamp, attributes); events_.push_back(event); } void AddLink(opentelemetry::trace::SpanContext span_context, - const trace_api::KeyValueIterable &attributes) noexcept override + const opentelemetry::common::KeyValueIterable &attributes) noexcept override { SpanDataLink link(span_context, attributes); links_.push_back(link); } - void SetStatus(trace_api::CanonicalCode code, nostd::string_view description) noexcept override + void SetStatus(opentelemetry::trace::CanonicalCode code, + nostd::string_view description) noexcept override { status_code_ = code; status_desc_ = std::string(description); diff --git a/sdk/include/opentelemetry/sdk/trace/tracer.h b/sdk/include/opentelemetry/sdk/trace/tracer.h index bb28842c75..42d16ce219 100644 --- a/sdk/include/opentelemetry/sdk/trace/tracer.h +++ b/sdk/include/opentelemetry/sdk/trace/tracer.h @@ -46,7 +46,7 @@ class Tracer final : public trace_api::Tracer, public std::enable_shared_from_th nostd::shared_ptr StartSpan( nostd::string_view name, - const trace_api::KeyValueIterable &attributes, + const opentelemetry::common::KeyValueIterable &attributes, const trace_api::StartSpanOptions &options = {}) noexcept override; void ForceFlushWithMicroseconds(uint64_t timeout) noexcept override; diff --git a/sdk/src/metrics/meter.cc b/sdk/src/metrics/meter.cc index 8d32b239e4..29a769628f 100644 --- a/sdk/src/metrics/meter.cc +++ b/sdk/src/metrics/meter.cc @@ -543,7 +543,7 @@ nostd::shared_ptr> Meter::NewDoubleValueObser return nostd::shared_ptr>(ptr); } -void Meter::RecordShortBatch(const trace::KeyValueIterable &labels, +void Meter::RecordShortBatch(const common::KeyValueIterable &labels, nostd::span *> instruments, nostd::span values) noexcept { @@ -553,7 +553,7 @@ void Meter::RecordShortBatch(const trace::KeyValueIterable &labels, } } -void Meter::RecordIntBatch(const trace::KeyValueIterable &labels, +void Meter::RecordIntBatch(const common::KeyValueIterable &labels, nostd::span *> instruments, nostd::span values) noexcept { @@ -563,7 +563,7 @@ void Meter::RecordIntBatch(const trace::KeyValueIterable &labels, } } -void Meter::RecordFloatBatch(const trace::KeyValueIterable &labels, +void Meter::RecordFloatBatch(const common::KeyValueIterable &labels, nostd::span *> instruments, nostd::span values) noexcept { @@ -573,7 +573,7 @@ void Meter::RecordFloatBatch(const trace::KeyValueIterable &labels, } } -void Meter::RecordDoubleBatch(const trace::KeyValueIterable &labels, +void Meter::RecordDoubleBatch(const common::KeyValueIterable &labels, nostd::span *> instruments, nostd::span values) noexcept { diff --git a/sdk/src/trace/samplers/parent.cc b/sdk/src/trace/samplers/parent.cc index f03f94cded..5385b3543e 100644 --- a/sdk/src/trace/samplers/parent.cc +++ b/sdk/src/trace/samplers/parent.cc @@ -15,7 +15,7 @@ SamplingResult ParentBasedSampler::ShouldSample( trace_api::TraceId trace_id, nostd::string_view name, trace_api::SpanKind span_kind, - const trace_api::KeyValueIterable &attributes) noexcept + const opentelemetry::common::KeyValueIterable &attributes) noexcept { if (!parent_context.IsValid()) { diff --git a/sdk/src/trace/samplers/trace_id_ratio.cc b/sdk/src/trace/samplers/trace_id_ratio.cc index a954238d99..f20246cb55 100644 --- a/sdk/src/trace/samplers/trace_id_ratio.cc +++ b/sdk/src/trace/samplers/trace_id_ratio.cc @@ -88,7 +88,7 @@ SamplingResult TraceIdRatioBasedSampler::ShouldSample( trace_api::TraceId trace_id, nostd::string_view /*name*/, trace_api::SpanKind /*span_kind*/, - const trace_api::KeyValueIterable & /*attributes*/) noexcept + const opentelemetry::common::KeyValueIterable & /*attributes*/) noexcept { if (threshold_ == 0) return {Decision::DROP, nullptr}; diff --git a/sdk/src/trace/span.cc b/sdk/src/trace/span.cc index 76418af1dd..417051e464 100644 --- a/sdk/src/trace/span.cc +++ b/sdk/src/trace/span.cc @@ -60,7 +60,7 @@ trace_api::SpanId GenerateRandomSpanId() Span::Span(std::shared_ptr &&tracer, std::shared_ptr processor, nostd::string_view name, - const trace_api::KeyValueIterable &attributes, + const opentelemetry::common::KeyValueIterable &attributes, const trace_api::StartSpanOptions &options, const trace_api::SpanContext &parent_span_context) noexcept : tracer_{std::move(tracer)}, @@ -138,7 +138,7 @@ void Span::AddEvent(nostd::string_view name, core::SystemTimestamp timestamp) no void Span::AddEvent(nostd::string_view name, core::SystemTimestamp timestamp, - const trace_api::KeyValueIterable &attributes) noexcept + const opentelemetry::common::KeyValueIterable &attributes) noexcept { std::lock_guard lock_guard{mu_}; if (recordable_ == nullptr) @@ -148,7 +148,8 @@ void Span::AddEvent(nostd::string_view name, recordable_->AddEvent(name, timestamp, attributes); } -void Span::SetStatus(trace_api::CanonicalCode code, nostd::string_view description) noexcept +void Span::SetStatus(opentelemetry::trace::CanonicalCode code, + nostd::string_view description) noexcept { std::lock_guard lock_guard{mu_}; if (recordable_ == nullptr) diff --git a/sdk/src/trace/span.h b/sdk/src/trace/span.h index 56baf8838f..f11711e2aa 100644 --- a/sdk/src/trace/span.h +++ b/sdk/src/trace/span.h @@ -18,7 +18,7 @@ class Span final : public trace_api::Span explicit Span(std::shared_ptr &&tracer, std::shared_ptr processor, nostd::string_view name, - const trace_api::KeyValueIterable &attributes, + const opentelemetry::common::KeyValueIterable &attributes, const trace_api::StartSpanOptions &options, const trace_api::SpanContext &parent_span_context) noexcept; @@ -33,7 +33,7 @@ class Span final : public trace_api::Span void AddEvent(nostd::string_view name, core::SystemTimestamp timestamp, - const trace_api::KeyValueIterable &attributes) noexcept override; + const opentelemetry::common::KeyValueIterable &attributes) noexcept override; void SetStatus(trace_api::CanonicalCode code, nostd::string_view description) noexcept override; diff --git a/sdk/src/trace/tracer.cc b/sdk/src/trace/tracer.cc index 6000a0444e..db88cc2b46 100644 --- a/sdk/src/trace/tracer.cc +++ b/sdk/src/trace/tracer.cc @@ -53,7 +53,7 @@ trace_api::SpanContext GetCurrentSpanContext(const trace_api::SpanContext &expli nostd::shared_ptr Tracer::StartSpan( nostd::string_view name, - const trace_api::KeyValueIterable &attributes, + const opentelemetry::common::KeyValueIterable &attributes, const trace_api::StartSpanOptions &options) noexcept { trace_api::SpanContext parent = GetCurrentSpanContext(options.parent); diff --git a/sdk/test/metrics/controller_test.cc b/sdk/test/metrics/controller_test.cc index 0dd14b7649..dad5012f9f 100644 --- a/sdk/test/metrics/controller_test.cc +++ b/sdk/test/metrics/controller_test.cc @@ -34,7 +34,7 @@ TEST(Controller, Constructor) auto instr = meter->NewIntCounter("test", "none", "none", true); std::map labels = {{"key", "value"}}; - auto labelkv = trace::KeyValueIterableView{labels}; + auto labelkv = common::KeyValueIterableView{labels}; alpha.start(); diff --git a/sdk/test/metrics/meter_test.cc b/sdk/test/metrics/meter_test.cc index b3cdc0ce39..b47b0d418a 100644 --- a/sdk/test/metrics/meter_test.cc +++ b/sdk/test/metrics/meter_test.cc @@ -69,7 +69,7 @@ TEST(Meter, CollectSyncInstruments) auto counter = m.NewShortCounter("Test-counter", "For testing", "Unitless", true); std::map labels = {{"Key", "Value"}}; - auto labelkv = opentelemetry::trace::KeyValueIterableView{labels}; + auto labelkv = opentelemetry::common::KeyValueIterableView{labels}; counter->add(1, labelkv); @@ -101,7 +101,7 @@ TEST(Meter, CollectDeletedSync) ASSERT_EQ(m.Collect().size(), 0); std::map labels = {{"Key", "Value"}}; - auto labelkv = opentelemetry::trace::KeyValueIterableView{labels}; + auto labelkv = opentelemetry::common::KeyValueIterableView{labels}; { auto counter = m.NewShortCounter("Test-counter", "For testing", "Unitless", true); counter->add(1, labelkv); @@ -118,7 +118,7 @@ TEST(Meter, CollectDeletedSync) void Callback(opentelemetry::metrics::ObserverResult result) { std::map labels = {{"key", "value"}}; - auto labelkv = trace::KeyValueIterableView{labels}; + auto labelkv = common::KeyValueIterableView{labels}; result.observe(1, labelkv); } @@ -134,7 +134,7 @@ TEST(Meter, CollectAsyncInstruments) m.NewShortSumObserver("Test-counter", "For testing", "Unitless", true, &ShortCallback); std::map labels = {{"Key", "Value"}}; - auto labelkv = opentelemetry::trace::KeyValueIterableView{labels}; + auto labelkv = opentelemetry::common::KeyValueIterableView{labels}; sumobs->observe(1, labelkv); @@ -166,7 +166,7 @@ TEST(Meter, CollectDeletedAsync) ASSERT_EQ(m.Collect().size(), 0); std::map labels = {{"Key", "Value"}}; - auto labelkv = opentelemetry::trace::KeyValueIterableView{labels}; + auto labelkv = opentelemetry::common::KeyValueIterableView{labels}; { auto sumobs = m.NewShortSumObserver("Test-counter", "For testing", "Unitless", true, &Callback); sumobs->observe(1, labelkv); @@ -191,7 +191,7 @@ TEST(Meter, RecordBatch) auto dcounter = m.NewDoubleCounter("Test-dcounter", "For testing", "Unitless", true); std::map labels = {{"Key", "Value"}}; - auto labelkv = opentelemetry::trace::KeyValueIterableView{labels}; + auto labelkv = opentelemetry::common::KeyValueIterableView{labels}; metrics_api::SynchronousInstrument *sinstr_arr[] = {scounter.get()}; short svalues_arr[] = {1}; @@ -246,7 +246,7 @@ TEST(Meter, DisableCollectSync) { Meter m("Test"); std::map labels = {{"Key", "Value"}}; - auto labelkv = opentelemetry::trace::KeyValueIterableView{labels}; + auto labelkv = opentelemetry::common::KeyValueIterableView{labels}; auto c = m.NewShortCounter("c", "", "", false); c->add(1, labelkv); ASSERT_EQ(m.Collect().size(), 0); @@ -256,7 +256,7 @@ TEST(Meter, DisableCollectAsync) { Meter m("Test"); std::map labels = {{"Key", "Value"}}; - auto labelkv = opentelemetry::trace::KeyValueIterableView{labels}; + auto labelkv = opentelemetry::common::KeyValueIterableView{labels}; auto c = m.NewShortValueObserver("c", "", "", false, &ShortCallback); c->observe(1, labelkv); ASSERT_EQ(m.Collect().size(), 0); diff --git a/sdk/test/metrics/metric_instrument_test.cc b/sdk/test/metrics/metric_instrument_test.cc index 28ca482375..9fd1c5c5a7 100644 --- a/sdk/test/metrics/metric_instrument_test.cc +++ b/sdk/test/metrics/metric_instrument_test.cc @@ -20,7 +20,7 @@ namespace metrics void ObserverConstructorCallback(metrics_api::ObserverResult result) { std::map labels = {{"key", "value"}}; - auto labelkv = trace::KeyValueIterableView{labels}; + auto labelkv = common::KeyValueIterableView{labels}; result.observe(1, labelkv); } @@ -31,7 +31,7 @@ TEST(ApiSdkConversion, async) new ValueObserver("ankit", "none", "unitles", true, &ObserverConstructorCallback)); std::map labels = {{"key587", "value264"}}; - auto labelkv = trace::KeyValueIterableView{labels}; + auto labelkv = common::KeyValueIterableView{labels}; alpha->observe(123456, labelkv); EXPECT_EQ(dynamic_cast *>(alpha.get())->GetRecords()[0].GetLabels(), @@ -50,7 +50,7 @@ TEST(IntValueObserver, InstrumentFunctions) ValueObserver alpha("enabled", "no description", "unitless", true, &ObserverConstructorCallback); std::map labels = {{"key", "value"}}; - auto labelkv = trace::KeyValueIterableView{labels}; + auto labelkv = common::KeyValueIterableView{labels}; EXPECT_EQ(alpha.GetName(), "enabled"); EXPECT_EQ(alpha.GetDescription(), "no description"); @@ -64,7 +64,7 @@ TEST(IntValueObserver, InstrumentFunctions) void ObserverCallback(std::shared_ptr> in, int freq, - const trace::KeyValueIterable &labels) + const common::KeyValueIterable &labels) { for (int i = 0; i < freq; i++) { @@ -74,7 +74,7 @@ void ObserverCallback(std::shared_ptr> in, void NegObserverCallback(std::shared_ptr> in, int freq, - const trace::KeyValueIterable &labels) + const common::KeyValueIterable &labels) { for (int i = 0; i < freq; i++) { @@ -89,8 +89,8 @@ TEST(IntValueObserver, StressObserve) std::map labels = {{"key", "value"}}; std::map labels1 = {{"key1", "value1"}}; - auto labelkv = trace::KeyValueIterableView{labels}; - auto labelkv1 = trace::KeyValueIterableView{labels1}; + auto labelkv = common::KeyValueIterableView{labels}; + auto labelkv1 = common::KeyValueIterableView{labels1}; std::thread first(ObserverCallback, alpha, 25, labelkv); // spawn new threads that call the callback @@ -116,7 +116,7 @@ TEST(IntValueObserver, StressObserve) void SumObserverCallback(std::shared_ptr> in, int freq, - const trace::KeyValueIterable &labels) + const common::KeyValueIterable &labels) { for (int i = 0; i < freq; i++) { @@ -131,8 +131,8 @@ TEST(IntSumObserver, StressObserve) std::map labels = {{"key", "value"}}; std::map labels1 = {{"key1", "value1"}}; - auto labelkv = trace::KeyValueIterableView{labels}; - auto labelkv1 = trace::KeyValueIterableView{labels1}; + auto labelkv = common::KeyValueIterableView{labels}; + auto labelkv1 = common::KeyValueIterableView{labels1}; std::thread first(SumObserverCallback, alpha, 100000, labelkv); std::thread second(SumObserverCallback, alpha, 100000, labelkv); @@ -148,7 +148,7 @@ TEST(IntSumObserver, StressObserve) void UpDownSumObserverCallback(std::shared_ptr> in, int freq, - const trace::KeyValueIterable &labels) + const common::KeyValueIterable &labels) { for (int i = 0; i < freq; i++) { @@ -158,7 +158,7 @@ void UpDownSumObserverCallback(std::shared_ptr> in, void NegUpDownSumObserverCallback(std::shared_ptr> in, int freq, - const trace::KeyValueIterable &labels) + const common::KeyValueIterable &labels) { for (int i = 0; i < freq; i++) { @@ -173,8 +173,8 @@ TEST(IntUpDownObserver, StressAdd) std::map labels = {{"key", "value"}}; std::map labels1 = {{"key1", "value1"}}; - auto labelkv = trace::KeyValueIterableView{labels}; - auto labelkv1 = trace::KeyValueIterableView{labels1}; + auto labelkv = common::KeyValueIterableView{labels}; + auto labelkv1 = common::KeyValueIterableView{labels1}; std::thread first(UpDownSumObserverCallback, alpha, 12340, labelkv); // spawn new threads that call the callback @@ -216,10 +216,10 @@ TEST(Counter, Binding) std::map labels2 = {{"key2", "value2"}, {"key3", "value3"}}; std::map labels3 = {{"key3", "value3"}, {"key2", "value2"}}; - auto labelkv = trace::KeyValueIterableView{labels}; - auto labelkv1 = trace::KeyValueIterableView{labels1}; - auto labelkv2 = trace::KeyValueIterableView{labels2}; - auto labelkv3 = trace::KeyValueIterableView{labels3}; + auto labelkv = common::KeyValueIterableView{labels}; + auto labelkv1 = common::KeyValueIterableView{labels1}; + auto labelkv2 = common::KeyValueIterableView{labels2}; + auto labelkv3 = common::KeyValueIterableView{labels3}; auto beta = alpha.bindCounter(labelkv); auto gamma = alpha.bindCounter(labelkv1); @@ -246,7 +246,7 @@ TEST(Counter, getAggsandnewupdate) std::map labels = {{"key3", "value3"}, {"key2", "value2"}}; - auto labelkv = trace::KeyValueIterableView{labels}; + auto labelkv = common::KeyValueIterableView{labels}; auto beta = alpha.bindCounter(labelkv); beta->add(1); beta->unbind(); @@ -263,7 +263,7 @@ TEST(Counter, getAggsandnewupdate) void CounterCallback(std::shared_ptr> in, int freq, - const trace::KeyValueIterable &labels) + const common::KeyValueIterable &labels) { for (int i = 0; i < freq; i++) { @@ -278,8 +278,8 @@ TEST(Counter, StressAdd) std::map labels = {{"key", "value"}}; std::map labels1 = {{"key1", "value1"}}; - auto labelkv = trace::KeyValueIterableView{labels}; - auto labelkv1 = trace::KeyValueIterableView{labels1}; + auto labelkv = common::KeyValueIterableView{labels}; + auto labelkv1 = common::KeyValueIterableView{labels1}; std::thread first(CounterCallback, alpha, 1000, labelkv); std::thread second(CounterCallback, alpha, 1000, labelkv); @@ -301,7 +301,7 @@ TEST(Counter, StressAdd) void UpDownCounterCallback(std::shared_ptr> in, int freq, - const trace::KeyValueIterable &labels) + const common::KeyValueIterable &labels) { for (int i = 0; i < freq; i++) { @@ -311,7 +311,7 @@ void UpDownCounterCallback(std::shared_ptr> in, void NegUpDownCounterCallback(std::shared_ptr> in, int freq, - const trace::KeyValueIterable &labels) + const common::KeyValueIterable &labels) { for (int i = 0; i < freq; i++) { @@ -326,8 +326,8 @@ TEST(IntUpDownCounter, StressAdd) std::map labels = {{"key", "value"}}; std::map labels1 = {{"key1", "value1"}}; - auto labelkv = trace::KeyValueIterableView{labels}; - auto labelkv1 = trace::KeyValueIterableView{labels1}; + auto labelkv = common::KeyValueIterableView{labels}; + auto labelkv1 = common::KeyValueIterableView{labels1}; std::thread first(UpDownCounterCallback, alpha, 12340, labelkv); // spawn new threads that call the callback @@ -354,7 +354,7 @@ TEST(IntUpDownCounter, StressAdd) void RecorderCallback(std::shared_ptr> in, int freq, - const trace::KeyValueIterable &labels) + const common::KeyValueIterable &labels) { for (int i = 0; i < freq; i++) { @@ -364,7 +364,7 @@ void RecorderCallback(std::shared_ptr> in, void NegRecorderCallback(std::shared_ptr> in, int freq, - const trace::KeyValueIterable &labels) + const common::KeyValueIterable &labels) { for (int i = 0; i < freq; i++) { @@ -379,8 +379,8 @@ TEST(IntValueRecorder, StressRecord) std::map labels = {{"key", "value"}}; std::map labels1 = {{"key1", "value1"}}; - auto labelkv = trace::KeyValueIterableView{labels}; - auto labelkv1 = trace::KeyValueIterableView{labels1}; + auto labelkv = common::KeyValueIterableView{labels}; + auto labelkv1 = common::KeyValueIterableView{labels1}; std::thread first(RecorderCallback, alpha, 25, labelkv); // spawn new threads that call the callback @@ -445,7 +445,7 @@ TEST(Instruments, NoUpdateNoRecord) std::map labels = {{"key", "value"}}; - auto labelkv = trace::KeyValueIterableView{labels}; + auto labelkv = common::KeyValueIterableView{labels}; EXPECT_EQ(alpha.GetRecords().size(), 0); alpha.add(1, labelkv); diff --git a/sdk/test/trace/always_off_sampler_test.cc b/sdk/test/trace/always_off_sampler_test.cc index 8b43831753..023cc45316 100644 --- a/sdk/test/trace/always_off_sampler_test.cc +++ b/sdk/test/trace/always_off_sampler_test.cc @@ -15,7 +15,7 @@ TEST(AlwaysOffSampler, ShouldSample) using M = std::map; M m1 = {{}}; - opentelemetry::trace::KeyValueIterableView view{m1}; + opentelemetry::common::KeyValueIterableView view{m1}; auto sampling_result = sampler.ShouldSample(SpanContext::GetInvalid(), trace_id, "", span_kind, view); diff --git a/sdk/test/trace/always_on_sampler_test.cc b/sdk/test/trace/always_on_sampler_test.cc index bc3dcfa8e6..31d3a2df01 100644 --- a/sdk/test/trace/always_on_sampler_test.cc +++ b/sdk/test/trace/always_on_sampler_test.cc @@ -23,7 +23,7 @@ TEST(AlwaysOnSampler, ShouldSample) auto sampling_result = sampler.ShouldSample( SpanContext::GetInvalid(), trace_id_invalid, "invalid trace id test", trace_api::SpanKind::kServer, - trace_api::KeyValueIterableView>(key_value_container)); + opentelemetry::common::KeyValueIterableView>(key_value_container)); ASSERT_EQ(Decision::RECORD_AND_SAMPLE, sampling_result.decision); ASSERT_EQ(nullptr, sampling_result.attributes); @@ -32,7 +32,7 @@ TEST(AlwaysOnSampler, ShouldSample) sampling_result = sampler.ShouldSample( SpanContext::GetInvalid(), trace_id_valid, "valid trace id test", trace_api::SpanKind::kServer, - trace_api::KeyValueIterableView>(key_value_container)); + opentelemetry::common::KeyValueIterableView>(key_value_container)); ASSERT_EQ(Decision::RECORD_AND_SAMPLE, sampling_result.decision); ASSERT_EQ(nullptr, sampling_result.attributes); diff --git a/sdk/test/trace/attribute_utils_test.cc b/sdk/test/trace/attribute_utils_test.cc index 43d6fd048c..7a3a753b29 100644 --- a/sdk/test/trace/attribute_utils_test.cc +++ b/sdk/test/trace/attribute_utils_test.cc @@ -16,7 +16,7 @@ TEST(AttributeMapTest, AttributesConstruction) std::map attributes = { {keys[0], values[0]}, {keys[1], values[1]}, {keys[2], values[2]}}; - opentelemetry::trace::KeyValueIterableView> iterable(attributes); + opentelemetry::common::KeyValueIterableView> iterable(attributes); opentelemetry::sdk::trace::AttributeMap map(iterable); for (int i = 0; i < kNumAttributes; i++) diff --git a/sdk/test/trace/parent_sampler_test.cc b/sdk/test/trace/parent_sampler_test.cc index b43eafa938..59eae3b293 100644 --- a/sdk/test/trace/parent_sampler_test.cc +++ b/sdk/test/trace/parent_sampler_test.cc @@ -24,7 +24,7 @@ TEST(ParentBasedSampler, ShouldSample) opentelemetry::trace::SpanKind span_kind = opentelemetry::trace::SpanKind::kInternal; using M = std::map; M m1 = {{}}; - opentelemetry::trace::KeyValueIterableView view{m1}; + opentelemetry::common::KeyValueIterableView view{m1}; trace_api::SpanContext parent_context_sampled(trace_id, span_id, trace_api::TraceFlags{1}, false); trace_api::SpanContext parent_context_nonsampled(trace_id, span_id, trace_api::TraceFlags{0}, false); diff --git a/sdk/test/trace/sampler_benchmark.cc b/sdk/test/trace/sampler_benchmark.cc index 1a39615e78..f8d59a315b 100644 --- a/sdk/test/trace/sampler_benchmark.cc +++ b/sdk/test/trace/sampler_benchmark.cc @@ -64,7 +64,7 @@ void BenchmarkShouldSampler(Sampler &sampler, benchmark::State &state) using M = std::map; M m1 = {{}}; - opentelemetry::trace::KeyValueIterableView view{m1}; + opentelemetry::common::KeyValueIterableView view{m1}; while (state.KeepRunning()) { diff --git a/sdk/test/trace/span_data_test.cc b/sdk/test/trace/span_data_test.cc index a8cf244aed..36db80904c 100644 --- a/sdk/test/trace/span_data_test.cc +++ b/sdk/test/trace/span_data_test.cc @@ -65,7 +65,7 @@ TEST(SpanData, EventAttributes) data.AddEvent( "Test Event", std::chrono::system_clock::now(), - opentelemetry::trace::KeyValueIterableView>(attributes)); + opentelemetry::common::KeyValueIterableView>(attributes)); for (int i = 0; i < kNumAttributes; i++) { @@ -86,7 +86,7 @@ TEST(SpanData, Links) data.AddLink( opentelemetry::trace::SpanContext(false, false), - opentelemetry::trace::KeyValueIterableView>(attributes)); + opentelemetry::common::KeyValueIterableView>(attributes)); for (int i = 0; i < kNumAttributes; i++) { diff --git a/sdk/test/trace/trace_id_ratio_sampler_test.cc b/sdk/test/trace/trace_id_ratio_sampler_test.cc index db5b2b952c..f60c002804 100644 --- a/sdk/test/trace/trace_id_ratio_sampler_test.cc +++ b/sdk/test/trace/trace_id_ratio_sampler_test.cc @@ -34,7 +34,7 @@ int RunShouldSampleCountDecision(trace_api::SpanContext &context, using M = std::map; M m1 = {{}}; - opentelemetry::trace::KeyValueIterableView view{m1}; + opentelemetry::common::KeyValueIterableView view{m1}; for (int i = 0; i < iterations; ++i) { @@ -62,7 +62,7 @@ TEST(TraceIdRatioBasedSampler, ShouldSampleWithoutContext) using M = std::map; M m1 = {{}}; - opentelemetry::trace::KeyValueIterableView view{m1}; + opentelemetry::common::KeyValueIterableView view{m1}; TraceIdRatioBasedSampler s1(0.01); @@ -122,7 +122,7 @@ TEST(TraceIdRatioBasedSampler, ShouldSampleWithContext) using M = std::map; M m1 = {{}}; - opentelemetry::trace::KeyValueIterableView view{m1}; + opentelemetry::common::KeyValueIterableView view{m1}; TraceIdRatioBasedSampler s1(0.01); diff --git a/sdk/test/trace/tracer_test.cc b/sdk/test/trace/tracer_test.cc index 963d70b5e8..cc21a15b2f 100644 --- a/sdk/test/trace/tracer_test.cc +++ b/sdk/test/trace/tracer_test.cc @@ -23,11 +23,12 @@ using opentelemetry::trace::SpanContext; class MockSampler final : public Sampler { public: - SamplingResult ShouldSample(const SpanContext & /*parent_context*/, - trace_api::TraceId /*trace_id*/, - nostd::string_view /*name*/, - trace_api::SpanKind /*span_kind*/, - const trace_api::KeyValueIterable & /*attributes*/) noexcept override + SamplingResult ShouldSample( + const SpanContext & /*parent_context*/, + trace_api::TraceId /*trace_id*/, + nostd::string_view /*name*/, + trace_api::SpanKind /*span_kind*/, + const opentelemetry::common::KeyValueIterable & /*attributes*/) noexcept override { // Return two pairs of attributes. These attributes should be added to the // span attributes