1 #ifndef ARTDAQ_UTILITIES_PLUGINS_METRICDATA_HH
2 #define ARTDAQ_UTILITIES_PLUGINS_METRICDATA_HH
4 #include "fhiclcpp/fwd.h"
5 #include "messagefacility/MessageLogger/MessageLogger.h"
8 #include <condition_variable>
48 return static_cast<MetricMode>(
static_cast<uint32_t
>(a) | static_cast<uint32_t>(b));
58 return static_cast<MetricMode>(
static_cast<uint32_t
>(a) & static_cast<uint32_t>(b));
189 MetricData(std::string
const& name, std::string
const& value, std::string
const& unit,
int level,
MetricMode mode,
190 std::string
const& metricPrefix,
bool useNameOverride)
204 std::string
const& metricPrefix,
bool useNameOverride)
205 :
Name(name),
Value(value),
Last(value),
Min(value),
Max(value),
Type(
MetricType::
IntMetric),
Unit(unit),
Level(level),
Mode(mode),
MetricPrefix(metricPrefix),
UseNameOverride(useNameOverride),
DataPointCount(1) {}
218 std::string
const& metricPrefix,
bool useNameOverride)
219 :
Name(name),
Value(value),
Last(value),
Min(value),
Max(value),
Type(
MetricType::
DoubleMetric),
Unit(unit),
Level(level),
Mode(mode),
MetricPrefix(metricPrefix),
UseNameOverride(useNameOverride),
DataPointCount(1) {}
232 std::string
const& metricPrefix,
bool useNameOverride)
233 :
Name(name),
Value(value),
Last(value),
Min(value),
Max(value),
Type(
MetricType::
FloatMetric),
Unit(unit),
Level(level),
Mode(mode),
MetricPrefix(metricPrefix),
UseNameOverride(useNameOverride),
DataPointCount(1) {}
245 MetricData(std::string
const& name,
long unsigned int const& value, std::string
const& unit,
int level,
246 MetricMode mode, std::string
const& metricPrefix,
bool useNameOverride)
247 :
Name(name),
Value(value),
Last(value),
Min(value),
Max(value),
Type(
MetricType::
UnsignedMetric),
Unit(unit),
Level(level),
Mode(mode),
MetricPrefix(metricPrefix),
UseNameOverride(useNameOverride),
DataPointCount(1) {}
std::string StringValue
Value of the metric, if it is a MetricType::StringMetric
std::string MetricPrefix
Name prefix for the metric
MetricDataValue(double v)
Construct a MetricDataValue as double
MetricDataValue(float v)
Construct a MetricDataValue as fload
size_t DataPointCount
Number of data points accumulated in this MetricData
Report the sum of all values. Use for counters to report accurate results.
std::string Unit
Units of the metric
float f
Value of the metric, if it is a MetricType::FloatMetric.
MetricDataValue()
Construct a MetricDataValue
Metric is a std::string (not in union)
std::string Name
Name of the metric
void AddPoint(unsigned long int point)
Add an unsigned int point to this MetricData
MetricData(std::string const &name, std::string const &value, std::string const &unit, int level, MetricMode mode, std::string const &metricPrefix, bool useNameOverride)
Construct a MetricData point using a string value
MetricDataValue(long unsigned int v)
Construct a MetricDataValue as unsigned int
bool UseNameOverride
Whether to override the default naming convention for this metric
MetricMode Mode
Accumulation mode of the metric
bool Add(MetricData other)
Add two MetricData instances together
constexpr MetricMode operator&(MetricMode a, MetricMode b)
Bitwise AND operator for MetricMode
MetricType
This enumeration is used to identify the type of the metric instance (which value should be extraced ...
MetricDataValue Max
Maximum recorded vaule of this MetricData.
MetricData(std::string const &name, double const &value, std::string const &unit, int level, MetricMode mode, std::string const &metricPrefix, bool useNameOverride)
Construct a MetricData point using a double value
Reports the minimum value recorded.
Metric is a long unsigned int.
void AddPoint(int point)
Add an integer point to this MetricData
Report only the last value recorded. Useful for event counters, run numbers, etc. ...
Repots the maximum value recorded.
MetricData(std::string const &name, float const &value, std::string const &unit, int level, MetricMode mode, std::string const &metricPrefix, bool useNameOverride)
Construct a MetricData point using a float value
MetricDataValue Value
Accumulated value of this MetricData
int i
Value of the metric, if it is a MetricType::IntMetric.
constexpr MetricMode operator|(MetricMode a, MetricMode b)
Bitwise OR operator for MetricMode
MetricType Type
Type of the metric
MetricMode
The Mode of the metric indicates how multiple metric values should be combined within a reporting int...
void AddPoint(double point)
Add a double point to this MetricData
MetricDataValue(int v)
Construct a MetricDataValue as integer
long unsigned int u
Value of the metric, if it is a MetricType::UnsignedMetric.
This union holds the values for all other metric types
MetricDataValue Last
Last value of this MetricData.
void AddPoint(float point)
Add a float point to this MetricData
MetricData()
Default constructor, constructs an MetricType::InvalidMetric
MetricData(std::string const &name, long unsigned int const &value, std::string const &unit, int level, MetricMode mode, std::string const &metricPrefix, bool useNameOverride)
Construct a MetricData point using a unsigned long int value
MetricData & operator=(const MetricData &r)=default
Default copy assignment operator
Small structure used to hold a metric data point before sending to the metric plugins ...
MetricData(std::string const &name, int const &value, std::string const &unit, int level, MetricMode mode, std::string const &metricPrefix, bool useNameOverride)
Construct a MetricData point using a int value
Report the average of all values. Use for rates to report accurate results.
MetricDataValue Min
Minimum recorded value of this MetricData.
double d
Value of the metric, if it is a MetricType::DoubleMetric.
int Level
Reporting level of the metric