Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move KeyValueIterable and KeyValueIterableView from trace to common #2

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -30,5 +30,5 @@ class KeyValueIterable
*/
virtual size_t size() const noexcept = 0;
};
} // namespace trace
} // namespace common
OPENTELEMETRY_END_NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
#include <type_traits>
#include <utility>

#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
{
Expand Down Expand Up @@ -60,5 +60,5 @@ class KeyValueIterableView final : public KeyValueIterable
private:
const T *container_;
};
} // namespace trace
} // namespace common
OPENTELEMETRY_END_NAMESPACE
6 changes: 3 additions & 3 deletions api/include/opentelemetry/metrics/async_instruments.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class ValueObserver : virtual public AsynchronousInstrument<T>
* @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
Expand All @@ -55,7 +55,7 @@ class SumObserver : virtual public AsynchronousInstrument<T>
void (*callback)(ObserverResult<T>))
{}

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;
};
Expand All @@ -74,7 +74,7 @@ class UpDownSumObserver : virtual public AsynchronousInstrument<T>
void (*callback)(ObserverResult<T>))
{}

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;
};
Expand Down
8 changes: 4 additions & 4 deletions api/include/opentelemetry/metrics/instrument.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

#include <iostream>
#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
Expand Down Expand Up @@ -135,7 +135,7 @@ class SynchronousInstrument : virtual public Instrument
* @return a Bound Instrument
*/
virtual nostd::shared_ptr<BoundSynchronousInstrument<T>> bind(
const trace::KeyValueIterable &labels)
const common::KeyValueIterable &labels)
{
return nostd::shared_ptr<BoundSynchronousInstrument<T>>();
}
Expand All @@ -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 <class T>
Expand Down Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions api/include/opentelemetry/metrics/meter.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<SynchronousInstrument<short> *> instruments,
nostd::span<const short> values) noexcept = 0;

virtual void RecordIntBatch(const trace::KeyValueIterable &labels,
virtual void RecordIntBatch(const common::KeyValueIterable &labels,
nostd::span<SynchronousInstrument<int> *> instruments,
nostd::span<const int> values) noexcept = 0;

virtual void RecordFloatBatch(const trace::KeyValueIterable &labels,
virtual void RecordFloatBatch(const common::KeyValueIterable &labels,
nostd::span<SynchronousInstrument<float> *> instruments,
nostd::span<const float> values) noexcept = 0;

virtual void RecordDoubleBatch(const trace::KeyValueIterable &labels,
virtual void RecordDoubleBatch(const common::KeyValueIterable &labels,
nostd::span<SynchronousInstrument<double> *> instruments,
nostd::span<const double> values) noexcept = 0;
};
Expand Down
33 changes: 17 additions & 16 deletions api/include/opentelemetry/metrics/noop.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class NoopValueObserver : public ValueObserver<T>

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 {}

Expand All @@ -65,7 +65,7 @@ class NoopSumObserver : public SumObserver<T>

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 {}

Expand All @@ -92,7 +92,7 @@ class NoopUpDownSumObserver : public UpDownSumObserver<T>

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 {}

Expand Down Expand Up @@ -138,14 +138,15 @@ class NoopCounter : public Counter<T>
bool /*enabled*/)
{}

nostd::shared_ptr<BoundNoopCounter<T>> bindNoopCounter(const trace::KeyValueIterable & /*labels*/)
nostd::shared_ptr<BoundNoopCounter<T>> bindNoopCounter(
const common::KeyValueIterable & /*labels*/)
{
return nostd::shared_ptr<BoundNoopCounter<T>>(new BoundNoopCounter<T>());
}

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; }

Expand Down Expand Up @@ -198,14 +199,14 @@ class NoopUpDownCounter : public UpDownCounter<T>
{}

nostd::shared_ptr<BoundNoopUpDownCounter<T>> bindNoopUpDownCounter(
const trace::KeyValueIterable & /*labels*/)
const common::KeyValueIterable & /*labels*/)
{
return nostd::shared_ptr<BoundNoopUpDownCounter<T>>(new BoundNoopUpDownCounter<T>());
}

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; }

Expand Down Expand Up @@ -258,14 +259,14 @@ class NoopValueRecorder : public ValueRecorder<T>
{}

nostd::shared_ptr<BoundNoopValueRecorder<T>> bindNoopValueRecorder(
const trace::KeyValueIterable & /*labels*/)
const common::KeyValueIterable & /*labels*/)
{
return nostd::shared_ptr<BoundNoopValueRecorder<T>>(new BoundNoopValueRecorder<T>());
}

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; }

