35 static std::hash<std::string>
hasher;
43 std::map<std::string, std::string>
tags_;
58 Metric(
const std::vector<std::string>&
name,
const std::map<std::string, std::string>&
tags,
const std::string&
unit =
"") noexcept;
112 const
std::vector<
std::
string>&
name() const noexcept;
117 size_t key() const noexcept;
127 double value() const noexcept;
132 std::chrono::system_clock::time_point
timestamp() const noexcept;
137 const
std::
string&
unit() const noexcept;
142 const
std::map<
std::
string,
std::
string>&
tags() const noexcept;
152 void setNewValue(
double value,
bool computeRate,
double unitsPerSecondFactor = 1.0) noexcept;
void setTimestamp(std::chrono::system_clock::time_point timestamp) noexcept
Sets the timestamp of the metric.
void setNewValue(double value, bool computeRate, double unitsPerSecondFactor=1.0) noexcept
Sets a new value to the metric.
std::vector< std::string > name_
Array of strings representing the name of the metric.
size_t key() const noexcept
Returns the key of the metric.
Metric()=delete
Deleted default constructor.
const std::string & unit() const noexcept
Returns the unit of the metric.
const std::vector< std::string > & name() const noexcept
Returns the name of the metric.
size_t key_
Key of the metric (hash of its name, tag keys and tags values)
static size_t generateKey(const std::vector< std::string > &name, const std::map< std::string, std::string > &tags)
Compute the key of potential metric.
std::string unit_
Unit of the metric.
std::chrono::system_clock::time_point timestamp_
Timestamp of the metric.
size_t roundKey() const noexcept
Returns the key of the collection iteration which created the metric.
std::chrono::system_clock::time_point timestamp() const noexcept
Returns the timestamp of the metric.
size_t roundKey_
Key of the collection iteration which created this metric.
const std::map< std::string, std::string > & tags() const noexcept
Returns the tags of the metric.
std::map< std::string, std::string > tags_
Tags of the metric.
double value_
Current value of the metric.
Class used to represent a metric object (with a name, unit, tags, a value and a timestamp) ...
void setRoundKey(size_t roundKey) noexcept
Sets the round key of the metric.
static std::hash< std::string > hasher
Object used to compute keys (string hashes)
double previousValue_
Previous value of the metric.
double value() const noexcept
Returns the value of the metric.
void updateValue(double value, double unitsPerSecondFactor=1.0) noexcept
Adds a new value to the current value.