[#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. Return 0 on success, and a non‐zero value otherwise. After this operation completes, `result‐>isRegistered()` will be `true`. The metric and associated callback remain registered with this registry until either the handle is unregistered or destroyed. 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`). Furthermore, metrics collection can be disable with `disableMetricsCollection` and enabled with `enableMetricsCollection`. 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::MetricAdapter`. == Synopsis Declared in `<bdlm_metricsregistry.h>` [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]#