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

`collectSample` overloads

== Synopses

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

Load into the specified `sample` a metric sample collected from the indicated categories, and append to `records` those collected records which are referred to by `sample`&period; Optionally specify a sequence of `categories` of length `numCategories`&period; If a sequence of categories is not supplied, a sample is collected from all registered categories&period; Optionally specify a `resetFlag` that determines if the collected metrics are reset as part of this operation&period; This operation will collect aggregated metric values for each _enabled_ category in the indicated categories from registered callbacks as well as from its own `CollectorRepository`, and then append those values to `records` and update `sample` with the addresses of those collected `records`&period; If `resetFlag` is `true`, the metrics being collected are reset to their default state&period; This operation also populates the `sample` with the time interval is computed as the elapsed time since the interval over which the sampled metrics were collected&period; This last time the metrics were reset (either through a call to the `publish` or `collectSample` methods)&period; If `category` has not previously been reset then this interval is taken to be the elapsed time since the creation of this metrics manager&period; The behavior is undefined unless `0 &lt;&equals; numCategories`, `categories` refers to a contiguous sequence of (at least) `numCategories`, and each category in `categories` appears only once&period; Note that `sample` is loaded with the _addresses_ of the metric records appended to `records`, and modifying `records` after this call returns may invalidate `sample`&period;


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
void
xref:BloombergLP/balm/MetricsManager/collectSample-01.adoc[collectSample](
    xref:BloombergLP/balm/MetricSample.adoc[MetricSample]* sample,
    xref:bsl/vector-00d.adoc[bsl::vector&lt;MetricRecord&gt;]* records,
    bool resetFlag = false);
----

[.small]#xref:BloombergLP/balm/MetricsManager/collectSample-01.adoc[_» more&period;&period;&period;_]#

Same as the preceding overload, collecting from the specified `categories` sequence&period;


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
void
xref:BloombergLP/balm/MetricsManager/collectSample-06.adoc[collectSample](
    xref:BloombergLP/balm/MetricSample.adoc[MetricSample]* sample,
    xref:bsl/vector-00d.adoc[bsl::vector&lt;MetricRecord&gt;]* records,
    xref:BloombergLP/balm/Category.adoc[Category] const const* categories[],
    int numCategories,
    bool resetFlag = false);
----

[.small]#xref:BloombergLP/balm/MetricsManager/collectSample-06.adoc[_» more&period;&period;&period;_]#


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