CDM Metrics Protocol buffer serialization.

An implementation that serializes metrics to a protocol buffer.

This is a merge from wvgerrit/28440.

I intend to submit 2048751, 2048750, and 2048509 together.

Bug: 36217927
Bug: 36220975
Test: Added unit tests to cover modified code.
Change-Id: Ie8b9d8b91d2602b015f5568890a16c0419c126df
This commit is contained in:
Adam Stone
2017-03-30 10:26:58 -07:00
parent a34e279d0f
commit b851dd8cfd
7 changed files with 706 additions and 19 deletions

View File

@@ -61,7 +61,7 @@ TEST_F(EventMetricTest, NoFieldsSuccessNullCallback) {
TEST_F(EventMetricTest, NoFieldsSuccessWithCallback) {
wvcdm::metrics::EventMetric<> metric("no/fields/metric");
EXPECT_CALL(*mock_serializer_,
SetInt64("no/fields/metric/count", 1.0));
SetInt64("no/fields/metric/count", 2));
EXPECT_CALL(*mock_serializer_,
SetDouble("no/fields/metric/mean", 10.0));
EXPECT_CALL(*mock_serializer_,
@@ -71,6 +71,23 @@ TEST_F(EventMetricTest, NoFieldsSuccessWithCallback) {
EXPECT_CALL(*mock_serializer_,
SetDouble("no/fields/metric/max", 10.0));
metric.Record(10);
metric.Record(10);
metric.Serialize(mock_serializer_.get());
std::map<std::string, Distribution*> value_map = GetValueMap(metric);
ASSERT_EQ(1u, GetValueMap(metric).size());
EXPECT_EQ(2, value_map.begin()->second->Count());
EXPECT_EQ("", value_map.begin()->first);
}
TEST_F(EventMetricTest, NoFieldsSuccessSingleRecordWithCallback) {
wvcdm::metrics::EventMetric<> metric("no/fields/metric");
EXPECT_CALL(*mock_serializer_,
SetInt64("no/fields/metric/count", 1.0));
EXPECT_CALL(*mock_serializer_,
SetDouble("no/fields/metric/mean", 10.0));
metric.Record(10);
metric.Serialize(mock_serializer_.get());