Provide a balm::Publisher
implementation that writes to a stream.
More...
Namespaces |
namespace | balm |
Detailed Description
- Outline
-
-
- Purpose:
- Provide a
balm::Publisher
implementation that writes to a stream.
-
- Classes:
-
- See also:
- Component balm_publisher, Component balm_metricrecord, Component balm_metricsmanager
-
- Description:
- This component defines a concrete class
balm::StreamPublisher
that implements the balm::Publisher
protocol for publishing metric records: This implementation of the publisher protocol publishes records to an output stream that is supplied at construction.
-
- Alternative Systems for Telemetry:
- Bloomberg software may alternatively use the GUTS telemetry API, which is integrated into Bloomberg infrastructure.
-
- Usage:
- In the following example we illustrate how to create and publish records with a
balm::StreamPublisher
. First we define a couple of metric ids. Note that we create the balm::MetricId
objects by hand, but in practice an id should be obtained from a balm::MetricRegistry
object (such as the one owned by a balm::MetricsManager
). Now we create a balm::StreamPublisher
object, supplying it the stdout
stream: Next we create a metric sample containing some records and pass it to the balm::StreamPublisher
we created. Note that because we are not actually collecting the metrics we set the elapsed time of the sample to an arbitrary 5s interval. bslma::Allocator *allocator = bslma::Default::allocator(0);
bsl::vector<balm::MetricRecord> records(allocator);
records.push_back(balm::MetricRecord(metricA, 5, 25.0, 6.0, 25.0));
records.push_back(balm::MetricRecord(metricB, 2, 7.0, 3.0, 11.0));
balm::MetricSample sample(allocator);
sample.setTimeStamp(bdlt::DatetimeTz(bdlt::CurrentTime::utc(), 0));
sample.appendGroup(records.data(),
static_cast<int>(records.size()),
bsls::TimeInterval(5, 0));
myPublisher.publish(sample);
The output of this example would look similar to: 05FEB2009_19:52:11.723+0000 2 Records
Elapsed Time: 5s
MyCategory.MetricA [ count = 5, total = 25, min = 6, max = 25 ]
MyCategory.MetricB [ count = 2, total = 7, min = 3, max = 11 ]