BDE 4.14.0 Production release
Loading...
Searching...
No Matches
balm_streampublisher

Detailed Description

Outline

Purpose

Provide a balm::Publisher implementation that writes to a stream.

Classes

See also
balm_publisher, balm_metricrecord, balm_metricsmanager

Description

This component defines a concrete class balm::StreamPublisher that implements the balm::Publisher protocol for publishing metric records:

| ctor
|
V
dtor
publish
Definition balm_publisher.h:276
Definition balm_streampublisher.h:151

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

This section illustrates intended use of this component.

Example 1: Basic 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).

balm::Category myCategory("MyCategory");
balm::MetricDescription descA(&myCategory, "MetricA");
balm::MetricDescription descB(&myCategory, "MetricB");
balm::MetricId metricA(&descA);
balm::MetricId metricB(&descB);
Definition balm_category.h:151
Definition balm_metricdescription.h:158
Definition balm_metricid.h:162

Now we create a balm::StreamPublisher object, supplying it the stdout stream:

balm::StreamPublisher myPublisher(bsl::cout);

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.

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()),
myPublisher.publish(sample);
Definition balm_metricrecord.h:217
Definition balm_metricsample.h:342
Definition bdlt_datetimetz.h:308
Definition bslstl_vector.h:1025
Definition bslma_allocator.h:457
Definition bsls_timeinterval.h:301
static Datetime utc()
Definition bdlt_currenttime.h:296
static Allocator * allocator(Allocator *basicAllocator=0)
Definition bslma_default.h:897

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 ]