Пример #1
0
 private void addRows(Scanner scanner, String type, Table trace) {
   for (Entry<Key, Value> entry : scanner) {
     RemoteSpan span = TraceFormatter.getRemoteSpan(entry);
     if (span.description.equals(type)) {
       trace.addRow(span, Long.valueOf(span.stop - span.start), span.svc + ":" + span.sender);
     }
   }
 }
Пример #2
0
  @Override
  public void pageBody(HttpServletRequest req, HttpServletResponse resp, StringBuilder sb)
      throws Exception {
    final String type = getType(req);
    int minutes = getMinutes(req);
    long endTime = System.currentTimeMillis();
    long startTime = endTime - minutes * 60 * 1000;
    Entry<Scanner, UserGroupInformation> entry = getScanner(sb);
    final Scanner scanner = entry.getKey();
    if (scanner == null) {
      return;
    }
    Range range =
        new Range(
            new Text("start:" + Long.toHexString(startTime)),
            new Text("start:" + Long.toHexString(endTime)));
    scanner.setRange(range);
    final Table trace = new Table("trace", "Traces for " + getType(req));
    trace.addSortableColumn("Start", new ShowTraceLinkType(), "Start Time");
    trace.addSortableColumn("ms", new DurationType(), "Span time");
    trace.addUnsortableColumn("Source", new StringType<String>(), "Service and location");

    if (null != entry.getValue()) {
      entry
          .getValue()
          .doAs(
              new PrivilegedAction<Void>() {
                @Override
                public Void run() {
                  addRows(scanner, type, trace);
                  return null;
                }
              });
    } else {
      addRows(scanner, type, trace);
    }

    trace.generate(req, sb);
  }