This class implements a manager for the recording and publishing of metrics. Metrics managed by a MetricsManager are grouped into categories identified by a string. The metrics manager allows clients to register a Publisher object using the addGeneralPublisher and addSpecificPublisher operations. Metrics can be recorded in one of two ways: Clients can (1) implement their own metric collection facilities and register a callback using this metric manager's registerMetricsCallback method; or (2) use the Collector objects available from the CollectorRepository owned by this metrics manager.

Synopsis

Declared in <balm_metricsmanager.h>

class MetricsManager;

Type Aliases

Name

Description

CallbackHandle

Identifies a registered RecordsCollectionCallback.

RecordsCollectionCallback

RecordsCollectionCallback is an alias for a callback function that appends to the supplied MetricRecord vector the values of the collected metrics, and, if the provided bool is true, resets those metrics to their default values. Clients can register callbacks matching this prototype with the metrics manager. Here is an example prototype matching this callback: ` void collectionCb(bsl::vector<MetricRecord> *records, bool resetFlag); `

Enums

Name

Description

Unnamed enum

Callback handle constants.

Member Functions

Name

Description

MetricsManager [constructor]

Create a MetricsManager. Optionally specify a basicAllocator used to supply memory. If basicAllocator is 0, the currently installed default allocator is used.

~MetricsManager [destructor]

Destroy this MetricsManager.

addGeneralPublisher

Add the specified publisher to the set of publishers that will be used to propagate records for every category published by this metrics manager. Return 0 on success, and a non‐zero value with no effect if publisher has already been registered. After this method returns, any category published by this metrics manager will be published to publisher. Note that this method will have no effect and return a non‐zero value if publisher was previously registered for one or more specific categories (using the alternative addSpecificPublisher method).

addSpecificPublisher

addSpecificPublisher overloads

collectSample

collectSample overloads

collectorRepository

collectorRepository overloads

findGeneralPublishers

findGeneralPublishers overloads

findSpecificPublishers

findSpecificPublishers overloads

metricRegistry

metricRegistry overloads

publish

publish overloads

publishAll

publishAll overloads

registerCollectionCallback

registerCollectionCallback overloads

removeCollectionCallback

Remove the callback associated with the specified handle. Return 0 on success, or a non‐zero value if handle cannot be found.

removePublisher

removePublisher overloads

setAllCategoriesEnabled

Set whether each category currently registered with metricRegistry() is enabled to the specified value, and ensure that categories registered after this call are initialized as either enabled or disabled, accordingly. If a category is disabled it will not be published (see the publish methods), and higher level components may not record values for metrics belonging to the category (for an example, see the balm_metric documentation). This operation is logically equivalent to iterating over the list of categories currently registered with metricRegistry() and calling setCategoryEnabled on each category individually, and also setting a default isEnabled() value (for newly‐created categories). Hence, subsequent calls to setCategoryEnabled will override this value for a particular category. Note that this operation is thread‐safe, but not atomic: Other threads may simultaneously access the current enabled status for a category while this operation completes. Also note that this operation has linear runtime performance with respect to the total number of category holders registered with metricRegistry() (see balm_metricregistry and balm_category for information on category holders).

setCategoryEnabled

setCategoryEnabled overloads

operator BloombergLP::bslmf::NestedTraitDeclaration<MetricsManager, UsesBslmaAllocator>

Declare that this type uses a bslma allocator.

Friends

Name

Description

BloombergLP::balm::MetricsManager_PublicationHelper

defined in implementation

Created with MrDocs