Monitoring  3.3.4
O2 Monitoring library
o2::monitoring::Metric Class Reference

Represents a metric including value, type of the value, name, timestamp and tags. More...

#include <Metric.h>

Collaboration diagram for o2::monitoring::Metric:

Public Member Functions

 Metric (int value, const std::string &name, Verbosity verbosity=Metric::DefaultVerbosity)
 
 Metric (std::string value, const std::string &name, Verbosity verbosity=Metric::DefaultVerbosity)
 
 Metric (double value, const std::string &name, Verbosity verbosity=Metric::DefaultVerbosity)
 
 Metric (uint64_t value, const std::string &name, Verbosity verbosity=Metric::DefaultVerbosity)
 
 Metric (const std::string &name, Verbosity verbosity=Metric::DefaultVerbosity, const std::chrono::time_point< std::chrono::system_clock > &timestamp=Metric::getCurrentTimestamp())
 
Metric && addValue (int value, const std::string &name)
 
Metric && addValue (double value, const std::string &name)
 
Metric && addValue (uint64_t value, const std::string &name)
 
Metric && addValue (std::string value, const std::string &name)
 
Metric && addValue (const std::variant< int, std::string, double, uint64_t > &value, const std::string &name)
 
 ~Metric ()=default
 Default destructor.
 
const std::string & getName () const
 
std::chrono::time_point< std::chrono::system_clock > getTimestamp () const
 
const std::vector< std::pair< std::string, std::variant< int, std::string, double, uint64_t > > > & getValues () const
 
const std::pair< std::string, std::variant< int, std::string, double, uint64_t > > & getFirstValue () const
 
std::size_t getValuesSize () const noexcept
 Values vector size getter.
 
const std::vector< std::pair< int, int > > & getTags () const
 
Metric && addTag (tags::Key key, tags::Value value)
 
Metric && addTag (tags::Key key, unsigned short int number)
 
Verbosity getVerbosity ()
 Verbosity getter.
 
int getFirstValueType () const
 This is required for backward compability with boost::variant and old StdOut format.
 

Static Public Member Functions

static auto getCurrentTimestamp () -> decltype(std::chrono::system_clock::now())
 
static void setDefaultVerbosity (Verbosity verbosity)
 Sets default verbosity of metrics.
 
static void setVerbosityPolicy (Verbosity verbosity, const std::regex &regex)
 Regex policy setter.
 

Static Public Attributes

static Verbosity DefaultVerbosity = Verbosity::Info
 Default metric verbosity.
 
static bool includeTimestamp = true
 Whether timestamp should be included or not.
 

Protected Member Functions

Metric && setTags (std::vector< std::pair< int, int >> &&tags)
 Set full vector of tags.
 
void overwriteVerbosity ()
 Overwirte verbosity using regex policy.
 

Protected Attributes

std::vector< std::pair< std::string, std::variant< int, std::string, double, uint64_t > > > mValues
 Metric values.
 
std::string mName
 Metric name.
 
std::chrono::time_point< std::chrono::system_clock > mTimestamp
 Metric timestamp.
 
std::vector< std::pair< int, int > > mTags
 Metric tags.
 
Verbosity mVerbosity
 Metric verbosity.
 

Static Protected Attributes

static std::map< std::underlying_type< Verbosity >::type, std::regex > mRegexPolicy
 Regex policy map.
 
static constexpr char mDefaultValueName [] = "value"
 Default value name.
 

Friends

class o2::monitoring::DerivedMetrics
 Allow DerivedMetrics access to setTags.
 

Detailed Description

Represents a metric including value, type of the value, name, timestamp and tags.

Constructor & Destructor Documentation

o2::monitoring::Metric::Metric ( int  value,
const std::string &  name,
Verbosity  verbosity = Metric::DefaultVerbosity 
)

Integer metric construtor

Parameters
valuemetric value (int)
namemetric name
o2::monitoring::Metric::Metric ( std::string  value,
const std::string &  name,
Verbosity  verbosity = Metric::DefaultVerbosity 
)

String metric construtor

Parameters
valuemetric value (string)
namethe metric name
o2::monitoring::Metric::Metric ( double  value,
const std::string &  name,
Verbosity  verbosity = Metric::DefaultVerbosity 
)

Double metric constructor

Parameters
valuemetric value (double)
namemetric name
o2::monitoring::Metric::Metric ( uint64_t  value,
const std::string &  name,
Verbosity  verbosity = Metric::DefaultVerbosity 
)

uint64_t metric constructor

Parameters
valuemetric value (uint64_t)
namemetric name
o2::monitoring::Metric::Metric ( const std::string &  name,
Verbosity  verbosity = Metric::DefaultVerbosity,
const std::chrono::time_point< std::chrono::system_clock > &  timestamp = Metric::getCurrentTimestamp() 
)

Constructor that does not require any value to be specified, .addValue needs to be used

Parameters
namemetric name

Member Function Documentation

Metric && o2::monitoring::Metric::addTag ( tags::Key  key,
tags::Value  value 
)

Add user defined tags

Parameters
keyenum tag key
valueemum tag value
Returns
r-value to "this" - to be able to chain methods
Metric&& o2::monitoring::Metric::addTag ( tags::Key  key,
unsigned short int  number 
)

Add user defined tags

Parameters
keyenum tag key
valuenumeric value
Returns
r-value to "this" - to be able to chain methods
Metric && o2::monitoring::Metric::addValue ( int  value,
const std::string &  name 
)

Adds additional int value to metric

Parameters
value
name
Metric && o2::monitoring::Metric::addValue ( double  value,
const std::string &  name 
)

Adds additional double value to metric

Parameters
value
name
Metric && o2::monitoring::Metric::addValue ( uint64_t  value,
const std::string &  name 
)

Adds additional uint64_t value to metric

Parameters
value
name
Metric && o2::monitoring::Metric::addValue ( std::string  value,
const std::string &  name 
)

Adds additional string value to metric

Parameters
value
name
Metric && o2::monitoring::Metric::addValue ( const std::variant< int, std::string, double, uint64_t > &  value,
const std::string &  name 
)

Adds additional variant value to metric

Parameters
value
name
auto o2::monitoring::Metric::getCurrentTimestamp ( ) -> decltype(std::chrono::system_clock::now())
static

Generetes current timestamp return timestamp as std::chrono::system_clock

const std::pair< std::string, std::variant< int, std::string, double, uint64_t > > & o2::monitoring::Metric::getFirstValue ( ) const

First value getter

Returns
first value as pair
const std::string & o2::monitoring::Metric::getName ( ) const

Name getter

Returns
metric name
const std::vector< std::pair< int, int > > & o2::monitoring::Metric::getTags ( ) const

Tag list getter

Returns
tags
std::chrono::time_point< std::chrono::system_clock > o2::monitoring::Metric::getTimestamp ( ) const

Timestamp getter

Returns
metric timestamp
const std::vector< std::pair< std::string, std::variant< int, std::string, double, uint64_t > > > & o2::monitoring::Metric::getValues ( ) const

Values getter

Returns
vector of values

The documentation for this class was generated from the following files: