轻量级java调用流程追踪日志框架-trace4j
来源:互联网 发布:最新拍摄软件 编辑:程序博客网 时间:2024/06/03 23:07
项目介绍
本项目为了解决中小型企业级java项目调用流程的性能追踪问题,提供便捷快速的调用流程追踪日志记录,同时可以记录每个调用函数的耗时
固然目前有比如Zipkin,Drapper这些分布式追踪系统,能够全面的追踪分布式系统的调用链路,但是对于中小型的企业项目搭建及维护成本过高。
地址:https://github.com/husthuke/trace4j
Qucik Start
在使需要开启追踪日志的项目中引用trace4j-core工程。
<dependency> <groupId>com.hooke</groupId> <artifactId>trace4j-core</artifactId> <version>1.0-SNAPSHOT</version> </dependency>
为需要进行日志追踪的方法增加如下注解
@Trace(processName = "test",startStep = true) public void doSomeThing1(){ System.out.println("doSomeThing1"); }
结合spring aspect机制定义业务aop
<!--Aspect的方式实现trace监测--> <bean id="traceAspect" class="com.hooke.trace.aop.spring.TraceAspect"> </bean> <aop:config> <aop:pointcut id="tracePointcutAspect" expression="execution(* com.hooke.biz..*(..))"/> <aop:aspect id="traceSpringAspect" ref="traceAspect"> <aop:around pointcut-ref="tracePointcutAspect" method="trace"/> </aop:aspect> </aop:config>
追踪日志格式
"threadId:" + 调用线程ID + " triceId:" + 追踪ID + " sessionId:" + 会话ID + " ProcessName:" + 追踪流程名称 + " ProcessStep:" + 追踪路程步骤 + " Joinpoint:" + aop连接点信息 + " argsJson:" + 方法入参信息 + " returnJson:" + 方法返回信息 + " cost:"+ 调用耗时 + " ms!"
运行结果示例:
1579 [main] INFO c.h.trace.aop.spring.TraceAspect - threadId:1 triceId:887c67ff-7681-4fea-8e9f-e7d3838766f9 sessionId:null ProcessName:test ProcessStep:1. Joinpoint:execution(void com.hooke.biz.TraceTest.doSomeThing1()) argsJson: returnJson: cost:882 ms!1589 [main] INFO c.h.trace.aop.spring.TraceAspect - threadId:1 triceId:887c67ff-7681-4fea-8e9f-e7d3838766f9 sessionId:null ProcessName:test ProcessStep:2. Joinpoint:execution(void com.hooke.biz.TraceTest.doSomeThing1()) argsJson: returnJson: cost:0 ms!1590 [main] INFO c.h.trace.aop.spring.TraceAspect - threadId:1 triceId:887c67ff-7681-4fea-8e9f-e7d3838766f9 sessionId:null ProcessName:test ProcessStep:3. Joinpoint:execution(void com.hooke.biz.TraceTest.doSomeThing2()) argsJson: returnJson: cost:1 ms!1603 [main] INFO c.h.trace.aop.spring.TraceAspect - threadId:1 triceId:887c67ff-7681-4fea-8e9f-e7d3838766f9 sessionId:null ProcessName:test ProcessStep:4. Joinpoint:execution(int com.hooke.biz.TraceTest.doSomeThing3(String)) argsJson:"testmethod3" returnJson:0 cost:13 ms!1764 [Thread-3] INFO c.h.trace.aop.spring.TraceAspect - threadId:14 triceId:887c67ff-7681-4fea-8e9f-e7d3838766f9 sessionId:null ProcessName:test ProcessStep:4.2. Joinpoint:execution(void com.hooke.biz.TraceTest.doSomeThing2()) argsJson: returnJson: cost:1 ms!1764 [Thread-1] INFO c.h.trace.aop.spring.TraceAspect - threadId:12 triceId:887c67ff-7681-4fea-8e9f-e7d3838766f9 sessionId:null ProcessName:test ProcessStep:4.3. Joinpoint:execution(void com.hooke.biz.TraceTest.doSomeThing2()) argsJson: returnJson: cost:15 ms!1764 [Thread-2] INFO c.h.trace.aop.spring.TraceAspect - threadId:13 triceId:887c67ff-7681-4fea-8e9f-e7d3838766f9 sessionId:null ProcessName:test ProcessStep:4.1. Joinpoint:execution(void com.hooke.biz.TraceTest.doSomeThing2()) argsJson: returnJson: cost:15 ms!1866 [Thread-4] INFO c.h.trace.aop.spring.TraceAspect - threadId:15 triceId:887c67ff-7681-4fea-8e9f-e7d3838766f9 sessionId:null ProcessName:test ProcessStep:4.4. Joinpoint:execution(void com.hooke.biz.TraceTest.doSomeThing2()) argsJson: returnJson: cost:0 ms!1964 [Thread-5] INFO c.h.trace.aop.spring.TraceAspect - threadId:16 triceId:887c67ff-7681-4fea-8e9f-e7d3838766f9 sessionId:null ProcessName:test ProcessStep:4.5. Joinpoint:execution(void com.hooke.biz.TraceTest.doSomeThing2()) argsJson: returnJson: cost:0 ms!2066 [Thread-6] INFO c.h.trace.aop.spring.TraceAspect - threadId:17 triceId:887c67ff-7681-4fea-8e9f-e7d3838766f9 sessionId:null ProcessName:test ProcessStep:4.6. Joinpoint:execution(void com.hooke.biz.TraceTest.doSomeThing2()) argsJson: returnJson: cost:0 ms!2177 [Thread-7] INFO c.h.trace.aop.spring.TraceAspect - threadId:18 triceId:887c67ff-7681-4fea-8e9f-e7d3838766f9 sessionId:null ProcessName:test ProcessStep:4.7. Joinpoint:execution(void com.hooke.biz.TraceTest.doSomeThing2()) argsJson: returnJson: cost:1 ms!2275 [Thread-8] INFO c.h.trace.aop.spring.TraceAspect - threadId:19 triceId:887c67ff-7681-4fea-8e9f-e7d3838766f9 sessionId:null ProcessName:test ProcessStep:4.8. Joinpoint:execution(void com.hooke.biz.TraceTest.doSomeThing2()) argsJson: returnJson: cost:0 ms!2403 [Thread-9] INFO c.h.trace.aop.spring.TraceAspect - threadId:20 triceId:887c67ff-7681-4fea-8e9f-e7d3838766f9 sessionId:null ProcessName:test ProcessStep:4.9. Joinpoint:execution(void com.hooke.biz.TraceTest.doSomeThing2()) argsJson: returnJson: cost:0 ms!2492 [Thread-10] INFO c.h.trace.aop.spring.TraceAspect - threadId:21 triceId:887c67ff-7681-4fea-8e9f-e7d3838766f9 sessionId:null ProcessName:test ProcessStep:4.10. Joinpoint:execution(void com.hooke.biz.TraceTest.doSomeThing2()) argsJson: returnJson: cost:0 ms!2591 [Thread-11] INFO c.h.trace.aop.spring.TraceAspect - threadId:22 triceId:887c67ff-7681-4fea-8e9f-e7d3838766f9 sessionId:null ProcessName:test ProcessStep:4.11. Joinpoint:execution(void com.hooke.biz.TraceTest.doSomeThing2()) argsJson: returnJson: cost:0 ms!2700 [Thread-12] INFO c.h.trace.aop.spring.TraceAspect - threadId:23 triceId:887c67ff-7681-4fea-8e9f-e7d3838766f9 sessionId:null ProcessName:test ProcessStep:4.12. Joinpoint:execution(void com.hooke.biz.TraceTest.doSomeThing2()) argsJson: returnJson: cost:0 ms!2800 [main] INFO c.h.trace.aop.spring.TraceAspect - threadId:1 triceId:887c67ff-7681-4fea-8e9f-e7d3838766f9 sessionId:null ProcessName:test ProcessStep:5. Joinpoint:execution(void com.hooke.biz.TraceTest.doSomeThing2()) argsJson: returnJson: cost:0 ms!
阅读全文
0 0
- 轻量级java调用流程追踪日志框架-trace4j
- 追踪系统调用流程
- java 追踪方法调用
- Java轻量级框架选择
- 轻量级Java框架
- JAVA:轻量级框架Spring
- Java EE轻量级框架Spring
- jSimpleWeb轻量级java mvc框架
- java轻量级IOC框架Guice
- java轻量级IOC框架Guice
- Java轻量级框架SSH简介
- java轻量级IOC框架Guice
- Hessian轻量级二进制远程调用框架
- Hessian轻量级二进制远程调用框架
- Android Hessian轻量级二进制远程调用框架
- 轻量级分布式 RPC 框架 远程调用
- struts2框架调用流程
- 如何追踪 不熟悉的 代码 调用流程 深度
- bootstrap表格添加按钮、模态框实现
- svn出现 “previous operattion has not finished,run clean up if it is was interrupted”解决方法
- 字符串逆序
- 【HDU 1257 最少拦截系统】+ dp
- linux运维第一天: 计算机基础
- 轻量级java调用流程追踪日志框架-trace4j
- java注解使用
- 5.JVM的七个收集器
- ResultSetMetaData获取数据库表字段
- 第一次用博客。
- 在页面显示监控视频
- ModelMap和ModelAndView的作用
- ojdbc操作oracle时间类型字段的处理
- JS获取某月首尾日,获取某天某周的首位日