final ByteBuf bb = msg.content();
byte[] buf = new byte[bb.readableBytes()];
bb.readBytes(buf);
CodedInputStream in = CodedInputStream.newInstance(buf);
final int numMetrics = in.readRawVarint32();
List<Metric> metrics = new ArrayList<Metric>(numMetrics);
for (int i = 0; i < numMetrics; i++) {
String tenantId = in.readString();
String metricName = in.readString();
DataType type = new DataType(in.readString());
long collectionTime = in.readRawVarint64();
int ttlSecs = in.readRawVarint32();
String units = in.readString();
Object value = null;
if (type.equals(DataType.BOOLEAN))
value = in.readBool();
else if (type.equals(DataType.DOUBLE))
value = in.readDouble();
else if (type.equals(DataType.INT))
value = in.readRawVarint32();
else if (type.equals(DataType.LONG))
value = in.readRawVarint64();
else if (type.equals(DataType.STRING))
value = in.readString();
if (value != null) {
metrics.add(new Metric(
Locator.createLocatorFromPathComponents(tenantId, metricName),
value,