[#BloombergLP-balm-MetricsManager]
= xref:BloombergLP.adoc[BloombergLP]::xref:BloombergLP/balm.adoc[balm]::MetricsManager
:relfileprefix: ../../
:mrdocs:

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

== Synopsis

Declared in `&lt;balm&lowbar;metricsmanager&period;h&gt;`

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
class MetricsManager;
----

== Type Aliases

[cols="1,4"]
|===
| Name| Description
| xref:BloombergLP/balm/MetricsManager/CallbackHandle.adoc[`CallbackHandle`] 
| Identifies a registered `RecordsCollectionCallback`&period;
| xref:BloombergLP/balm/MetricsManager/RecordsCollectionCallback.adoc[`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&period; Clients can register callbacks matching this prototype with the metrics manager&period; Here is an example prototype matching this callback&colon; &grave; void collectionCb(bsl&colon;&colon;vector&lt;MetricRecord&gt; &ast;records, bool resetFlag)&semi; &grave;
|===


== Enums

[cols="1,4"]
|===
| Name| Description
| xref:BloombergLP/balm/MetricsManager/_04enum.adoc[`Unnamed enum`] 
| Callback handle constants&period;
|===


== Member Functions

[cols="1,4"]
|===
| Name| Description
| xref:BloombergLP/balm/MetricsManager/2constructor.adoc[`MetricsManager`]         [.small]#[constructor]#
| Create a `MetricsManager`&period; Optionally specify a `basicAllocator` used to supply memory&period; If `basicAllocator` is 0, the currently installed default allocator is used&period;
| xref:BloombergLP/balm/MetricsManager/2destructor.adoc[`&#126;MetricsManager`] [.small]#[destructor]#
| Destroy this `MetricsManager`&period;
| xref:BloombergLP/balm/MetricsManager/addGeneralPublisher.adoc[`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&period; Return 0 on success, and a non&hyphen;zero value with no effect if `publisher` has already been registered&period; After this method returns, _any_ category published by this metrics manager will be published to `publisher`&period; Note that this method will have no effect and return a non&hyphen;zero value if `publisher` was previously registered for one or more specific categories (using the alternative `addSpecificPublisher` method)&period;
| xref:BloombergLP/balm/MetricsManager/addSpecificPublisher-06.adoc[`addSpecificPublisher`] 
| `addSpecificPublisher` overloads
| xref:BloombergLP/balm/MetricsManager/collectSample-0c.adoc[`collectSample`] 
| `collectSample` overloads
| xref:BloombergLP/balm/MetricsManager/collectorRepository-077.adoc[`collectorRepository`] 
| `collectorRepository` overloads
| xref:BloombergLP/balm/MetricsManager/findGeneralPublishers-09.adoc[`findGeneralPublishers`] 
| `findGeneralPublishers` overloads
| xref:BloombergLP/balm/MetricsManager/findSpecificPublishers-02.adoc[`findSpecificPublishers`] 
| `findSpecificPublishers` overloads
| xref:BloombergLP/balm/MetricsManager/metricRegistry-0f.adoc[`metricRegistry`] 
| `metricRegistry` overloads
| xref:BloombergLP/balm/MetricsManager/publish-028.adoc[`publish`] 
| `publish` overloads
| xref:BloombergLP/balm/MetricsManager/publishAll-027.adoc[`publishAll`] 
| `publishAll` overloads
| xref:BloombergLP/balm/MetricsManager/registerCollectionCallback-0a.adoc[`registerCollectionCallback`] 
| `registerCollectionCallback` overloads
| xref:BloombergLP/balm/MetricsManager/removeCollectionCallback.adoc[`removeCollectionCallback`] 
| Remove the callback associated with the specified `handle`&period; Return 0 on success, or a non&hyphen;zero value if `handle` cannot be found&period;
| xref:BloombergLP/balm/MetricsManager/removePublisher-099.adoc[`removePublisher`] 
| `removePublisher` overloads
| xref:BloombergLP/balm/MetricsManager/setAllCategoriesEnabled.adoc[`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&period; 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&lowbar;metric` documentation)&period; 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&hyphen;created categories)&period; Hence, subsequent calls to `setCategoryEnabled` will override this value for a particular category&period; Note that this operation is thread&hyphen;safe, but _not_ atomic&colon; Other threads may simultaneously access the current enabled status for a category while this operation completes&period; Also note that this operation has _linear_ runtime performance with respect to the total number of category holders registered with `metricRegistry()` (see `balm&lowbar;metricregistry` and `balm&lowbar;category` for information on category holders)&period;
| xref:BloombergLP/balm/MetricsManager/setCategoryEnabled-0c.adoc[`setCategoryEnabled`] 
| `setCategoryEnabled` overloads
| xref:BloombergLP/balm/MetricsManager/2conversion.adoc[`operator BloombergLP::bslmf::NestedTraitDeclaration&lt;MetricsManager, UsesBslmaAllocator&gt;`] 
| Declare that this type uses a `bslma` allocator&period;
|===


== Friends

[cols="1,4"]
|===
| Name| Description
| `xref:BloombergLP/balm/MetricsManager_PublicationHelper.adoc[BloombergLP::balm::MetricsManager&lowbar;PublicationHelper]`
| defined in implementation
|===


[.small]#Created with https://www.mrdocs.com[MrDocs]#
