Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
a0af8c5
Create meter.h
Brandon-Kimberly Jul 1, 2020
f4921e4
Create noop.h
Brandon-Kimberly Jul 1, 2020
f71aafe
Create key_value_iterable.h
Brandon-Kimberly Jul 1, 2020
e36cc8e
Create key_value_iterable_view.h
Brandon-Kimberly Jul 1, 2020
a41e0f9
Create noop_test_metrics.cc
Brandon-Kimberly Jul 1, 2020
03d4841
Create CMakeLists.txt
Brandon-Kimberly Jul 1, 2020
00f04b7
Create BUILD
Brandon-Kimberly Jul 1, 2020
ba62dec
Make function RecordBatch public
Brandon-Kimberly Jul 1, 2020
a7638b5
Add callback to async functions
Brandon-Kimberly Jul 2, 2020
22a9f3a
Remove comments and add callback to async functions
Brandon-Kimberly Jul 2, 2020
39332ff
Pass KeyValueIterable view not direct data struct
Brandon-Kimberly Jul 2, 2020
c4e8d74
Changed unique_ptr to shared_ptr
Brandon-Kimberly Jul 3, 2020
faa9b1a
Change unique_ptr to shared_ptr
Brandon-Kimberly Jul 3, 2020
4c578fa
Replace mistakenly deleted lines
Brandon-Kimberly Jul 3, 2020
07b308f
Refactor test and rename file
Brandon-Kimberly Jul 3, 2020
ef67e99
Rename noop test
Brandon-Kimberly Jul 3, 2020
bc347e7
Rename noop test
Brandon-Kimberly Jul 3, 2020
a7b8e81
Run on pushes to Meter branch for testing
Brandon-Kimberly Jul 3, 2020
2e7ff6c
Add metrics subdirectory
Brandon-Kimberly Jul 3, 2020
eb0193f
Delete key_value_iterable.h
Brandon-Kimberly Jul 7, 2020
5d20af1
Delete key_value_iterable_view.h
Brandon-Kimberly Jul 7, 2020
ad110b2
Replace KeyValueIterable with span of pairs
Brandon-Kimberly Jul 7, 2020
998f1ca
Replace KeyValueIterable and format
Brandon-Kimberly Jul 7, 2020
8780d19
Add RecordBatch test
Brandon-Kimberly Jul 7, 2020
13bc1b3
Change test prefix from trace. to metrics.
Brandon-Kimberly Jul 7, 2020
052889e
Change labels in RecordBatch from string_view to KeyValueIterable
Brandon-Kimberly Jul 7, 2020
fe29603
Add namespace and change labels to KeyValueIterable
Brandon-Kimberly Jul 7, 2020
075a542
Update comments
Brandon-Kimberly Jul 7, 2020
0ecc121
Remove CI running on Meter pushes
Brandon-Kimberly Jul 7, 2020
7f5f7ac
Test BatchRecord and remove observer tests
Brandon-Kimberly Jul 8, 2020
3600ee4
Add overloaded BatchRecord functions
Brandon-Kimberly Jul 9, 2020
f4e2740
Update noop_metrics_test.cc
Brandon-Kimberly Jul 9, 2020
9c825cc
Update comments
Brandon-Kimberly Jul 9, 2020
6f4f9c2
Template Meter class
Brandon-Kimberly Jul 15, 2020
8426b08
Template Noop Meter class
Brandon-Kimberly Jul 15, 2020
28ca75d
Switch to use template noop meter class
Brandon-Kimberly Jul 15, 2020
afebf75
Refactored to integrate with instrument classes
Brandon-Kimberly Jul 25, 2020
e75ba61
Update to match func signatures of Meter class
Brandon-Kimberly Jul 25, 2020
0386da3
Update function args to match updates to NoopMeter
Brandon-Kimberly Jul 25, 2020
a3bd972
Update RecordBatch calls
Brandon-Kimberly Jul 26, 2020
8a0295d
Remove overloaded RecordBatch functions
Brandon-Kimberly Jul 26, 2020
af71ffc
Undo previous commit
Brandon-Kimberly Jul 26, 2020
1f72e8b
Update RecordBatch parameters
Brandon-Kimberly Jul 26, 2020
ff302b4
Add explicit casting to RecordBatch tests
Brandon-Kimberly Jul 28, 2020
cf0788e
Format
Brandon-Kimberly Jul 29, 2020
33407dd
Change RecordBatch to remove pointer_casting
Brandon-Kimberly Jul 30, 2020
5e55c9b
Merge branch 'master' into meter
Brandon-Kimberly Jul 30, 2020
d4a527b
Format
Brandon-Kimberly Jul 30, 2020
69d5f08
Merge branch 'master' into meter
Brandon-Kimberly Jul 30, 2020
8f05585
Add Meter SDK Stub to pass tests
Brandon-Kimberly Jul 30, 2020
6391b48
Add private vars
Brandon-Kimberly Jul 30, 2020
e9a11fa
Format
Brandon-Kimberly Jul 30, 2020
45c0f74
Add stub returns to pass CI
Brandon-Kimberly Jul 30, 2020
cb737d1
Format
Brandon-Kimberly Jul 30, 2020
aeb2552
Merge branch 'master' into meter
reyang Aug 3, 2020
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
276 changes: 271 additions & 5 deletions api/include/opentelemetry/metrics/meter.h
Original file line number Diff line number Diff line change
@@ -1,17 +1,283 @@
#pragma once

