Belle II Software light-2406-ragdoll
|
Base class for the ZMQ connection to help monitor and log certain values. More...
#include <ZMQLogger.h>
Classes | |
struct | Decrementor |
Visitor Helper for decrementing a numerical value. More... | |
struct | Incrementor |
Visitor Helper for incrementing a numerical value. More... | |
struct | toJSON |
Visitor Helper for converting a variant value into a JSON string. More... | |
Public Member Functions | |
virtual std::string | getMonitoringJSON () const |
Convert the stored monitoring values to a JSON string ready for sending out via a message. | |
template<class AClass > | |
void | log (const std::string &key, const AClass &value) |
Store a value under a certain key. Different types of values can be stored, namely long, double or string. Mixtures are not allowed for a given key. | |
void | increment (const std::string &key) |
Increment the value with the given key (only numerical values). If not present, set to 1. | |
void | decrement (const std::string &key) |
Decrement the value with the given key (only numerical values). If not present, set to -1. | |
template<size_t MAX_SIZE = 100> | |
void | average (const std::string &key, double value) |
Instead of storeing the double value directly under the given key, store the average of the last MAX_SIZE values. | |
template<size_t AVERAGE_SIZE = 2000> | |
void | timeit (const std::string &key) |
Measure the rate of calls with the same key every AVERAGE_SIZE calls (and also display the last time AVERAGE_SIZE was reached under <key>_last_measurement) | |
void | logTime (const std::string &key) |
Store the current time as a string under the given key. | |
Private Attributes | |
std::map< std::string, std::variant< long, double, std::string > > | m_monitoring |
Internal storage of all stored values. | |
std::unordered_map< std::string, std::tuple< std::vector< double >, size_t > > | m_averages |
Internal storage of the previous values when calculating averages. | |
std::unordered_map< std::string, std::tuple< unsigned long, std::chrono::system_clock::time_point > > | m_timeCounters |
Internal storage how often the timeit function for a given key was called and when it has last reached MAX_SIZE. | |
Base class for the ZMQ connection to help monitor and log certain values.
Which and when to monitor/log must be defined by the derived classes, this base class only gives helpers to store/add/average/measure time and most importantly convert all stored monitoring values to a JSON string on request (useful e.g. for monitoring purposes).
Please note, that in all cases you need to call the corresponding monitor function by yourself. There is no "registering" of monitor values, values will only be stored on actively calling a monitor function (e.g. log).
Definition at line 35 of file ZMQLogger.h.
void decrement | ( | const std::string & | key | ) |
Decrement the value with the given key (only numerical values). If not present, set to -1.
Definition at line 37 of file ZMQLogger.cc.
|
virtual |
Convert the stored monitoring values to a JSON string ready for sending out via a message.
Definition at line 15 of file ZMQLogger.cc.
void increment | ( | const std::string & | key | ) |
Increment the value with the given key (only numerical values). If not present, set to 1.
Definition at line 32 of file ZMQLogger.cc.
void logTime | ( | const std::string & | key | ) |
Store the current time as a string under the given key.
Definition at line 42 of file ZMQLogger.cc.
|
private |
Internal storage of the previous values when calculating averages.
Definition at line 60 of file ZMQLogger.h.
|
private |
Internal storage of all stored values.
Definition at line 58 of file ZMQLogger.h.
|
private |
Internal storage how often the timeit function for a given key was called and when it has last reached MAX_SIZE.
Definition at line 62 of file ZMQLogger.h.