Skip to content

Commit

Permalink
modified structure
Browse files Browse the repository at this point in the history
  • Loading branch information
ankit-bhargava committed Jul 24, 2020
1 parent 07bde38 commit 949e861
Show file tree
Hide file tree
Showing 6 changed files with 672 additions and 561 deletions.
112 changes: 61 additions & 51 deletions api/include/opentelemetry/metrics/async_instruments.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,69 +8,79 @@ namespace metrics
{

template <class T>
class ValueObserver : public AsynchronousInstrument<T>
class ValueObserver : virtual public AsynchronousInstrument<T>
{

public:
ValueObserver() = default;

ValueObserver(nostd::string_view name,
nostd::string_view description,
nostd::string_view unit,
bool enabled,
void (*callback)(ObserverResult<T>))
{}

/*
* Updates the instruments aggregator with the new value. The labels should
* contain the keys and values to be associated with this value.
*
* @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) {}
ValueObserver() = default;

ValueObserver(nostd::string_view name,
nostd::string_view description,
nostd::string_view unit,
bool enabled,
void (*callback)(ObserverResult<T>))
{}

/*
* Updates the instruments aggregator with the new value. The labels should
* contain the keys and values to be associated with this value.
*
* @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;

/**
* Captures data by activating the callback function associated with the
* instrument and storing its return value. Callbacks for asynchronous
* instruments are defined during construction.
*
* @param none
* @return none
*/
virtual void run () override = 0;

};

template <class T>
class SumObserver : public AsynchronousInstrument<T>
class SumObserver : virtual public AsynchronousInstrument<T>
{

public:
SumObserver() = default;

SumObserver(nostd::string_view name,
nostd::string_view description,
nostd::string_view unit,
bool enabled,
void (*callback)(ObserverResult<T>))
{}

/*
* Add adds the value to the counter's sum. The labels should contain
* the keys and values to be associated with this value. Counters only * accept positive
* valued updates.
*
* @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) {}
SumObserver() = default;

SumObserver(nostd::string_view name,
nostd::string_view description,
nostd::string_view unit,
bool enabled,
void (*callback)(ObserverResult<T>))
{}


virtual void observe(T value, const trace::KeyValueIterable &labels) override = 0;

virtual void run() override = 0;

};

template <class T>
class UpDownSumObserver : public AsynchronousInstrument<T>
class UpDownSumObserver : virtual public AsynchronousInstrument<T>
{

public:
UpDownSumObserver() = default;

UpDownSumObserver(nostd::string_view name,
nostd::string_view description,
nostd::string_view unit,
bool enabled,
void (*callback)(ObserverResult<T>))
{}

virtual void observe(int value, const trace::KeyValueIterable &labels) {}
UpDownSumObserver() = default;

UpDownSumObserver(nostd::string_view name,
nostd::string_view description,
nostd::string_view unit,
bool enabled,
void (*callback)(ObserverResult<T>))
{}

virtual void observe(T value, const trace::KeyValueIterable &labels) override = 0;

virtual void run() override = 0;

};

} // namespace metrics
Expand Down
Loading

0 comments on commit 949e861

Please sign in to comment.