#include "opentelemetry/metrics/async_instruments.h"
#include "opentelemetry/metrics/instrument.h"
#include "opentelemetry/metrics/sync_instruments.h"
#include "opentelemetry/nostd/shared_ptr.h"
#include "opentelemetry/nostd/span.h"
#include "opentelemetry/nostd/string_view.h"
#include "opentelemetry/version.h"

OPENTELEMETRY_BEGIN_NAMESPACE

namespace metrics
{

/**
* Handles instrument creation and provides a facility for batch recording.
*
* This class provides methods to create new metric instruments, record a
* batch of values to a specified set of instruments, and collect
* measurements from all instruments.
*
*/
class Meter
{
public:
Meter() = default;
};
virtual ~Meter() = default;

} // namespace metrics
/**
* Creates a Counter with the passed characteristics and returns a shared_ptr to that Counter.
*
* @param name the name of the new Counter.
* @param description a brief description of what the Counter is used for.
* @param unit the unit of metric values following https://unitsofmeasure.org/ucum.html.
* @param enabled a boolean value that turns on or off the metric instrument.
* @return a shared pointer to the created Counter.
* @throws NullPointerException if {@code name} is null
* @throws IllegalArgumentException if a different metric by the same name exists in this meter.
* @throws IllegalArgumentException if the {@code name} does not match spec requirements.
*/
virtual nostd::shared_ptr<Counter<short>> NewShortCounter(nostd::string_view name,
nostd::string_view description,
nostd::string_view unit,
const bool enabled) = 0;

virtual nostd::shared_ptr<Counter<int>> NewIntCounter(nostd::string_view name,
nostd::string_view description,
nostd::string_view unit,
const bool enabled) = 0;

virtual nostd::shared_ptr<Counter<float>> NewFloatCounter(nostd::string_view name,
nostd::string_view description,
nostd::string_view unit,
const bool enabled) = 0;

virtual nostd::shared_ptr<Counter<double>> NewDoubleCounter(nostd::string_view name,
nostd::string_view description,
nostd::string_view unit,
const bool enabled) = 0;

/**
* Creates an UpDownCounter with the passed characteristics and returns a shared_ptr to that
* UpDownCounter.
*
* @param name the name of the new UpDownCounter.
* @param description a brief description of what the UpDownCounter is used for.
* @param unit the unit of metric values following https://unitsofmeasure.org/ucum.html.
* @param enabled a boolean value that turns on or off the metric instrument.
* @return a shared pointer to the created UpDownCounter.
* @throws NullPointerException if {@code name} is null
* @throws IllegalArgumentException if a different metric by the same name exists in this meter.
* @throws IllegalArgumentException if the {@code name} does not match spec requirements.
*/
virtual nostd::shared_ptr<UpDownCounter<short>> NewShortUpDownCounter(
nostd::string_view name,
nostd::string_view description,
nostd::string_view unit,
const bool enabled) = 0;

