本文整理汇总了Java中com.dianping.cat.message.Transaction类的典型用法代码示例。如果您正苦于以下问题:Java Transaction类的具体用法?Java Transaction怎么用?Java Transaction使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Transaction类属于com.dianping.cat.message包,在下文中一共展示了Transaction类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: newtransation
import com.dianping.cat.message.Transaction; //导入依赖的package包/类
/**
* Cat.newTransaction 与Cat.getProducer().newTransaction 区别在于 一个是重新生成一个transation 和获取当前线程绑定的transaction“
*
* @return
* @throws Exception
*/
@RequestMapping(value = "/cycletransation", method = RequestMethod.GET)
public String newtransation() throws Exception {
Transaction t = Cat.getProducer().newTransaction("TransactionTest", "Cat.getProducer()");
Cat.getProducer().logEvent("eventType1", "1", Message.SUCCESS, "");
Cat.getProducer().logEvent("eventType1", "2", Message.SUCCESS, "");
Transaction t2 = Cat.getProducer().newTransaction("TransactionTest-1", "child transaction 1");
Cat.getProducer().logEvent("eventType2-1", "2-1", Message.SUCCESS, "");
Cat.getProducer().logEvent("eventType2-2", "2-2", Message.SUCCESS, "");
t2.addData("tChild transaction-1");
t2.setStatus(Message.SUCCESS);
t2.complete();
Transaction t3 = Cat.getProducer().newTransaction("TransactionTest-2", "child transaction 2");
Cat.getProducer().logEvent("eventType3-1", "3-1", Message.SUCCESS, "");
Cat.getProducer().logEvent("eventType3-2", "3-2", Message.SUCCESS, "");
t3.addData("Child transaction-2");
t3.setStatus(Message.SUCCESS);
// 休眠3s 验证时间
Thread.sleep(4000);
t3.complete();
t.addData(" Parent transaction");
t.setStatus(Message.SUCCESS);
t.complete();
return "";
}
开发者ID:ggj2010,项目名称:javabase,代码行数:31,代码来源:CatController.java
示例2: aroundTransaction
import com.dianping.cat.message.Transaction; //导入依赖的package包/类
private Object aroundTransaction(String type, String name, ProceedingJoinPoint joinPoint) throws Throwable {
Object result = null;
Transaction transaction = null;
//不让cat异常导致业务异常
try {
transaction = Cat.getProducer().newTransaction(type, name);
} catch (Exception e) {
log.error("Cat.getProducer().newTransaction Error", e);
}
try {
log.info("大众点评cat拦截:type="+type+";name="+name);
result = joinPoint.proceed();
if (transaction != null) transaction.setStatus(Transaction.SUCCESS);
} catch (Throwable throwable) {
if (transaction != null) transaction.setStatus(throwable);
log.error("aroundTransaction exception", throwable);
throw throwable;
} finally {
if (transaction != null)
transaction.complete();
}
return result;
}
开发者ID:ggj2010,项目名称:javabase,代码行数:24,代码来源:CatAop.java
示例3: createConsumerCross
import com.dianping.cat.message.Transaction; //导入依赖的package包/类
/**
* 客户端处理方法
* @param url
* @param transaction
*/
private void createConsumerCross(URL url,Transaction transaction){
//供应者的名称 如:com.cmall.goods.rpc
Event crossAppEvent = Cat.newEvent(CatConstants.CONSUMER_CALL_APP,getProviderAppName(url));
//供应者ip
Event crossServerEvent = Cat.newEvent(CatConstants.CONSUMER_CALL_SERVER,url.getHost());
//供应者端口
Event crossPortEvent = Cat.newEvent(CatConstants.CONSUMER_CALL_PORT,url.getPort()+"");
crossAppEvent.setStatus(Event.SUCCESS);
crossServerEvent.setStatus(Event.SUCCESS);
crossPortEvent.setStatus(Event.SUCCESS);
completeEvent(crossAppEvent);
completeEvent(crossPortEvent);
completeEvent(crossServerEvent);
transaction.addChild(crossAppEvent);
transaction.addChild(crossPortEvent);
transaction.addChild(crossServerEvent);
}
开发者ID:xiaomin0322,项目名称:dubbo_plus,代码行数:23,代码来源:CatTransaction.java
示例4: createProviderCross
import com.dianping.cat.message.Transaction; //导入依赖的package包/类
/**
* 服务端处理方法
* @param url
* @param transaction
*/
private void createProviderCross(URL url,Transaction transaction){
//供应者名称
String consumerAppName = RpcContext.getContext().getAttachment(Constants.APPLICATION_KEY);
if(StringUtils.isEmpty(consumerAppName)){
consumerAppName= RpcContext.getContext().getRemoteHost()+":"+ RpcContext.getContext().getRemotePort();
}
//供应者名称
Event crossAppEvent = Cat.newEvent(CatConstants.PROVIDER_CALL_APP,consumerAppName);
//供应者地址
Event crossServerEvent = Cat.newEvent(CatConstants.PROVIDER_CALL_SERVER,url.getHost());
crossAppEvent.setStatus(Event.SUCCESS);
crossServerEvent.setStatus(Event.SUCCESS);
completeEvent(crossAppEvent);
completeEvent(crossServerEvent);
transaction.addChild(crossAppEvent);
transaction.addChild(crossServerEvent);
}
开发者ID:xiaomin0322,项目名称:dubbo_plus,代码行数:23,代码来源:CatTransaction.java
示例5: testMessageTree
import com.dianping.cat.message.Transaction; //导入依赖的package包/类
@Test
public void testMessageTree() {
for (int i = 0; i < 500; i++) {
Transaction t = Cat.newTransaction("URL", "/order/submitOrder");
MessageTree tree = (MessageTree) Cat.getManager().getThreadLocalMessageTree();
// 这里可以设置不同的域服务器,相当于app.properties那个配置文件
tree.setDomain("PayOrder");
Cat.logMetric("order", "quantity", 1, "channel", "channel" + i % 5);
Cat.logMetric("payment.pending", "amount", i, "channel", "channel" + i % 5);
Cat.logMetric("payment.success", "amount", i, "channel", "channel" + i % 5);
t.addData("channel=channel" + i % 5);
try {
Thread.sleep(300);
} catch (InterruptedException e) {
e.printStackTrace();
}
t.complete();
}
}
开发者ID:Percy0601,项目名称:training-cat,代码行数:22,代码来源:TrainingBussinessMessage.java
示例6: initGroupDataSource
import com.dianping.cat.message.Transaction; //导入依赖的package包/类
@Override
public void initGroupDataSource(GroupDataSource source, JdbcFilter chain) {
Transaction transaction = Cat.newTransaction(CAT_TYPE, "DataSource.Init-" + source.getJdbcRef());
try {
chain.initGroupDataSource(source, chain);
this.monitor = new GroupDataSourceMonitor(source);
StatusExtensionRegister.getInstance().register(this.monitor);
transaction.setStatus(Message.SUCCESS);
} catch (RuntimeException e) {
Cat.logError(e);
transaction.setStatus(e);
throw e;
} finally {
transaction.complete();
}
}
开发者ID:dianping,项目名称:zebra,代码行数:17,代码来源:CatFilter.java
示例7: switchFailOverDataSource
import com.dianping.cat.message.Transaction; //导入依赖的package包/类
@Override
public void switchFailOverDataSource(FailOverDataSource source, JdbcFilter chain) {
Transaction t = Cat.newTransaction(CAT_TYPE, "FailOver");
try {
chain.switchFailOverDataSource(source, chain);
Cat.logEvent("DAL.FailOver", "Success");
t.setStatus(Message.SUCCESS);
} catch (RuntimeException exp) {
Cat.logEvent("DAL.FailOver", "Failed");
Cat.logError(exp);
t.setStatus("Fail to find any master database");
throw exp;
} finally {
t.complete();
}
}
开发者ID:dianping,项目名称:zebra,代码行数:17,代码来源:CatFilter.java
示例8: testCat
import com.dianping.cat.message.Transaction; //导入依赖的package包/类
@Test
public void testCat() throws IOException {
Transaction t1 = Cat.newTransaction("type1", "name1");
Transaction t21 = Cat.newTransaction("type21", "name2");
Transaction t31 = Cat.newTransaction("type31", "name3");
t31.setStatus(Transaction.SUCCESS);
t31.complete();
t21.setStatus(Transaction.SUCCESS);
t21.complete();
Transaction t22 = Cat.newTransaction("type22", "name2");
t22.setStatus(Transaction.SUCCESS);
t22.complete();
t1.setStatus(Transaction.SUCCESS);
t1.complete();
waitForAnyKeyToExit();
}
开发者ID:ctripcorp,项目名称:x-pipe,代码行数:20,代码来源:SimpleTest.java
示例9: logTransactionSwallowException
import com.dianping.cat.message.Transaction; //导入依赖的package包/类
@Override
public <V> V logTransactionSwallowException(String type, String name, Callable<V> task) {
Transaction transaction = Cat.newTransaction(type, name);
try{
V result = task.call();
transaction.setStatus(Transaction.SUCCESS);
return result;
}catch(Throwable th){
transaction.setStatus(th);
logger.error("[logTransaction]" + type + "," + name + "," + task, th);
}finally{
transaction.complete();
}
return null;
}
开发者ID:ctripcorp,项目名称:x-pipe,代码行数:17,代码来源:CatTransactionMonitor.java
示例10: sendQueue
import com.dianping.cat.message.Transaction; //导入依赖的package包/类
private void sendQueue(QueueName queueName, RabbitMessage rm) throws Exception {
if (rm == null || queueName == null) {
return;
}
initQueueChannel();
String _queueName = queueName.getNameByEnvironment(environment);
Transaction trans = Cat.newTransaction("RabbitMQ Message", "PUBLISH-QUEUE-" + _queueName);
Cat.logEvent("mq send queue", _queueName, Event.SUCCESS,rm.toJsonStr());
try {
queueChannel.queueDeclare(_queueName, true, false, false, null);
queueChannel.basicPublish("", _queueName, MessageProperties.PERSISTENT_TEXT_PLAIN, rm.toJsonStr().getBytes("UTF-8"));
if (LOGGER.isInfoEnabled()) {
LOGGER.info("SEND SUCCESS:[queue:{},message:{}]", _queueName, rm.toJsonStr());
}
Cat.logMetricForCount("PUBLISH-QUEUE-" + _queueName); // 统计请求次数, 可以查看对应队列中放入了多少信息
trans.setStatus(Transaction.SUCCESS);
} catch (Exception e) {
if (LOGGER.isErrorEnabled()) {
LOGGER.error("SEND ERROR:[queue:{},message:{},exception:{}]", _queueName, rm.toJsonStr(), e);
}
String err = queueName + " rabbitmq发送消息异常";
Cat.logError(err, e);
trans.setStatus(e);
throw new AsuraRabbitMqException(err, e);
} finally {
trans.complete();
}
}
开发者ID:AsuraTeam,项目名称:asura,代码行数:29,代码来源:RabbitMqSendClient.java
示例11: sendTopic
import com.dianping.cat.message.Transaction; //导入依赖的package包/类
/**
* 发送消息-topic方式
*
* @param exchangeName 格式为:系统标示_模块标示_功能标示
* @param msg 具体消息
* @author zhangshaobin
* @created 2016年3月1日 下午4:40:59
*/
public void sendTopic(ExchangeName exchangeName, RoutingKey routingKey, PublishSubscribeType type, String msg) throws Exception {
initTopicChannel();
String _exchange = exchangeName.getNameByEnvironment(environment);
Transaction trans = Cat.newTransaction("RabbitMQ Message", "PUBLISH-TOPIC-" + _exchange);
RabbitMessage rm = new RabbitMessage();
rm.setData(msg);
rm.setType(_exchange);
try {
Cat.logEvent("mq send topic",exchangeName.getName(),Event.SUCCESS, rm.toJsonStr());
rm.setType(_exchange);
topicChannel.exchangeDeclare(_exchange, type.getName(), true);
topicChannel.basicPublish(_exchange, routingKey.getKey(), null, rm.toJsonStr().getBytes("UTF-8"));
if (LOGGER.isInfoEnabled()) {
LOGGER.info("SEND SUCCESS:[queue:{},message:{}]", _exchange, rm.toJsonStr());
}
Cat.logMetricForCount("PUBLISH-TOPIC-" + _exchange); // 统计请求次数, 可以查看对应队列中放入了多少信息
trans.setStatus(Transaction.SUCCESS);
} catch (Exception e) {
if (LOGGER.isErrorEnabled()) {
LOGGER.error("SEND ERROR:[queue:{},message:{},exception:{}]", _exchange, rm.toJsonStr(), e);
}
String err = exchangeName + " rabbitmq发送消息异常";
Cat.logError(err, e);
trans.setStatus(e);
throw new AsuraRabbitMqException(err, e);
} finally {
trans.complete();
}
}
开发者ID:AsuraTeam,项目名称:asura,代码行数:38,代码来源:RabbitMqSendClient.java
示例12: doBasicProfiling
import com.dianping.cat.message.Transaction; //导入依赖的package包/类
@Around("execution(* com..*.proxy..*.* (..))")
public Object doBasicProfiling(final ProceedingJoinPoint joinPoint) throws Throwable {
long start_all = System.currentTimeMillis();
long end_all = 0L;
String declaringTypeName = joinPoint.getSignature().getDeclaringTypeName();
String signatureName = joinPoint.getSignature().getName();
Object [] args = joinPoint.getArgs();
Transaction tran = Cat.newTransaction("Aspect-proxy", declaringTypeName + "." + signatureName);
if (RpcContext.getContext().getRemoteAddressString() != null && RpcContext.getContext().getMethodName() != null
&& RpcContext.getContext().getUrl() != null) {
MDC.put(HOST, RpcContext.getContext().getRemoteAddressString());
MDC.put(INTERFACE, RpcContext.getContext().getUrl().getServiceInterface());
MDC.put(METHOD, RpcContext.getContext().getMethodName());
} else {
MDC.put(HOST, "127.0.0.1");
MDC.put(INTERFACE, "none");
MDC.put(METHOD, "none");
}
final DataLogEntity de = new DataLogEntity();
de.setClassName(declaringTypeName);
de.setMethodName(signatureName);
de.setParams(args);
String logJson = de.toJsonStr();
// 参数日志
if (logger.isDebugEnabled()) {
logger.debug(de.toJsonStr());
}
try {
long start = System.currentTimeMillis();
final Object retVal = joinPoint.proceed();
long end = System.currentTimeMillis();
// 记录耗时
logger.info("{}, 耗时:{} ms, 进入aop到执行完耗时:{} ms", logJson, (end - start), (end - start_all));
Cat.logEvent(declaringTypeName, signatureName, "0", logJson+" 耗时:" + (end - start) + " ms" + " 时间戳:" + System.currentTimeMillis());
/**
* 设置消息的状态,必须设置,0:标识成功,其他标识发生了异常
*/
tran.setStatus(Transaction.SUCCESS);
end_all = System.currentTimeMillis();
return retVal;
} catch (final Exception e) {
final ErrorLogEntity ele = new ErrorLogEntity(de);
DataTransferObject dto = handleException(e, ele, tran);
end_all = System.currentTimeMillis();
// 方法返回值类型
Class returnType = null;
if (null != joinPoint.getSignature()) {
returnType = ((MethodSignature) joinPoint.getSignature()).getReturnType();
}
if (null != returnType && returnType.equals(String.class)){
return dto.toJsonString();
}else if (null != returnType && returnType.equals(DataTransferObject.class)){
return dto;
}else{
throw e;
}
} finally {
MDC.remove(HOST);
MDC.remove(INTERFACE);
MDC.remove(METHOD);
tran.complete();
logger.info("{}, 接入cat后整体耗时: {} ms", logJson, (end_all - start_all));
}
}
开发者ID:AsuraTeam,项目名称:asura,代码行数:66,代码来源:SystemLogger.java
示例13: handleErrorException
import com.dianping.cat.message.Transaction; //导入依赖的package包/类
/**
* 处理系统异常
* @param errorLogEntity
* @param e
* @param tran
* @return
*/
private DataTransferObject handleErrorException(ErrorLogEntity errorLogEntity,Exception e,Transaction tran){
errorLogEntity.setThrowMessage(e.getMessage());
//cat记录错误
Cat.logError(e);
tran.setStatus(e);
LogUtil.error(logger, " system error message:{}", errorLogEntity.toJsonStr(), e);
return getDTOFromException(DataTransferObject.SYS_ERROR, "服务错误");
}
开发者ID:AsuraTeam,项目名称:asura,代码行数:16,代码来源:SystemLogger.java
示例14: init
import com.dianping.cat.message.Transaction; //导入依赖的package包/类
/**
* 初始化zk连接
*
* @author zhangshaobin
* @created 2013-6-26 上午10:21:34
*/
private void init() {
applicationName = DynamicPropertyFactory.getInstance().getStringProperty(CommonConstant.CONFIG_APPLICATION_NAME_KEY, null).get();
String zkConfigEnsemble = DynamicPropertyFactory.getInstance().getStringProperty(CommonConstant.ZK_ENSEMABLE_KEY, null).get();
Integer zkConfigSessionTimeout = DynamicPropertyFactory.getInstance().getIntProperty(CommonConstant.ZK_SESSION_TIMEOUT_KEY, 15000).get();
Integer zkConfigConnTimeout = DynamicPropertyFactory.getInstance().getIntProperty(CommonConstant.ZK_CONN_TIMEOUT_KEY, 5000).get();
Transaction tran = Cat.newTransaction("Asura Configuration init", applicationName + "_" + zkConfigEnsemble);
try {
if (Check.NuNStr(zkConfigEnsemble)) {
logger.warn("ZooKeeper configuration running in file mode, zk is not enabled since not configured");
Cat.logError("zk is not enabled since not configured", new RuntimeException("ZooKeeper located at " + zkConfigEnsemble + " is not started."));
return;
}
client = createAndStartZKClient(zkConfigEnsemble, zkConfigSessionTimeout, zkConfigConnTimeout);
if (client.getState() != CuratorFrameworkState.STARTED) {
throw new RuntimeException("ZooKeeper located at " + zkConfigEnsemble + " is not started.");
}
tran.setStatus(Transaction.SUCCESS);
} catch (Exception e) {
logger.error("连接配置中心服务器超时,时间5000毫秒。", e);
Cat.logError("asura configuration init exception", e);
tran.setStatus(e);
System.exit(1);
} finally {
tran.complete();
}
logger.info(new SimpleDateFormat("[yyyy-MM-dd HH:mm:ss] ").format(new Date()) + applicationName + " connected to cofnig server(" + zkConfigEnsemble + ").");
logger.info(applicationName + " connected to cofnig server(" + zkConfigEnsemble + ").");
}
开发者ID:AsuraTeam,项目名称:asura,代码行数:41,代码来源:ConfigSubscriber.java
示例15: getConfigValue
import com.dianping.cat.message.Transaction; //导入依赖的package包/类
/**
* 从zookeeper上获取配置信息
*
* @param suffixPath
* 配置路径
*
* @return 配置信息值
*/
@Override
public String getConfigValue(final String suffixPath) {
final String path = pasePath(suffixPath);
String data = DynamicPropertyFactory.getInstance().getStringProperty(paseKey(path), null).get();
if (Check.NuNStr(data)) {
try {
if (isExistsNode(path)) {
data = (String) SerializableSerializer.deserialize(client.getData().forPath(path));
} else {
throw new RuntimeException("zk configuration can not find. key:" + path);
}
if (!Check.NuNStr(data)) {
((ConcurrentCompositeConfiguration) ConfigurationManager.getConfigInstance()).setOverrideProperty(paseKey(path), data);
} else {
throw new RuntimeException("zk configuration value is null. key:" + path);
}
} catch (Exception e) {
logger.error("can't get asura configuration by " + path, e);
Transaction tran = Cat.newTransaction("get Asura Configuration", path);
Cat.logError("can't get asura configuration by " + path, e);
tran.setStatus(e);
tran.complete();
}
}
return DynamicPropertyFactory.getInstance().getStringProperty(paseKey(path), null).get();
}
开发者ID:AsuraTeam,项目名称:asura,代码行数:35,代码来源:ConfigSubscriber.java
示例16: intercept
import com.dianping.cat.message.Transaction; //导入依赖的package包/类
@Override
public Object intercept(Invocation invocation) throws Throwable {
Object result = null;
Transaction transaction = null;
MappedStatement mappedStatement = (MappedStatement)invocation.getArgs()[0];
Object objects = (Object)invocation.getArgs()[1];
BoundSql boundSql = mappedStatement.getBoundSql(objects);
// 得到 类名-方法
String[] strArr = mappedStatement.getId().split("\\.");
String class_method = strArr[strArr.length - 2] + "." + strArr[strArr.length - 1];
String sql = getSql(mappedStatement.getConfiguration(), boundSql);
try {
transaction = Cat.getProducer().newTransaction("SQL", class_method);
result = invocation.proceed();
Cat.getProducer().logEvent("SQL.Method", mappedStatement.getSqlCommandType().name(), Message.SUCCESS, "");
// Cat.getProducer().logEvent("SQL.Database","" ,Message.SUCCESS,"");
Cat.getProducer().logEvent("SQL.Statement", sql.substring(0, sql.indexOf(" ")), Message.SUCCESS, sql);
transaction.setStatus(Message.SUCCESS);
} catch (InvocationTargetException | IllegalAccessException e) {
transaction.setStatus( ((InvocationTargetException)e).getTargetException().toString());
log.error( ((InvocationTargetException)e).getTargetException().toString());
Cat.getProducer().logError( ((InvocationTargetException)e).getTargetException().toString(), e);
throw e;
} finally {
// transaction.addData(boundSql.getSql().trim().replaceAll("\\n",""));
transaction.complete();
}
return result;
}
开发者ID:ggj2010,项目名称:javabase,代码行数:30,代码来源:MyBatisCatPlugin.java
示例17: aroundCache
import com.dianping.cat.message.Transaction; //导入依赖的package包/类
private Object aroundCache(CatMethodCache catMethodTransaction, ProceedingJoinPoint joinPoint) throws Throwable {
//注解有值的优先以注解的值
String type = catMethodTransaction.type();
String name = catMethodTransaction.name();
Object result = null;
Transaction transaction = null;
//不让cat异常导致业务异常
try {
transaction = Cat.getProducer().newTransaction(type, name);
} catch (Exception e) {
log.error("Cat.getProducer().newTransaction Error", e);
}
try {
log.info("大众点评cat拦截 CatMethodCache :type="+type+";name="+name);
result = joinPoint.proceed();
if (transaction != null) {
transaction.setStatus(Transaction.SUCCESS);
if(joinPoint.getArgs().length>0)
transaction.addData("key="+joinPoint.getArgs()[0]+";"+"value="+ JSONObject.toJSON(result==null?new Object():result).toString());
}
} catch (Throwable throwable) {
if (transaction != null) transaction.setStatus(throwable);
log.error("aroundTransaction exception", throwable);
throw throwable;
} finally {
if (transaction != null)
transaction.complete();
}
return result;
}
开发者ID:ggj2010,项目名称:javabase,代码行数:31,代码来源:CatAop.java
示例18: testBasicBussiness
import com.dianping.cat.message.Transaction; //导入依赖的package包/类
/**
* 测试一个最简单的示例
*/
@Test
public void testBasicBussiness() {
log.debug("测试最基本的事务");
for (int i = 0; i < 1000; i++) {
Transaction t = Cat.newTransaction("统计消息类型:URL/SQL/Bussiness。。。一级纬度", "具体消息分类,属于一个二级纬度:/index;Select * from ...");
// 增加事件记录
Cat.logEvent("RemoteLink", "sina", Event.SUCCESS, "http://sina.com.cn/");
// 增加记录变量
t.addData("channel=channel" + i % 5);
Cat.logMetricForCount("Receipt Verify Success");
Cat.logMetricForCount("Receipt Verify Success 2", 2);
Cat.logMetricForDuration("Receipt Verify Druation", 10);
Cat.logMetricForSum("sum Value", 20);
Cat.logMetricForSum("sum Value2", 20, 2);
try {
Thread.sleep(500);
} catch (InterruptedException e) {
e.printStackTrace();
}
t.complete();
}
}
开发者ID:Percy0601,项目名称:training-cat,代码行数:30,代码来源:TrainingBussinessMessage.java
示例19: findAll
import com.dianping.cat.message.Transaction; //导入依赖的package包/类
@Override
public List<User> findAll() {
String rootMessageId = RpcContext.getContext().getAttachment(CatConstants.PIGEON_ROOT_MESSAGE_ID);
String currentMessageId = RpcContext.getContext().getAttachment(CatConstants.PIGEON_CURRENT_MESSAGE_ID);
String serverMessageId = RpcContext.getContext().getAttachment(CatConstants.PIGEON_SERVER_MESSAGE_ID);
Transaction t = Cat.newTransaction("RemoteCall", "findAll");
MessageTree tree = Cat.getManager().getThreadLocalMessageTree();
if (null == tree) {
Cat.setup(null);
tree = Cat.getManager().getThreadLocalMessageTree();
}
tree.setRootMessageId(rootMessageId);
tree.setParentMessageId(serverMessageId);
tree.setMessageId(currentMessageId);
List<User> users = new ArrayList<User>();
int i = 0;
while (i ++ < 10) {
User u = new User();
u.setId(i);
u.setName("Percy00" + i);
users.add(u);
}
Cat.logEvent("Call", "Params", Event.SUCCESS, "parentId:" + serverMessageId + "|msgId:" + currentMessageId + "End...");
t.setStatus(Transaction.SUCCESS);
t.complete();
return users;
}
开发者ID:Percy0601,项目名称:training-cat,代码行数:33,代码来源:UserServiceImpl.java
示例20: main
import com.dianping.cat.message.Transaction; //导入依赖的package包/类
public static void main(String[] args) {
SpringApplication.run(ApplicationBootstrap.class, args);
for (int i = 0; i < 1000; i++) {
Transaction t = Cat.newTransaction(
"统计消息类型:URL/SQL/Bussiness。。。一级纬度",
"具体消息分类,属于一个二级纬度:/index;Select * from ...");
// 增加事件记录
Cat.logEvent("RemoteLink", "sina", Event.SUCCESS,
"http://sina.com.cn/");
// 增加记录变量
t.addData("channel=channel" + i % 5);
Cat.logMetricForCount("Receipt Verify Success");
Cat.logMetricForCount("Receipt Verify Success 2", 2);
Cat.logMetricForDuration("Receipt Verify Druation", 10);
Cat.logMetricForSum("sum Value", 20);
Cat.logMetricForSum("sum Value2", 20, 2);
try {
Thread.sleep(500);
} catch (InterruptedException e) {
e.printStackTrace();
}
t.complete();
// try {
// System.in.read();
// } catch (IOException e) {
// e.printStackTrace();
// }
}
}
开发者ID:Percy0601,项目名称:training-cat,代码行数:37,代码来源:ApplicationBootstrap.java
注:本文中的com.dianping.cat.message.Transaction类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论