[#BloombergLP-balm-MetricsManager-registerCollectionCallback-0a] = xref:BloombergLP.adoc[BloombergLP]::xref:BloombergLP/balm.adoc[balm]::xref:BloombergLP/balm/MetricsManager.adoc[MetricsManager]::registerCollectionCallback :relfileprefix: ../../../ :mrdocs: `registerCollectionCallback` overloads == Synopses Declared in `<balm_metricsmanager.h>` Register the specified `callback` to collect records for the specified `category`, and return an opaque integer handle that can be used later to remove the `callback`. The supplied `callback` will be called to collect metrics from `category` each time `category` is published, even if `category` is disabled (i.e., `category‐>enabled()` is `false`). If the `publish` method is called on `category` and `category` is disabled, the `callback` will be invoked so clients may update any internal state, but the collected metrics will be ignored. Clients that wish to avoid overhead associated with collecting metrics for a disabled category must test (within their code) whether the category is disabled. The behavior is undefined if the `callback` returns metrics belonging to metric categories other than `category`. Note that the same `callback` can be registered for a `category` multiple times, and that registering the same `callback` multiple times will result in an equal number of invocations of the `callback` when publishing the `category`. [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- xref:BloombergLP/balm/MetricsManager/CallbackHandle.adoc[CallbackHandle] xref:BloombergLP/balm/MetricsManager/registerCollectionCallback-08.adoc[registerCollectionCallback]( xref:BloombergLP/balm/Category.adoc[Category] const* category, xref:BloombergLP/balm/MetricsManager/RecordsCollectionCallback.adoc[RecordsCollectionCallback] const& callback); ---- [.small]#xref:BloombergLP/balm/MetricsManager/registerCollectionCallback-08.adoc[_» more..._]# Register the specified `callback` to collect records for the category having the specified `categoryName`, and return an opaque integer handle that can be used later to remove the `callback`. The supplied `callback` will be called to collect metrics from the identified category each time the category is published or collected, even if the category is disabled. If the `publish` or `collectSample` method is called on the identified category, and the category is disabled, the `callback` will be invoked so clients may update any internal state, but the collected metrics will be ignored. Clients that wish to avoid overhead associated with collecting metrics for a disabled category must test (within their code) whether the category is disabled. The behavior is undefined if the `callback` returns metrics belonging to metric categories other than the one identified by `categoryName`, or if `categoryName` is not null‐terminated. Note that the same `callback` can be registered for a category multiple times, and that registering the same `callback` multiple times will result in an equal number of invocations of the `callback` when publishing the category. [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- xref:BloombergLP/balm/MetricsManager/CallbackHandle.adoc[MetricsManager::CallbackHandle] xref:BloombergLP/balm/MetricsManager/registerCollectionCallback-05.adoc[registerCollectionCallback]( char const* categoryName, xref:BloombergLP/balm/MetricsManager/RecordsCollectionCallback.adoc[RecordsCollectionCallback] const& callback); ---- [.small]#xref:BloombergLP/balm/MetricsManager/registerCollectionCallback-05.adoc[_» more..._]# [.small]#Created with https://www.mrdocs.com[MrDocs]#