AnyCollect  1.1.2
AnyCollect::Metric Class Reference

Class used to represent a metric object (with a name, unit, tags, a value and a timestamp) More...

#include <Metric.h>

Collaboration diagram for AnyCollect::Metric:

Public Member Functions

 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...
 
Metricoperator= (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...
 

Static Public Member Functions

static size_t generateKey (const std::vector< std::string > &name, const std::map< std::string, std::string > &tags)
 Compute the key of potential metric. More...
 
static size_t generateKey (const Metric &metric)
 Compute the key of a metric. More...
 

Protected Attributes

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 Protected Attributes

static std::hash< std::string > hasher {}
 Object used to compute keys (string hashes) More...
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ 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
namename of the metric
tagstags of the metric
unitunit of the metric

Definition at line 29 of file Metric.cc.

Here is the call graph for this function:

◆ 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
namename of the metric
tagstags of the metric
unitunit of the metric

Definition at line 39 of file Metric.cc.

Here is the call graph for this function:

◆ Metric() [4/5]

AnyCollect::Metric::Metric ( const Metric other)
noexcept

Copy constructor.

Parameters
othermetric to copy

Definition at line 49 of file Metric.cc.

◆ Metric() [5/5]

AnyCollect::Metric::Metric ( Metric &&  other)
noexcept

Move constructor.

Parameters
othermetric to move

Definition at line 60 of file Metric.cc.

Member Function Documentation

◆ 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
namename of the metric
tagstags of the metric
Returns
the potential metric's key

Definition at line 84 of file Metric.cc.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ generateKey() [2/2]

static size_t AnyCollect::Metric::generateKey ( const Metric metric)
static

Compute the key of a metric.

Parameters
metricthe 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.

Here is the caller graph for this function:

◆ operator=()

Metric & AnyCollect::Metric::operator= ( Metric  other)
noexcept

Assignment operator.

Parameters
othermetric to copy

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.

Here is the caller graph for this function:

◆ setNewValue()

void AnyCollect::Metric::setNewValue ( double  value,
bool  computeRate,
double  unitsPerSecondFactor = 1.0 
)
noexcept

Sets a new value to the metric.

Parameters
valuethe new value
computeRatewhether the rate should be computed (as previousValue_ - value)
unitsPerSecondFactorfactor to convert the value into units per seconds

Definition at line 124 of file Metric.cc.

Here is the caller graph for this function:

◆ setRoundKey()

void AnyCollect::Metric::setRoundKey ( size_t  roundKey)
noexcept

Sets the round key of the metric.

Definition at line 144 of file Metric.cc.

Here is the caller graph for this function:

◆ 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.

Here is the caller graph for this function:

◆ 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.

Here is the caller graph for this function:

◆ 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.

Here is the caller graph for this function:

◆ unit()

const std::string & AnyCollect::Metric::unit ( ) const
noexcept

Returns the unit of the metric.

Definition at line 115 of file Metric.cc.

Here is the caller graph for this function:

◆ 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
valueThe value to add
unitsPerSecondFactorfactor to convert the value into units per seconds

Definition at line 133 of file Metric.cc.

Here is the caller graph for this function:

◆ value()

double AnyCollect::Metric::value ( ) const
noexcept

Returns the value of the metric.

Definition at line 107 of file Metric.cc.

Here is the caller graph for this function:

Member Data Documentation

◆ 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: