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

This class defines a thread&hyphen;aware mechanism for registering metrics and metric categories&period;

== Synopsis

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

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

== Description

A metric is uniquely identified by its name and category, and the metric registry provides a mapping from those identifying properties to a `balm&colon;&colon;MetricId`&period; A `balm&colon;&colon;MetricRegistry` object also provides a mapping from a category name to the address of a non&hyphen;modifiable `balm&colon;&colon;Category` object&period;

== Member Functions

[cols="1,4"]
|===
| Name| Description
| xref:BloombergLP/balm/MetricRegistry/2constructor.adoc[`MetricRegistry`]         [.small]#[constructor]#
| Create an empty metric registry&period;
| xref:BloombergLP/balm/MetricRegistry/2destructor.adoc[`&#126;MetricRegistry`] [.small]#[destructor]#
| Destroy this metric registry&period;
| xref:BloombergLP/balm/MetricRegistry/addCategory.adoc[`addCategory`] 
| Add `category` to this registry unless it is already registered&period;
| xref:BloombergLP/balm/MetricRegistry/addId.adoc[`addId`] 
| Add a metric id for `category` and `name` if not already registered&period;
| xref:BloombergLP/balm/MetricRegistry/createUserDataKey.adoc[`createUserDataKey`] 
| Return a new unique key for associating user data with metrics&period;
| xref:BloombergLP/balm/MetricRegistry/findCategory.adoc[`findCategory`] 
| Find the registered category named `category`&period;
| xref:BloombergLP/balm/MetricRegistry/findId.adoc[`findId`] 
| Find the metric id for `category` and `name` in this registry&period;
| xref:BloombergLP/balm/MetricRegistry/getAllCategories.adoc[`getAllCategories`] 
| Append to the specified `categories` the addresses of all the categories registered by this `balm&colon;&colon;MetricRegistry` object&period;
| xref:BloombergLP/balm/MetricRegistry/getCategory.adoc[`getCategory`] 
| Return the category for `category`, registering it if needed&period;
| xref:BloombergLP/balm/MetricRegistry/getId.adoc[`getId`] 
| Return a metric id for `category` and `name`, registering if needed&period;
| xref:BloombergLP/balm/MetricRegistry/numCategories.adoc[`numCategories`] 
| Return the number of categories in this registry&period;
| xref:BloombergLP/balm/MetricRegistry/numMetrics.adoc[`numMetrics`] 
| Return the number of metrics in this registry&period;
| xref:BloombergLP/balm/MetricRegistry/print.adoc[`print`] 
| Format this object to the specified output `stream`&period;
| xref:BloombergLP/balm/MetricRegistry/registerCategoryHolder.adoc[`registerCategoryHolder`] 
| Register `holder` with `category` in this registry&period;
| xref:BloombergLP/balm/MetricRegistry/setAllCategoriesEnabled.adoc[`setAllCategoriesEnabled`] 
| Set the enabled state of all categories to `value`&period;
| xref:BloombergLP/balm/MetricRegistry/setCategoryEnabled.adoc[`setCategoryEnabled`] 
| Set whether `category` is enabled to `value`&period;
| xref:BloombergLP/balm/MetricRegistry/setFormat.adoc[`setFormat`] 
| Set the format for `metricId` to `format`&period;
| xref:BloombergLP/balm/MetricRegistry/setPreferredPublicationType.adoc[`setPreferredPublicationType`] 
| Set the preferred publication type of `metric` to `type`&period;
| xref:BloombergLP/balm/MetricRegistry/setUserData-0b.adoc[`setUserData`] 
| `setUserData` overloads
| xref:BloombergLP/balm/MetricRegistry/2conversion.adoc[`operator BloombergLP::bslmf::NestedTraitDeclaration&lt;MetricRegistry, UsesBslmaAllocator&gt;`] 
| Declare that this type uses a `bslma` allocator&period;
|===



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