Package com.dianping.cat.message

Examples of com.dianping.cat.message.Transaction


  }

  @Test
  public void test3() throws InterruptedException {
    for (int i = 0; i < 500; i++) {
      Transaction t = Cat.newTransaction("test", "test");

      Cat.logMetricForCount("MemberCardSuccess");
      Cat.logMetricForCount("MemberCardFail", 2);

      MessageTree tree = Cat.getManager().getThreadLocalMessageTree();
      ((DefaultMessageTree) tree).setDomain("MobileMembercardMainApiWeb");
      t.complete();
    }
    Thread.sleep(100000);
  }
View Full Code Here


  public void sample() {
    String pageName = "";
    String serverIp = "";
   
    Transaction t = Cat.newTransaction("URL", pageName); //创建一个Transaction

    try {
      //记录一个事件
      Cat.logEvent("URL.Server", serverIp, Event.SUCCESS, "ip=" + serverIp + "&...");
      //记录一个业务指标,记录订单次数
      Cat.logMetricForCount("OrderCount");
      //记录一个业务指标,记录支付次数
      Cat.logMetricForCount("PayCount");
     
      yourBusiness();//自己业务代码
     
      t.setStatus(Transaction.SUCCESS);//设置状态
    } catch (Exception e) {
      t.setStatus(e);//设置错误状态
    } finally {
      t.complete();//结束Transaction
    }
  }
View Full Code Here

  private void processTransaction(HeartbeatReport report, MessageTree tree, Transaction transaction) {
    List<Message> children = transaction.getChildren();

    for (Message message : children) {
      if (message instanceof Transaction) {
        Transaction temp = (Transaction) message;

        processTransaction(report, tree, temp);
      } else if (message instanceof Heartbeat) {
        if (message.getType().equalsIgnoreCase("heartbeat")) {
          processHeartbeat(report, (Heartbeat) message, tree);
View Full Code Here

public class TestCrashLog {

  @Test
  public void test() throws InterruptedException {
    for (int i = 0; i < 100; i++) {
      Transaction t = Cat.newTransaction("url", "crash");

      String message = parse(i);

      Cat.logEvent("Exception", message, "ERROR", "sdf");

      String plateform = getPlateform(i);
      String version = getVersion(i);

      MessageTree tree = Cat.getManager().getThreadLocalMessageTree();
      ((DefaultMessageTree) tree).setIpAddress(plateform + ":" + version);
      ((DefaultMessageTree) tree).setDomain("CrashLogWeb");
      t.complete();
    }
    Thread.sleep(10000);
    // code nullpoint
  }
View Full Code Here

public class TestSendMessage {

  @Test
  public void sendException() throws Exception {
    for (int i = 0; i < 10; i++) {
      Transaction t = Cat.newTransaction("Midas", "XXName");
      try {
        t.setStatus("Fail");
       
        DefaultMessageTree  tree =(DefaultMessageTree) Cat.getManager().getThreadLocalMessageTree();
     
        tree.setDomain("rs-mapi-web");
      } catch (Exception e) {
        t.setStatus(Transaction.SUCCESS);
        Cat.logError(e);
        throw e;
      } finally {
        t.complete();
      }
    }
    Thread.sleep(10000);
  }
View Full Code Here

  }
 
  @Test
  public void sendSendUrlErrorMessage() throws Exception {
    for (int i = 0; i < 100; i++) {
      Transaction t = Cat.getProducer().newTransaction("URL", "Test");

      t.addData("key and value");
      t.setStatus(new NullPointerException());
      t.complete();
    }
    Thread.sleep(10000);
  }
View Full Code Here

  }

  @Override
  public ModelResponse<T> invoke(ModelRequest request) {
    ModelResponse<T> response = new ModelResponse<T>();
    Transaction t = Cat.newTransaction("ModelService", getClass().getSimpleName());

    try {
      ModelPeriod period = request.getPeriod();
      String domain = request.getDomain();
      T report = getReport(request, period, domain);

      t.addData("period", period);
      t.addData("domain", domain);

      if (report != null) {
        response.setModel(report);
        t.setStatus(Message.SUCCESS);
      } else {
        t.setStatus("NoReportFound");
      }
    } catch (Exception e) {
      Cat.logError(e);
      t.setStatus(e);
      response.setException(e);
    } finally {
      t.complete();
    }
    return response;
  }
View Full Code Here

  }

  @Test
  public void sendSendCallErrorMessage() throws Exception {
    for (int i = 0; i < 100; i++) {
      Transaction t = Cat.getProducer().newTransaction("Call", "Test");

      t.addData("key and value");
      t.setStatus(new NullPointerException());
      t.complete();

    }
    Thread.sleep(1000);
  }
View Full Code Here

  }

  @Test
  public void sendSendSqlErrorMessage() throws Exception {
    for (int i = 0; i < 100; i++) {
      Transaction t = Cat.getProducer().newTransaction("SQL", "Test");

      t.addData("key and value");
      t.setStatus(new NullPointerException());
      t.complete();
    }
    Thread.sleep(1000);
  }
View Full Code Here

  }

  @Test
  public void sendMessage() throws Exception {
    for (int i = 0; i < 100; i++) {
      Transaction t = Cat.getProducer().newTransaction("Test", "Test");

      t.addData("key and value");
      t.complete();

    }
    Thread.sleep(1000);
  }
View Full Code Here

TOP

Related Classes of com.dianping.cat.message.Transaction

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.