Exemplo n.º 1
0
 @Override
 public void run() {
   long before = System.currentTimeMillis();
   try {
     List<ListMetricQueueItem> dataBatch = Lists.newArrayList();
     dataQueue.drainTo(dataBatch);
     ThruputMetrics.addDataPoint(MonitoredAction.LIST_METRIC_SIZE, dataBatch.size());
     long t2 = System.currentTimeMillis();
     dataBatch = prune(dataBatch);
     long t3 = System.currentTimeMillis();
     ThruputMetrics.addDataPoint(MonitoredAction.LIST_METRIC_PRUNE, t3 - t2);
     List<ListMetric> listMetrics = convertToListMetrics(dataBatch);
     long t4 = System.currentTimeMillis();
     ThruputMetrics.addDataPoint(MonitoredAction.LIST_METRIC_CONVERT, t4 - t3);
     ListMetricManager.addMetricBatch(listMetrics);
     long t5 = System.currentTimeMillis();
     ThruputMetrics.addDataPoint(MonitoredAction.LIST_METRIC_MERTIC_ADD_BATCH, t5 - t4);
   } catch (Throwable ex) {
     LOG.debug("ListMetricQueue:error");
     ex.printStackTrace();
     LOG.error(ex, ex);
   } finally {
     ThruputMetrics.addDataPoint(
         MonitoredAction.LIST_METRIC_TIMING, System.currentTimeMillis() - before);
   }
 }
Exemplo n.º 2
0
 private static List<ListMetric> convertToListMetrics(List<ListMetricQueueItem> dataBatch) {
   if (dataBatch == null) return null;
   List<ListMetric> listMetrics = Lists.newArrayList();
   for (ListMetricQueueItem item : dataBatch) {
     listMetrics.add(
         ListMetricManager.createListMetric(
             item.getAccountId(),
             item.getMetricName(),
             item.getMetricType(),
             item.getNamespace(),
             item.getDimensionMap()));
   }
   return listMetrics;
 }