[SystemProfile] Add support for CHANNEL field
Change-Id: I94bd3127086f84d0c81be8dabbd24212bc42d969
diff --git a/analyzer/report_master/report_serializer.cc b/analyzer/report_master/report_serializer.cc
index 6e65a81..f4c01d0 100644
--- a/analyzer/report_master/report_serializer.cc
+++ b/analyzer/report_master/report_serializer.cc
@@ -511,6 +511,9 @@
case cobalt::SystemProfileField::SYSTEM_VERSION:
(*stream) << "System_Version";
break;
+ case cobalt::SystemProfileField::CHANNEL:
+ (*stream) << "Channel";
+ break;
}
}
return grpc::Status::OK;
@@ -621,6 +624,9 @@
case SystemProfileField::SYSTEM_VERSION:
(*stream) << ToCSVString(profile.system_version());
break;
+ case SystemProfileField::CHANNEL:
+ (*stream) << ToCSVString(profile.channel());
+ break;
}
}
}
diff --git a/analyzer/store/observation_store.cc b/analyzer/store/observation_store.cc
index a0ea536..be14c0e 100644
--- a/analyzer/store/observation_store.cc
+++ b/analyzer/store/observation_store.cc
@@ -239,6 +239,10 @@
break;
case SystemProfileField::SYSTEM_VERSION:
dst->set_allocated_system_version(src->release_system_version());
+ break;
+ case SystemProfileField::CHANNEL:
+ dst->set_allocated_channel(src->release_channel());
+ break;
}
}
}
diff --git a/config/metrics.proto b/config/metrics.proto
index faf31d6..c5525b3 100644
--- a/config/metrics.proto
+++ b/config/metrics.proto
@@ -27,6 +27,7 @@
BOARD_NAME = 2;
PRODUCT_NAME = 3;
SYSTEM_VERSION = 4;
+ CHANNEL = 5;
}
// ExponentialIntegerBuckets is used to define a partition of the integers into
diff --git a/encoder/encoder.cc b/encoder/encoder.cc
index f775fe6..33093b3 100644
--- a/encoder/encoder.cc
+++ b/encoder/encoder.cc
@@ -423,6 +423,10 @@
result.metadata->mutable_system_profile()->set_system_version(
profile.system_version());
break;
+ case SystemProfileField::CHANNEL:
+ result.metadata->mutable_system_profile()->set_channel(
+ profile.channel());
+ break;
}
}
}
diff --git a/encoder/system_data.cc b/encoder/system_data.cc
index 65985af..9620cb7 100644
--- a/encoder/system_data.cc
+++ b/encoder/system_data.cc
@@ -100,6 +100,10 @@
PopulateSystemProfile();
}
+void SystemData::SetChannel(const std::string& channel) {
+ system_profile_.set_channel(channel);
+}
+
void SystemData::OverrideSystemProfile(const SystemProfile& profile) {
system_profile_ = profile;
}
diff --git a/encoder/system_data.h b/encoder/system_data.h
index 93a226d..95942f8 100644
--- a/encoder/system_data.h
+++ b/encoder/system_data.h
@@ -5,9 +5,8 @@
#ifndef COBALT_ENCODER_SYSTEM_DATA_H_
#define COBALT_ENCODER_SYSTEM_DATA_H_
-#include <string>
-
#include <mutex>
+#include <string>
#include <utility>
#include <vector>
@@ -75,6 +74,9 @@
experiments_ = std::move(experiments);
}
+ // Resets the current channel value.
+ void SetChannel(const std::string& channel);
+
// Overrides the stored SystemProfile. Useful for testing.
void OverrideSystemProfile(const SystemProfile& profile);
diff --git a/encoder/system_data_test.cc b/encoder/system_data_test.cc
index 2651265..dc8d948 100644
--- a/encoder/system_data_test.cc
+++ b/encoder/system_data_test.cc
@@ -5,6 +5,7 @@
#include "encoder/system_data.h"
#include <stdio.h>
+
#include <set>
#include <string>
#include <utility>
@@ -66,6 +67,13 @@
EXPECT_EQ(system_data.experiments().front().arm_id(), kArmId);
}
+TEST(SystemDataTest, SetChannelTest) {
+ SystemData system_data("test_product", "", "test_version");
+ EXPECT_EQ(system_data.system_profile().channel(), "");
+ system_data.SetChannel("Channel");
+ EXPECT_EQ(system_data.system_profile().channel(), "Channel");
+}
+
} // namespace encoder
} // namespace cobalt
diff --git a/logger/encoder.cc b/logger/encoder.cc
index 25dc8b1..2fe54fb 100644
--- a/logger/encoder.cc
+++ b/logger/encoder.cc
@@ -376,6 +376,9 @@
metadata->mutable_system_profile()->set_system_version(
profile.system_version());
break;
+ case SystemProfileField::CHANNEL:
+ metadata->mutable_system_profile()->set_channel(profile.channel());
+ break;
}
}
}
diff --git a/observation_batch.proto b/observation_batch.proto
index f01a6bb..c228711 100644
--- a/observation_batch.proto
+++ b/observation_batch.proto
@@ -66,6 +66,9 @@
// value for |version| is "20190220_01_RC00".
string system_version = 8;
+ // This is a string representation of the current channel.
+ string channel = 9;
+
// Contains all the experiments the device has a notion of and the experiment
// state the device belongs to.
repeated Experiment experiments = 7;