Map<String, RpcStats> statsByRpc = new HashMap<String, RpcStats>();
BigDecimal totalCostMicropennies = new BigDecimal(0);
for (int i = 0; i < records.size(); i++) {
RequestStatProto requestStat = records.get(i);
String pathKey = extractKey(requestStat);
PathStats pathStats = statsByPath.get(pathKey);
if (pathStats == null) {
pathStats = new PathStats(pathKey);
statsByPath.put(pathKey, pathStats);
}
if (pathStats.requestIds.size() >= 10) {
if (pathStats.requestIds.get(pathStats.requestIds.size() - 1) != 0) {
pathStats.requestIds.add(0);
}
} else {
pathStats.requestIds.add(i + 1);
}
for (AggregateRpcStatsProto aggregateStat : requestStat.getRpcStatsList()) {
String rpcKey = aggregateStat.getServiceCallName();
long totalCalls = aggregateStat.getTotalAmountOfCalls();
long costMicropennies = aggregateStat.getTotalCostOfCallsMicrodollars();
totalCostMicropennies = totalCostMicropennies.add(new BigDecimal(costMicropennies));
RpcStats rpcStats = statsByRpc.get(rpcKey);