artdaq_utilities  v1_04_10
MetricData.hh
1 #ifndef ARTDAQ_UTILITIES_PLUGINS_METRICDATA_HH
2 #define ARTDAQ_UTILITIES_PLUGINS_METRICDATA_HH
3 
4 #include "fhiclcpp/fwd.h"
5 #include "messagefacility/MessageLogger/MessageLogger.h"
6 
7 #include <sstream>
8 #include <list>
9 #include <condition_variable>
10 #include <atomic>
11 
12 namespace artdaq
13 {
17  enum class MetricType
18  {
20  StringMetric,
21  IntMetric,
22  DoubleMetric,
23  FloatMetric,
25  };
26 
30  enum class MetricMode
31  {
32  LastPoint,
33  Accumulate,
34  Average,
35  Rate,
37  };
38 
42  struct MetricData
43  {
48  MetricData(const MetricData& r) = default;
49 
54  MetricData(MetricData&& r) noexcept = default;
55 
61  MetricData& operator=(const MetricData& r) = default;
62 
68  MetricData& operator=(MetricData&& r) noexcept = default;
69 
73  std::string Name;
77  std::string StringValue;
78 
82  union
83  {
84  int IntValue;
85  double DoubleValue;
86  float FloatValue;
87  long unsigned int UnsignedValue;
88  };
89 
97  std::string Unit;
101  int Level;
109  std::string MetricPrefix;
118 
129  MetricData(std::string const& name, std::string const& value, std::string const& unit, int level, MetricMode mode, std::string const& metricPrefix, bool useNameOverride)
130  : Name(name)
131  , StringValue(value)
133  , Unit(unit)
134  , Level(level)
135  , Mode(mode)
136  , MetricPrefix(metricPrefix)
137  , UseNameOverride(useNameOverride)
138  , DataPointCount(1)
139  {}
140 
151  MetricData(std::string const& name, int const& value, std::string const& unit, int level, MetricMode mode, std::string const& metricPrefix, bool useNameOverride)
152  : Name(name)
153  , IntValue(value)
155  , Unit(unit)
156  , Level(level)
157  , Mode(mode)
158  , MetricPrefix(metricPrefix)
159  , UseNameOverride(useNameOverride)
160  , DataPointCount(1)
161  {}
162 
173  MetricData(std::string const& name, double const& value, std::string const& unit, int level, MetricMode mode, std::string const& metricPrefix, bool useNameOverride)
174  : Name(name)
175  , DoubleValue(value)
177  , Unit(unit)
178  , Level(level)
179  , Mode(mode)
180  , MetricPrefix(metricPrefix)
181  , UseNameOverride(useNameOverride)
182  , DataPointCount(1)
183  {}
184 
195  MetricData(std::string const& name, float const& value, std::string const& unit, int level, MetricMode mode, std::string const& metricPrefix, bool useNameOverride)
196  : Name(name)
197  , FloatValue(value)
199  , Unit(unit)
200  , Level(level)
201  , Mode(mode)
202  , MetricPrefix(metricPrefix)
203  , UseNameOverride(useNameOverride)
204  , DataPointCount(1)
205  {}
206 
217  MetricData(std::string const& name, long unsigned int const& value, std::string const& unit, int level, MetricMode mode, std::string const& metricPrefix, bool useNameOverride)
218  : Name(name)
219  , UnsignedValue(value)
221  , Unit(unit)
222  , Level(level)
223  , Mode(mode)
224  , MetricPrefix(metricPrefix)
225  , UseNameOverride(useNameOverride)
226  , DataPointCount(1)
227  {}
228 
232  MetricData() : Name("")
234  };
235 }
236 
237 #endif /* ARTDAQ_UTILITIES_PLUGINS_METRICDATA_HH */
std::string StringValue
Value of the metric, if it is a MetricType::StringMetric
Definition: MetricData.hh:77
std::string MetricPrefix
Name prefix for the metric
Definition: MetricData.hh:109
int IntValue
Value of the metric, if it is a MetricType::IntMetric.
Definition: MetricData.hh:84
double DoubleValue
Value of the metric, if it is a MetricType::DoubleMetric.
Definition: MetricData.hh:85
Report the average of all values. Use for rates to report accurate results.
size_t DataPointCount
Number of data points accumulated in this MetricData
Definition: MetricData.hh:117
MetricMode
The Mode of the metric indicates how multiple metric values should be combined within a reporting int...
Definition: MetricData.hh:30
std::string Unit
Units of the metric
Definition: MetricData.hh:97
float FloatValue
Value of the metric, if it is a MetricType::FloatMetric.
Definition: MetricData.hh:86
Metric is a std::string (not in union)
std::string Name
Name of the metric
Definition: MetricData.hh:73
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
Definition: MetricData.hh:129
Reports the sum of all values, divided by the length of the time interval they were accumulated over...
bool UseNameOverride
Whether to override the default naming convention for this metric
Definition: MetricData.hh:113
MetricMode Mode
Accumulation mode of the metric
Definition: MetricData.hh:105
MetricType
This enumeration is used to identify the type of the metric instance (which value should be extraced ...
Definition: MetricData.hh:17
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
Definition: MetricData.hh:173
Metric is a long unsigned int.
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
Definition: MetricData.hh:195
Sends both the Accumulate mode and Rate mode metric. (Rate mode metric will append &quot;/s&quot; to metric uni...
MetricType Type
Type of the metric
Definition: MetricData.hh:93
Report the sum of all values. Use for counters to report accurate results.
MetricData()
Default constructor, constructs an MetricType::InvalidMetric
Definition: MetricData.hh:232
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
Definition: MetricData.hh:217
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 ...
Definition: MetricData.hh:42
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
Definition: MetricData.hh:151
Report only the last value recorded. Useful for event counters, run numbers, etc. ...
Default, invalid value.
long unsigned int UnsignedValue
Value of the metric, if it is a MetricType::UnsignedMetric.
Definition: MetricData.hh:87
int Level
Reporting level of the metric
Definition: MetricData.hh:101