[#BloombergLP-bdlm-MetricsRegistry-registerCollectionCallback]
= xref:BloombergLP.adoc[BloombergLP]::xref:BloombergLP/bdlm.adoc[bdlm]::xref:BloombergLP/bdlm/MetricsRegistry.adoc[MetricsRegistry]::registerCollectionCallback
:relfileprefix: ../../../
:mrdocs:

Register the metric described by the specified `descriptor` and associate it with the specified `callback` to collect data from the metric, and load the specified `result` with a handle can be used later to unregister the metric&period; Return 0 on success, and a non&hyphen;zero value otherwise&period; After this operation completes, `result&hyphen;&gt;isRegistered()` will be `true`&period; The metric and associated callback remain registered with this registry until either the handle is unregistered or destroyed&period; When a `MetricsAdapter` is associated with this registry using `setMetricsAdapter`, this object registers all the registered metrics and callbacks with that adapter, and similarly unregisters them if the `MetricAdapter` is later disassociated with this registry (either on this objects destruction, or due to a call to `removeMetricsAdapter` or `setMetricsAdapter`)&period; Furthermore, metrics collection can be disable with `disableMetricsCollection` and enabled with `enableMetricsCollection`&period; In this way, a `MetricsRegistry` serves as an intermediary between users of `bdlm` that register metrics and the subsystem for collecting and publishing metrics being adapted by a concrete instance of `bdlm&colon;&colon;MetricAdapter`&period;

== Synopsis

Declared in `&lt;bdlm&lowbar;metricsregistry&period;h&gt;`

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
int
registerCollectionCallback(
    xref:BloombergLP/bdlm/MetricsRegistryRegistrationHandle.adoc[MetricsRegistryRegistrationHandle]* result,
    xref:BloombergLP/bdlm/MetricDescriptor.adoc[bdlm::MetricDescriptor] const& descriptor,
    xref:BloombergLP/bdlm/MetricsRegistry/Callback.adoc[Callback] const& callback);
----


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