Quick Links: |
#include <balm_collectorrepository.h>
This class defines a fully thread-safe repository mechanism for Collector
and IntegerCollector
objects. Collectors are identified in the repository by a MetricId
object and also grouped together according to the category of the metric. This repository supports operations to create, find, and collect metric records from the collectors in the repository.
See Component balm_collectorrepository
balm::CollectorRepository::CollectorRepository | ( | MetricRegistry * | registry, | |
bslma::Allocator * | basicAllocator = 0 | |||
) |
Create an empty collector repository that will use the specified registry
to identify the metrics for which it manages collectors. Optionally specify a basicAllocator
used to supply memory. If basicAllocator
is 0, the currently installed default allocator is used. The behavior is undefined if registry
is 0.
balm::CollectorRepository::~CollectorRepository | ( | ) |
Free all the collectors in this repository and destroy this object.
balm::CollectorRepository::BSLMF_NESTED_TRAIT_DECLARATION | ( | CollectorRepository | , | |
bslma::UsesBslmaAllocator | ||||
) |
void balm::CollectorRepository::collectAndReset | ( | bsl::vector< MetricRecord > * | records, | |
const Category * | category | |||
) |
void balm::CollectorRepository::collectAndReset | ( | std::vector< MetricRecord > * | records, | |
const Category * | category | |||
) |
Append to the specified records
the collected metric record values from the collectors in this repository belonging to the specified category
; then reset those collectors to their default values.
void balm::CollectorRepository::collect | ( | bsl::vector< MetricRecord > * | records, | |
const Category * | category | |||
) |
void balm::CollectorRepository::collect | ( | std::vector< MetricRecord > * | records, | |
const Category * | category | |||
) |
Append to the specified records
the collected metric record values from the collectors in this repository belonging to the specified category
. Note that this operation does not reset the managed collectors, so subsequent collection operations will effectively re-collect the current values.
Collector* balm::CollectorRepository::getDefaultCollector | ( | const char * | category, | |
const char * | metricName | |||
) |
Return the address of the modifiable default collector identified by the specified null-terminated strings category
and metricName
. If a collector for the identified metric does not already exist in the repository, create one, add it to the repository, and return its address. In addition, if the identified metric has not already been registered, add the identified metric to the metricRegistry
supplied at construction. Note that this operation is logically equivalent to:
getDefaultCollector(registry().getId(category, metricName))
Return the address of the modifiable default collector identified by the specified metricId
. If a default collector for the identified metric does not already exist in the repository, create one, add it to the repository, and return its address.
IntegerCollector* balm::CollectorRepository::getDefaultIntegerCollector | ( | const char * | category, | |
const char * | metricName | |||
) |
Return the address of the modifiable default integer collector identified by the specified category
and metricName
. If a default integer collector for the identified metric does not already exist in the repository, create one, add it to the repository, and return its address. In addition, if the identified metric has not already been registered, add the identified metric to the metricRegistry
supplied at construction. The behavior is undefined unless category
and metricName
are null-terminated. Note that this operation is logically equivalent to:
getDefaultIntegerCollector(registry().getId(category, metricName))
IntegerCollector* balm::CollectorRepository::getDefaultIntegerCollector | ( | const MetricId & | metricId | ) |
Return the address of the modifiable default integer collector identified by the specified metricId
. If a default integer collector for the identified metric does not already exist in the repository, create one, add it to the repository, and return its address.
bsl::shared_ptr<Collector> balm::CollectorRepository::addCollector | ( | const char * | category, | |
const char * | metricName | |||
) |
Return a shared pointer to a newly-created modifiable collector identified by the specified null-terminated strings category
and metricName
, and add that collector to the repository. If is not already registered, also add the identified metric to the metricRegistry
supplied at construction. Note that this operation is logically equivalent to:
addCollector(registry().getId(category, metricName))
bsl::shared_ptr<Collector> balm::CollectorRepository::addCollector | ( | const MetricId & | metricId | ) |
Return a shared pointer to a newly-created modifiable collector identified by the specified metricId
and add that collector to the repository. The behavior is undefined unless metricId
is a valid id returned by the MetricRepository
supplied at construction.
bsl::shared_ptr<IntegerCollector> balm::CollectorRepository::addIntegerCollector | ( | const char * | category, | |
const char * | metricName | |||
) |
Return a shared pointer to a newly created modifiable integer collector identified by the specified category
and metricName
and add that collector to the repository. If is not already registered, also add the identified metric to the metricRegistry
supplied at construction. The behavior is undefined unless category
and metricName
are null-terminated. Note that this operation is logically equivalent to:
addIntegerCollector(registry().getId(category, metricName))
bsl::shared_ptr<IntegerCollector> balm::CollectorRepository::addIntegerCollector | ( | const MetricId & | metricId | ) |
Return a shared pointer to a newly-created modifiable collector identified by the specified metricId
and add that collector to the repository. The behavior is undefined unless metricId
is a valid id returned by the MetricRepository
supplied at construction.
int balm::CollectorRepository::getAddedCollectors | ( | bsl::vector< bsl::shared_ptr< Collector > > * | collectors, | |
bsl::vector< bsl::shared_ptr< IntegerCollector > > * | intCollectors, | |||
const MetricId & | metricId | |||
) |
int balm::CollectorRepository::getAddedCollectors | ( | std::vector< bsl::shared_ptr< Collector > > * | collectors, | |
std::vector< bsl::shared_ptr< IntegerCollector > > * | intCollectors, | |||
const MetricId & | metricId | |||
) |
Append to the specified collectors
and intCollectors
shared pointers to any collectors, and integer collectors, collecting values for the metrics identified by the specified metricId
that were added using the addCollector
or addIntegerCollector
methods, and return the combined total number of collectors and integer collectors that were found. This method does not count or return the default collectors for metricId
. The behavior is undefined unless metricId
is a valid id returned by the MetricRepository
supplied at construction.
MetricRegistry& balm::CollectorRepository::registry | ( | ) |
Return a reference to the modifiable registry of metrics used by this collector repository.
const MetricRegistry& balm::CollectorRepository::registry | ( | ) | const |
Return a reference to the non-modifiable registry of metrics used by this collector repository.