virtual nostd::shared_ptr<UpDownCounter<int>> NewIntUpDownCounter(nostd::string_view name,
nostd::string_view description,
nostd::string_view unit,
const bool enabled) = 0;

virtual nostd::shared_ptr<UpDownCounter<float>> NewFloatUpDownCounter(
nostd::string_view name,
nostd::string_view description,
nostd::string_view unit,
const bool enabled) = 0;

virtual nostd::shared_ptr<UpDownCounter<double>> NewDoubleUpDownCounter(
nostd::string_view name,
nostd::string_view description,
nostd::string_view unit,
const bool enabled) = 0;

/**
* Creates a ValueRecorder with the passed characteristics and returns a shared_ptr to that
* ValueRecorder.
*
* @param name the name of the new ValueRecorder.
* @param description a brief description of what the ValueRecorder is used for.
* @param unit the unit of metric values following https://unitsofmeasure.org/ucum.html.
* @param enabled a boolean value that turns on or off the metric instrument.
* @return a shared pointer to the created DoubleValueRecorder.
* @throws NullPointerException if {@code name} is null
* @throws IllegalArgumentException if a different metric by the same name exists in this meter.
* @throws IllegalArgumentException if the {@code name} does not match spec requirements.
*/
virtual nostd::shared_ptr<ValueRecorder<short>> NewShortValueRecorder(
nostd::string_view name,
nostd::string_view description,
nostd::string_view unit,
const bool enabled) = 0;

virtual nostd::shared_ptr<ValueRecorder<int>> NewIntValueRecorder(nostd::string_view name,
nostd::string_view description,
nostd::string_view unit,
const bool enabled) = 0;

virtual nostd::shared_ptr<ValueRecorder<float>> NewFloatValueRecorder(
nostd::string_view name,
nostd::string_view description,
nostd::string_view unit,
const bool enabled) = 0;

virtual nostd::shared_ptr<ValueRecorder<double>> NewDoubleValueRecorder(
nostd::string_view name,
nostd::string_view description,
nostd::string_view unit,
const bool enabled) = 0;

/**
* Creates a SumObserver with the passed characteristics and returns a shared_ptr to that
* SumObserver.
*
* @param name the name of the new SumObserver.
* @param description a brief description of what the SumObserver is used for.
* @param unit the unit of metric values following https://unitsofmeasure.org/ucum.html.
* @param enabled a boolean value that turns on or off the metric instrument.
* @param callback the function to be observed by the instrument.
* @return a shared pointer to the created SumObserver.
* @throws NullPointerException if {@code name} is null
* @throws IllegalArgumentException if a different metric by the same name exists in this meter.
* @throws IllegalArgumentException if the {@code name} does not match spec requirements.
*/
virtual nostd::shared_ptr<SumObserver<short>> NewShortSumObserver(
nostd::string_view name,
nostd::string_view description,
nostd::string_view unit,
const bool enabled,
void (*callback)(ObserverResult<short>)) = 0;

virtual nostd::shared_ptr<SumObserver<int>> NewIntSumObserver(
nostd::string_view name,
nostd::string_view description,
nostd::string_view unit,
const bool enabled,
void (*callback)(ObserverResult<int>)) = 0;

virtual nostd::shared_ptr<SumObserver<float>> NewFloatSumObserver(
nostd::string_view name,
nostd::string_view description,
nostd::string_view unit,
const bool enabled,
void (*callback)(ObserverResult<float>)) = 0;

virtual nostd::shared_ptr<SumObserver<double>> NewDoubleSumObserver(
nostd::string_view name,
nostd::string_view description,
nostd::string_view unit,
const bool enabled,
void (*callback)(ObserverResult<double>)) = 0;

