Esempio n. 1
0
 @Override
 public Object call() throws Exception {
   long start = System.currentTimeMillis();
   Exception exception = null;
   try {
     observer.snapshot(timestamp);
     return null;
   } catch (Exception e) {
     exception = e;
     return null;
   } finally {
     long stop = System.currentTimeMillis();
     long duration = stop - start;
     StringBuilder sb = new StringBuilder();
     sb.append("snapshot for service [")
         .append(serviceConfig.getName())
         .append("] observer [")
         .append(observer.getName())
         .append("]: time=")
         .append((stop - start))
         .append(" ms");
     if (exception == null) {
       sb.append("; result was ok");
       // only print out good case if > step
       if (duration >= serviceConfig.getStepMillis()) {
         logger.warn("{} but exceeded stepMillis", sb);
       }
     } else {
       sb.append("; exception: ").append(exception.getMessage());
       logger.warn("{}", sb);
       logger.warn("", exception);
     }
   }
 }