Ejemplo n.º 1
0
  protected List<Message> getVisibleChildren(Transaction parent) {
    List<Message> children = new ArrayList<Message>();

    for (Message child : parent.getChildren()) {
      if (child instanceof Transaction) {
        children.add(child);
      } else if (child instanceof Event && "RemoteCall".equals(child.getType())) {
        children.add(child);
      }
    }

    return children;
  }
Ejemplo n.º 2
0
  protected int calculateLines(Transaction t) {
    int count = 1;

    for (Message child : t.getChildren()) {
      if (child instanceof Transaction) {
        count += calculateLines((Transaction) child);
      } else if (child instanceof Event) {
        if (child.getType().equals("RemoteCall")) {
          count++;
        }
      }
    }

    return count;
  }
Ejemplo n.º 3
0
  private int processTransaction(Machine machine, Transaction transaction, MessageTree tree) {
    int count = 0;
    String transactionType = transaction.getType();

    if (transactionType.startsWith("Cache.")) {
      count = processLongCache(machine, transaction, tree, count);
    } else if (transactionType.equals("SQL")) {
      count = processLongSql(machine, transaction, tree, count);
    }

    List<Message> messageList = transaction.getChildren();

    for (Message message : messageList) {
      if (message instanceof Transaction) {
        count += processTransaction(machine, (Transaction) message, tree);
      }
    }
    return count;
  }
Ejemplo n.º 4
0
  protected int encodeMessage(
      MessageTree tree, Message message, ChannelBuffer buf, int level, LineCounter counter) {
    if (message instanceof Transaction) {
      Transaction transaction = (Transaction) message;
      List<Message> children = transaction.getChildren();

      if (children.isEmpty()) {
        if (transaction.getDurationInMillis() < 0) {
          return encodeLine(tree, transaction, buf, 't', Policy.WITHOUT_STATUS, level, counter);
        } else {
          return encodeLine(tree, transaction, buf, 'A', Policy.WITH_DURATION, level, counter);
        }
      } else {
        int count = 0;

        count += encodeLine(tree, transaction, buf, 't', Policy.WITHOUT_STATUS, level, counter);

        for (Message child : children) {
          count += encodeMessage(tree, child, buf, level + 1, counter);
        }

        count += encodeLine(tree, transaction, buf, 'T', Policy.WITH_DURATION, level, counter);

        return count;
      }
    } else if (message instanceof Event) {
      String type = message.getType();

      if ("RemoteCall".equals(type)) {
        return encodeLogViewLink(tree, message, buf, level, counter);
      } else {
        return encodeLine(tree, message, buf, 'E', Policy.DEFAULT, level, counter);
      }
    } else if (message instanceof Metric) {
      return encodeLine(tree, message, buf, 'M', Policy.DEFAULT, level, counter);
    } else if (message instanceof Heartbeat) {
      return encodeLine(tree, message, buf, 'H', Policy.DEFAULT, level, counter);
    } else {
      throw new RuntimeException(
          String.format("Unsupported message type: %s.", message.getClass()));
    }
  }