Class collector_group
Defined in File collector_group.hpp
Inheritance Relationships
Base Type
public rcppsw::er::client< collector_group >
(Template Class client)
Class Documentation
-
class collector_group : public rcppsw::er::client<collector_group>
A group of N collectors, mapped by name, on which collective operations can be performed, in addition to individual collection; used to reduce code duplication.
Public Functions
-
collector_group(void)
-
virtual ~collector_group(void) = default
-
bool collect(const key_type &name, const base_metrics &metrics)
Collect metrics from the specified collector, passing it the specified metrics set. This function only works if you are collecting metrics from something that is present on the same machine as the collector.
- Parameters:
name – The registered name of the collector.
metrics – The metrics to collect from.
- Returns:
TRUE
if the specified collector is registered and collection was successful,FALSE
otherwise.
-
bool collect_if(const key_type &name, const base_metrics &metrics, const std::function<bool(const base_metrics&)> &predicate)
Collect metrics from the specified collector, passing it the specified metrics set, but only if the specified condition is met by the metrics.
Useful if you have a “polymorphic” set of metrics that are very similar, but need to be captured in different files, and you don’t want to have to derive nearly identical classes to handle it. The predicate is evaluated after checking to see if the specified collector is enabled, because that check has to be done anyway, and predicate evaluation is potentially expensive.
- Parameters:
name – The name of the collector to collect with.
metrics – The metrics to collect.
predicate – The predicate used to determine if the specified collector should actually be invoked.
- Returns:
TRUE
if metrics were collected,FALSE
otherwise.
-
template<typename T, typename ...Args>
inline bool collector_register(const key_type &name, Args&&... args) Add a collector to the group by constructing it in place.
- Template Parameters:
T – The type of the collector.
- Parameters:
name – The key for the collector in the group. Should be unique, though it is not a requirement. If it is not unique then the older collector that was mapped to that name will NOT be overwritten, and nothing is done. You have to remove it first collector_unregister().
args – 0 or more arguments to the collector constructor.
- Returns:
TRUE
if the collector was successfully registered, andFALSE
otherwise.
-
bool collector_unregister(const key_type &name)
Unregister the collector with mapped name
name
from the group.- Returns:
TRUE
if the collector was successfully unregistered, andFALSE
otherwise.
-
void finalize(void)
-
bool flush(bool fail_ok, const rtypes::timestep &t)
Call the base_collector::flush() function on all collectors in the group.
fail_ok
Is it OK if one or more collectors fail to write due to filesystem I/O errors, or not?- Returns:
If
fail_ok
isFALSE
,TRUE
iff ALL collectors in the group attempted to write out metrics this timestep and were successful, andFALSE
otherwise. Iffail_ok
isTRUE
, thenTRUE
if all collectors attempted to write out metrics this timestep, regardless of success, andFALSE
otherwise.
-
template<typename T = base_collector>
inline T *get(const key_type &key) Get a reference to a collector by name.
- Parameters:
key – The mapped name of the collector in the group.
-
void initialize(void)
Call the base_collector::initialize() function on all collectors in the group.
-
void interval_reset(const rtypes::timestep &t)
Call the base_collector::interval_reset() function on all collectors in the group.
-
inline size_t size(void) const
-
collector_group(void)