BDE 4.14.0 Production release
|
Provide a container for a sample of collected metric records.
This component provides a container used to store a sample of recorded metric information. A balm::MetricSample
contains a collection of addresses to (external) balm::MetricRecord
objects containing the aggregated record values for a series of metrics. The records in a sample are broken into a series of groups, each group is represented by a balm::MetricSampleGroup
object. Each balm::MetricSampleGroup
contains a sequence of records and an elapsed time value, indicating the time period over which those records were collected. Finally, a balm::MetricSample
object contains a timestamp value used to indicate when the sample was taken.
Bloomberg software may alternatively use the GUTS telemetry API, which is integrated into Bloomberg infrastructure.
balm::MetricSample
and balm::MetricSampleGroup
are both const thread-safe, meaning that accessors may be invoked concurrently from different threads, but it is not safe to access or modify an object in one thread while another thread modifies the same object.
This section illustrates intended use of this component.
The following example demonstrates how to create and use a metric sample. We start by initializing several balm::MetricRecord
values, which we will add to the sample. Note that in this example we create the balm::MetricId
objects by hand; however, in practice ids should be obtained from a balm::MetricRegistry
object (such as the one owned by a balm::MetricsManager
).
Now we create the two arrays of metric records whose addresses we will later add to the metric sample:
Next we create a balm::MetricSample
object, sample
, and set its timestamp property. Then we add two groups of records (containing the addresses of our two record arrays) to the sample we have created. Since the records were not actually collected over a period of time, we supply an arbitrary elapsed time value of 1 second and 2 seconds (respectively) for the two groups added to the sample. Note that these arrays must remain valid for the lifetime of sample
.
We can verify the basic properties of our sample:
Finally we can obtain an iterator over the sample's sequence of groups. In this simple example, we iterate over the groups of records in the sample and, for each group, iterate over the records in that group, writing those records to the console.
The output will look like: