BDE 4.14.0 Production release
|
Provide a repository for collectors.
This component defines a class, balm::CollectorRepository
, that serves as a repository for balm::Collector
and balm::IntegerCollector
objects. The collector repository supports operations to create and lookup collectors, as well as an operation to collect metric records from the collectors in the repository. Collectors are identified by a metric id, which uniquely identifies the metric for which they collect values. The getDefaultCollector
(and getDefaultIntegerCollector
) operations return the default collector (or integer collector) for the supplied metric. The addCollector
(and addIntegerCollector
) operations create and return a new collector (or integer collector) for the specified metric. Each collector instance can can safely collect values from multiple threads, however, the collector does use a mutex: Applications anticipating high contention for that lock can use addCollector
(and addIntegerCollector
) to obtain multiple collectors and thereby reduce contention. Finally, the collectAndReset
operation collects and returns metric records from each of the collectors in the repository.
Bloomberg software may alternatively use the GUTS telemetry API, which is integrated into Bloomberg infrastructure.
balm::CollectorRepository
is fully thread-safe, meaning that all non-creator operations on a given instance can be safely invoked simultaneously from multiple threads.
The following example illustrates creating a balm::CollectorRepository
, then looking up collectors in that repository, and finally collecting values from the repository. We start by creating a repository and looking up 2 collectors and 2 integer collectors:
We now update the values in those collectors:
We can use the repository to collect recorded values from the collectors it manages. Since there are collectors for four metrics, there should be four recorded values. Note the order in which the records are returned is undefined.
Finally we write the recorded values to the console:
The output of the for-loop should be: