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>
49 return static_cast<MetricMode>(
static_cast<uint32_t
>(a) | static_cast<uint32_t>(b));
59 return static_cast<MetricMode>(
static_cast<uint32_t
>(a) & static_cast<uint32_t>(b));
190 MetricData(std::string
const& name, std::string
const& value, std::string
const& unit,
int level,
MetricMode mode,
191 std::string
const& metricPrefix,
bool useNameOverride)
205 std::string
const& metricPrefix,
bool useNameOverride)
206 :
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) {}
219 std::string
const& metricPrefix,
bool useNameOverride)
220 :
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) {}
233 std::string
const& metricPrefix,
bool useNameOverride)
234 :
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) {}
246 MetricData(std::string
const& name, uint64_t
const& value, std::string
const& unit,
int level,
247 MetricMode mode, std::string
const& metricPrefix,
bool useNameOverride)
248 :
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) {}
408 Min.
i = std::numeric_limits<int>::max();
409 Max.
i = std::numeric_limits<int>::min();
414 Min.
d = std::numeric_limits<double>::max();
415 Max.
d = std::numeric_limits<double>::min();
420 Min.
f = std::numeric_limits<float>::max();
421 Max.
f = std::numeric_limits<float>::min();
426 Min.
u = std::numeric_limits<uint64_t>::max();
427 Max.
u = std::numeric_limits<uint64_t>::min();
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
MetricData(std::string const &name, uint64_t const &value, std::string const &unit, int level, MetricMode mode, std::string const &metricPrefix, bool useNameOverride)
Construct a MetricData point using a uint64_t value
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
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
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
void AddPoint(uint64_t point)
Add an uint64_t point to this MetricData
Reports the minimum value recorded.
Metric is a long unsigned int.
over. Use to create rates from counters.
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.
MetricDataValue(uint64_t v)
Construct a MetricDataValue as unsigned int
Keep previous metric value in memory.
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
This union holds the values for all other metric types
MetricDataValue Last
Last value of this MetricData.
void Reset()
Reset this MetricData instance to the initial state
void AddPoint(float point)
Add a float point to this MetricData
MetricData()
Default constructor, constructs an MetricType::InvalidMetric
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
uint64_t u
Value of the metric, if it is a MetricType::UnsignedMetric.
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