Class used to represent a metric object (with a name, unit, tags, a value and a timestamp)
More...
#include <Metric.h>
|
| Metric ()=delete |
| Deleted default constructor. More...
|
|
| Metric (const std::vector< std::string > &name, const std::map< std::string, std::string > &tags, const std::string &unit="") noexcept |
| Construct a new Metric object. More...
|
|
| Metric (std::vector< std::string > &&name, std::map< std::string, std::string > &&tags, std::string &&unit="") noexcept |
| Construct a new Metric object. More...
|
|
| Metric (const Metric &other) noexcept |
| Copy constructor. More...
|
|
| Metric (Metric &&other) noexcept |
| Move constructor. More...
|
|
Metric & | operator= (Metric other) noexcept |
| Assignment operator. More...
|
|
const std::vector< std::string > & | name () const noexcept |
| Returns the name of the metric. More...
|
|
size_t | key () const noexcept |
| Returns the key of the metric. More...
|
|
size_t | roundKey () const noexcept |
| Returns the key of the collection iteration which created the metric. More...
|
|
double | value () const noexcept |
| Returns the value of the metric. More...
|
|
std::chrono::system_clock::time_point | timestamp () const noexcept |
| Returns the timestamp of the metric. More...
|
|
const std::string & | unit () const noexcept |
| Returns the unit of the metric. More...
|
|
const std::map< std::string, std::string > & | tags () const noexcept |
| Returns the tags of the metric. More...
|
|
void | setNewValue (double value, bool computeRate, double unitsPerSecondFactor=1.0) noexcept |
| Sets a new value to the metric. More...
|
|
void | updateValue (double value, double unitsPerSecondFactor=1.0) noexcept |
| Adds a new value to the current value. More...
|
|
void | setTimestamp (std::chrono::system_clock::time_point timestamp) noexcept |
| Sets the timestamp of the metric. More...
|
|
void | setRoundKey (size_t roundKey) noexcept |
| Sets the round key of the metric. More...
|
|
|
size_t | key_ |
| Key of the metric (hash of its name, tag keys and tags values) More...
|
|
size_t | roundKey_ |
| Key of the collection iteration which created this metric. More...
|
|
std::vector< std::string > | name_ |
| Array of strings representing the name of the metric. More...
|
|
double | previousValue_ |
| Previous value of the metric. More...
|
|
double | value_ |
| Current value of the metric. More...
|
|
std::chrono::system_clock::time_point | timestamp_ |
| Timestamp of the metric. More...
|
|
std::string | unit_ |
| Unit of the metric. More...
|
|
std::map< std::string, std::string > | tags_ |
| Tags of the metric. More...
|
|
|
static std::hash< std::string > | hasher {} |
| Object used to compute keys (string hashes) More...
|
|
Class used to represent a metric object (with a name, unit, tags, a value and a timestamp)
Definition at line 33 of file Metric.h.
◆ Metric() [1/5]
AnyCollect::Metric::Metric |
( |
| ) |
|
|
delete |
Deleted default constructor.
◆ Metric() [2/5]
AnyCollect::Metric::Metric |
( |
const std::vector< std::string > & |
name, |
|
|
const std::map< std::string, std::string > & |
tags, |
|
|
const std::string & |
unit = "" |
|
) |
| |
|
noexcept |
Construct a new Metric object.
- Parameters
-
name | name of the metric |
tags | tags of the metric |
unit | unit of the metric |
Definition at line 29 of file Metric.cc.
◆ Metric() [3/5]
AnyCollect::Metric::Metric |
( |
std::vector< std::string > && |
name, |
|
|
std::map< std::string, std::string > && |
tags, |
|
|
std::string && |
unit = "" |
|
) |
| |
|
noexcept |
Construct a new Metric object.
- Parameters
-
name | name of the metric |
tags | tags of the metric |
unit | unit of the metric |
Definition at line 39 of file Metric.cc.
◆ Metric() [4/5]
AnyCollect::Metric::Metric |
( |
const Metric & |
other | ) |
|
|
noexcept |
Copy constructor.
- Parameters
-
Definition at line 49 of file Metric.cc.
◆ Metric() [5/5]
AnyCollect::Metric::Metric |
( |
Metric && |
other | ) |
|
|
noexcept |
Move constructor.
- Parameters
-
Definition at line 60 of file Metric.cc.
◆ generateKey() [1/2]
size_t AnyCollect::Metric::generateKey |
( |
const std::vector< std::string > & |
name, |
|
|
const std::map< std::string, std::string > & |
tags |
|
) |
| |
|
static |
Compute the key of potential metric.
- Parameters
-
name | name of the metric |
tags | tags of the metric |
- Returns
- the potential metric's key
Definition at line 84 of file Metric.cc.
◆ generateKey() [2/2]
static size_t AnyCollect::Metric::generateKey |
( |
const Metric & |
metric | ) |
|
|
static |
Compute the key of a metric.
- Parameters
-
metric | the metric to compute the key of |
- Returns
- the potential metric's key
◆ key()
size_t AnyCollect::Metric::key |
( |
| ) |
const |
|
noexcept |
Returns the key of the metric.
Definition at line 99 of file Metric.cc.
◆ name()
const std::vector< std::string > & AnyCollect::Metric::name |
( |
| ) |
const |
|
noexcept |
Returns the name of the metric.
Definition at line 95 of file Metric.cc.
◆ operator=()
Assignment operator.
- Parameters
-
Definition at line 71 of file Metric.cc.
◆ roundKey()
size_t AnyCollect::Metric::roundKey |
( |
| ) |
const |
|
noexcept |
Returns the key of the collection iteration which created the metric.
Definition at line 103 of file Metric.cc.
◆ setNewValue()
void AnyCollect::Metric::setNewValue |
( |
double |
value, |
|
|
bool |
computeRate, |
|
|
double |
unitsPerSecondFactor = 1.0 |
|
) |
| |
|
noexcept |
Sets a new value to the metric.
- Parameters
-
value | the new value |
computeRate | whether the rate should be computed (as previousValue_ - value ) |
unitsPerSecondFactor | factor to convert the value into units per seconds |
Definition at line 124 of file Metric.cc.
◆ setRoundKey()
void AnyCollect::Metric::setRoundKey |
( |
size_t |
roundKey | ) |
|
|
noexcept |
Sets the round key of the metric.
Definition at line 144 of file Metric.cc.
◆ setTimestamp()
void AnyCollect::Metric::setTimestamp |
( |
std::chrono::system_clock::time_point |
timestamp | ) |
|
|
noexcept |
Sets the timestamp of the metric.
Definition at line 140 of file Metric.cc.
◆ tags()
const std::map< std::string, std::string > & AnyCollect::Metric::tags |
( |
| ) |
const |
|
noexcept |
Returns the tags of the metric.
Definition at line 119 of file Metric.cc.
◆ timestamp()
std::chrono::system_clock::time_point AnyCollect::Metric::timestamp |
( |
| ) |
const |
|
noexcept |
Returns the timestamp of the metric.
Definition at line 111 of file Metric.cc.
◆ unit()
const std::string & AnyCollect::Metric::unit |
( |
| ) |
const |
|
noexcept |
Returns the unit of the metric.
Definition at line 115 of file Metric.cc.
◆ updateValue()
void AnyCollect::Metric::updateValue |
( |
double |
value, |
|
|
double |
unitsPerSecondFactor = 1.0 |
|
) |
| |
|
noexcept |
Adds a new value to the current value.
When a matcher computes the same metric during a single collection iteration (same round key), the different computed values are summed
- Parameters
-
value | The value to add |
unitsPerSecondFactor | factor to convert the value into units per seconds |
Definition at line 133 of file Metric.cc.
◆ value()
double AnyCollect::Metric::value |
( |
| ) |
const |
|
noexcept |
Returns the value of the metric.
Definition at line 107 of file Metric.cc.
◆ hasher
std::hash< std::string > AnyCollect::Metric::hasher {} |
|
staticprotected |
Object used to compute keys (string hashes)
Definition at line 35 of file Metric.h.
◆ key_
size_t AnyCollect::Metric::key_ |
|
protected |
Key of the metric (hash of its name, tag keys and tags values)
Definition at line 36 of file Metric.h.
◆ name_
std::vector<std::string> AnyCollect::Metric::name_ |
|
protected |
Array of strings representing the name of the metric.
Definition at line 38 of file Metric.h.
◆ previousValue_
double AnyCollect::Metric::previousValue_ |
|
protected |
Previous value of the metric.
Definition at line 39 of file Metric.h.
◆ roundKey_
size_t AnyCollect::Metric::roundKey_ |
|
protected |
Key of the collection iteration which created this metric.
Definition at line 37 of file Metric.h.
◆ tags_
std::map<std::string, std::string> AnyCollect::Metric::tags_ |
|
protected |
Tags of the metric.
Definition at line 43 of file Metric.h.
◆ timestamp_
std::chrono::system_clock::time_point AnyCollect::Metric::timestamp_ |
|
protected |
Timestamp of the metric.
Definition at line 41 of file Metric.h.
◆ unit_
std::string AnyCollect::Metric::unit_ |
|
protected |
Unit of the metric.
Definition at line 42 of file Metric.h.
◆ value_
double AnyCollect::Metric::value_ |
|
protected |
Current value of the metric.
Definition at line 40 of file Metric.h.
The documentation for this class was generated from the following files: