Merge "Add shard ID to statsd atom for procstats collection" into rvc-dev

This commit is contained in:
TreeHugger Robot
2020-06-24 21:22:27 +00:00
committed by Android (Google) Code Review
2 changed files with 13 additions and 3 deletions

View File

@@ -6131,6 +6131,10 @@ message ProcessStatsAvailablePagesProto {
*/ */
message ProcStats { message ProcStats {
optional ProcessStatsSectionProto proc_stats_section = 1; optional ProcessStatsSectionProto proc_stats_section = 1;
// Data pulled from device into this is sometimes sharded across multiple atoms to work around
// a size limit. When this happens, this shard ID will contain an increasing 1-indexed integer
// with the number of this shard.
optional int32 shard_id = 2;
} }
/** /**

View File

@@ -2575,11 +2575,17 @@ public class StatsPullAtomService extends SystemService {
lastHighWaterMark, section, true, statsFiles, procStats); lastHighWaterMark, section, true, statsFiles, procStats);
procStats.dumpAggregatedProtoForStatsd(protoStreams, MAX_PROCSTATS_RAW_SHARD_SIZE); procStats.dumpAggregatedProtoForStatsd(protoStreams, MAX_PROCSTATS_RAW_SHARD_SIZE);
for (ProtoOutputStream proto : protoStreams) { for (int i = 0; i < protoStreams.length; i++) {
if (proto.getBytes().length > 0) { byte[] bytes = protoStreams[i].getBytes(); // cache the value
if (bytes.length > 0) {
StatsEvent e = StatsEvent.newBuilder() StatsEvent e = StatsEvent.newBuilder()
.setAtomId(atomTag) .setAtomId(atomTag)
.writeByteArray(proto.getBytes()) .writeByteArray(bytes)
// This is a shard ID, and is specified in the metric definition to be
// a dimension. This will result in statsd using RANDOM_ONE_SAMPLE to
// keep all the shards, as it thinks each shard is a different dimension
// of data.
.writeInt(i)
.build(); .build();
pulledData.add(e); pulledData.add(e);
} }