/**
* Creates an UpDownSumObserver with the passed characteristics and returns a shared_ptr to
* that UpDowNSumObserver.
*
* @param name the name of the new UpDownSumObserver.
* @param description a brief description of what the UpDownSumObserver is used for.
* @param unit the unit of metric values following https://unitsofmeasure.org/ucum.html.
* @param enabled a boolean value that turns on or off the metric instrument.
* @param callback the function to be observed by the instrument.
* @return a shared pointer to the created UpDownSumObserver.
* @throws NullPointerException if {@code name} is null
* @throws IllegalArgumentException if a different metric by the same name exists in this meter.
* @throws IllegalArgumentException if the {@code name} does not match spec requirements.
*/
virtual nostd::shared_ptr<UpDownSumObserver<short>> NewShortUpDownSumObserver(
nostd::string_view name,
nostd::string_view description,
nostd::string_view unit,
const bool enabled,
void (*callback)(ObserverResult<short>)) = 0;

virtual nostd::shared_ptr<UpDownSumObserver<int>> NewIntUpDownSumObserver(
nostd::string_view name,
nostd::string_view description,
nostd::string_view unit,
const bool enabled,
void (*callback)(ObserverResult<int>)) = 0;

virtual nostd::shared_ptr<UpDownSumObserver<float>> NewFloatUpDownSumObserver(
nostd::string_view name,
nostd::string_view description,
nostd::string_view unit,
const bool enabled,
void (*callback)(ObserverResult<float>)) = 0;

virtual nostd::shared_ptr<UpDownSumObserver<double>> NewDoubleUpDownSumObserver(
nostd::string_view name,
nostd::string_view description,
nostd::string_view unit,
const bool enabled,
void (*callback)(ObserverResult<double>)) = 0;

/**
* Creates a ValueObserver with the passed characteristics and returns a shared_ptr to that
* ValueObserver.
*
* @param name the name of the new ValueObserver.
* @param description a brief description of what the ValueObserver is used for.
* @param unit the unit of metric values following https://unitsofmeasure.org/ucum.html.
* @param enabled a boolean value that turns on or off the metric instrument.
* @param callback the function to be observed by the instrument.
* @return a shared pointer to the created ValueObserver.
* @throws NullPointerException if {@code name} is null
* @throws IllegalArgumentException if a different metric by the same name exists in this meter.
* @throws IllegalArgumentException if the {@code name} does not match spec requirements.
*/
virtual nostd::shared_ptr<ValueObserver<short>> NewShortValueObserver(
nostd::string_view name,
nostd::string_view description,
nostd::string_view unit,
const bool enabled,
void (*callback)(ObserverResult<short>)) = 0;

virtual nostd::shared_ptr<ValueObserver<int>> NewIntValueObserver(
nostd::string_view name,
nostd::string_view description,
nostd::string_view unit,
const bool enabled,
void (*callback)(ObserverResult<int>)) = 0;

virtual nostd::shared_ptr<ValueObserver<float>> NewFloatValueObserver(
nostd::string_view name,
nostd::string_view description,
nostd::string_view unit,
const bool enabled,
void (*callback)(ObserverResult<float>)) = 0;

virtual nostd::shared_ptr<ValueObserver<double>> NewDoubleValueObserver(
nostd::string_view name,
nostd::string_view description,
nostd::string_view unit,
const bool enabled,
void (*callback)(ObserverResult<double>)) = 0;

/**
* Utility method that allows users to atomically record measurements to a set of
* synchronous metric instruments with a common set of labels.
*
* @param labels the set of labels to associate with this recorder.
* @param instruments a span of pointers to the instruments to record to.
* @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,
nostd::span<SynchronousInstrument<short> *> instruments,
nostd::span<const short> values) noexcept = 0;

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

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

virtual void RecordDoubleBatch(const trace::KeyValueIterable &labels,
nostd::span<SynchronousInstrument<double> *> instruments,
nostd::span<const double> values) noexcept = 0;
};
} // namespace metrics
OPENTELEMETRY_END_NAMESPACE
Loading