Expand Down Expand Up @@ -602,28 +603,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<SynchronousInstrument<short> *> instruments,
nostd::span<const short> values) noexcept override
{
// No-op
}

void RecordIntBatch(const trace::KeyValueIterable &labels,
void RecordIntBatch(const common::KeyValueIterable &labels,
nostd::span<SynchronousInstrument<int> *> instruments,
nostd::span<const int> values) noexcept override
{
// No-op
}

void RecordFloatBatch(const trace::KeyValueIterable &labels,
void RecordFloatBatch(const common::KeyValueIterable &labels,
nostd::span<SynchronousInstrument<float> *> instruments,
nostd::span<const float> values) noexcept override
{
// No-op
}

void RecordDoubleBatch(const trace::KeyValueIterable &labels,
void RecordDoubleBatch(const common::KeyValueIterable &labels,
nostd::span<SynchronousInstrument<double> *> instruments,
nostd::span<const double> values) noexcept override
{
Expand Down
2 changes: 1 addition & 1 deletion api/include/opentelemetry/metrics/observer_result.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class ObserverResult

ObserverResult(AsynchronousInstrument<T> *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);
}
Expand Down
18 changes: 9 additions & 9 deletions api/include/opentelemetry/metrics/sync_instruments.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class Counter : virtual public SynchronousInstrument<T>
* @param labels the set of labels, as key-value pairs.
* @return a BoundIntCounter tied to the specified labels
*/
virtual nostd::shared_ptr<BoundCounter<T>> bindCounter(const trace::KeyValueIterable &labels)
virtual nostd::shared_ptr<BoundCounter<T>> bindCounter(const common::KeyValueIterable &labels)
{
return nostd::shared_ptr<BoundCounter<T>>();
}
Expand All @@ -61,9 +61,9 @@ class Counter : virtual public SynchronousInstrument<T>
* @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 <class T>
Expand Down Expand Up @@ -101,7 +101,7 @@ class UpDownCounter : virtual public SynchronousInstrument<T>
bool enabled);

virtual nostd::shared_ptr<BoundUpDownCounter<T>> bindUpDownCounter(
const trace::KeyValueIterable &labels)
const common::KeyValueIterable &labels)
{
return nostd::shared_ptr<BoundUpDownCounter<T>>();
}
Expand All @@ -114,9 +114,9 @@ class UpDownCounter : virtual public SynchronousInstrument<T>
* @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 <class T>
Expand Down Expand Up @@ -154,7 +154,7 @@ class ValueRecorder : virtual public SynchronousInstrument<T>
bool enabled);

virtual nostd::shared_ptr<BoundValueRecorder<T>> bindValueRecorder(
const trace::KeyValueIterable &labels)
const common::KeyValueIterable &labels)
{
return nostd::shared_ptr<BoundValueRecorder<T>>();
}
Expand All @@ -167,9 +167,9 @@ class ValueRecorder : virtual public SynchronousInstrument<T>
* @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
Expand Down
5 changes: 3 additions & 2 deletions api/include/opentelemetry/plugin/tracer.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

#include <memory>

#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"
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -66,7 +67,7 @@ class Tracer final : public trace::Tracer, public std::enable_shared_from_this<T
// trace::Tracer
nostd::shared_ptr<trace::Span> 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);
Expand Down
4 changes: 2 additions & 2 deletions api/include/opentelemetry/trace/default_span.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
2 changes: 1 addition & 1 deletion api/include/opentelemetry/trace/default_tracer.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class DefaultTracer : public Tracer
* key will be overwritten.
*/
nostd::unique_ptr<Span> StartSpan(nostd::string_view name,
const KeyValueIterable &attributes,
const common::KeyValueIterable &attributes,
const StartSpanOptions &options = {}) override noexcept
{
return nostd::unique_ptr<Span>(new DefaultSpan::GetInvalid());
Expand Down
4 changes: 2 additions & 2 deletions api/include/opentelemetry/trace/noop.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 {}
Expand All @@ -65,7 +65,7 @@ class NoopTracer final : public Tracer, public std::enable_shared_from_this<Noop
public:
// Tracer
nostd::shared_ptr<Span> 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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@
#include <iostream>
#include <map>
#include <string>
#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"
Expand Down
Loading