显示每个请求统计信息和程序流程的 Java 分析器
我正在寻找支持每个请求分析统计的分析器,最好是沿着程序流(而不是通常的线程调用堆栈)。因此,基本上每个请求都有一个探查器调用堆栈+顺序调用视图,如下所示:对
doGet 100ms
+ doFilter 95ms
+ doFilter2 90ms
+ validateValues 20ms
+ calculateX 40ms
+ calc1 10ms
+ calc2 30ms
+ renderResponse 30ms
哪些类/方法进行探查是以某种方式配置的,对于处理每个方法调用的跟踪探查器来说,这当然是不可用的。
我知道并使用过 dynaTrace,它的“PurePath”功能 (http ://www.dynatrace.com/en/architecture-tame-complexity-with-purepath.aspx)支持这一点,但我正在寻找可在较小项目中使用并且需要较少初始投资的工具并设置。
是否有任何“经典”分析器(YourKit 等)支持此功能,而我忽略了该功能?
附录: 提供一些背景信息:主要目标是获得用于生产系统监控和分析的统计数据。首先也是最重要的想法是获取请求需要多长时间的实时统计数据,以及在响应时间增加的情况下获取某些(类型)请求的数据(想想 JETM + x)。
每个请求分析统计数据可以详细分析为什么只有某些请求很慢,例如,如果 10% 的请求花费的时间是平均值的十倍。根据汇总统计数据,据我所知,这很难解决。
这同样适用于沿程序流呈现调用的分析统计信息,因为很容易识别请求中的问题所在,例如,一个方法执行十个数据库查询,您将每个调用视为单个调用,而不仅仅是十个调用聚合调用。
理想情况下,测量点在运行时配置和启用/禁用。
I'm looking for profilers that support per request profiling statistics, ideally along the programs flow (not the usual thread call stack). So basically a profiler call stack + sequential calls view for each single request, something like this:
doGet 100ms
+ doFilter 95ms
+ doFilter2 90ms
+ validateValues 20ms
+ calculateX 40ms
+ calc1 10ms
+ calc2 30ms
+ renderResponse 30ms
Which classes / methods are profiled is configured in some way, for a tracing profiler that processes each method call, this is of course not usable.
I know of and have used dynaTrace, its "PurePath" Feature (http://www.dynatrace.com/en/architecture-tame-complexity-with-purepath.aspx) supports this, but I'm looking for tools that are usable in smaller projects and require less of an initial investment and set up.
Does any "classical" profiler (YourKit, etc) support this and I have overlooked the feature?
Addendum:
To supply some background: The main goal is to have statistics for the monitoring and analysis of a system in production. First and foremost the idea is to get live statistics of how long requests take and in case response time goes up to have data for certain (types of) requests (think JETM + x).
Per request profiling statistics allows for a detailed analysis of why just some requests are slow, e.g. if 10% of the requests take ten times as long as your average. With aggregated statistics this is AFAIK very hard to solve.
The same goes for a profiling statistics that renders the calls along the program flow, because it is easy to identify where in the request the problem lies, e.g. a method performs ten DB queries, you see each call as a single one and not just ten aggregated calls.
Ideally the measurement points are configure and en/disabled at run time.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您可以尝试 btrace 进行选择性测量。它有点类似于 dtrace,如果您使用的是受支持的平台(Solaris、BSD、OS X),您也可以使用 dtrace。
You could try btrace to do selective measurements. It is somewhat similar to dtrace, which you could also use if you are on a supported platform, Solaris, BSD, OS X.
如果您的应用程序的计时时间为毫秒,您可以只拥有一个时间映射来暂存 TreeMap,您可以对其进行摘要并写入文件。这是最灵活的,适合毫秒计时。
对于微秒计时,我为每个阶段都有一个枚举值,然后在 ThreadLocal 数组中记录达到该阶段时的当前时间 (System.nanoTime())。 (无对象分配)请求完成后,将时间增量写入文件,例如 CSV 格式。
If your application is timing milli-seconds, you could just have a map of time to stage TreeMap which you can summaries and write to a file. This is the most flexible and is fine for milli-second timings.
For micro-second timings, I have an enum value for each stage and then record the current time (System.nanoTime()) when that staging is reached in a ThreadLocal array. (No object allocation) When the request is finished, write the timing deltas to a file e.g. CSV format.
我的方法与 Peter 的方法类似,但我没有使用线程局部变量和在线计算,而是在执行到达有趣的阶段时写入日志文件。另外,我使用 AspectJ 生成日志行,我发现它非常方便随意添加/删除日志行,而无需更改其余源代码。
My approach is similar to Peter's but instead of using threadlocals and computing online I write to the log file when the execution reaches interesting stages. Also, I used AspectJ to generate the log lines, which I found very convenient for adding/removing log lines at whim without having to change rest of source code.