关于监控:在运行时检测 java 类以监控性能 –> 有没有工具已经这样做了? | 珊瑚贝

Instrument java classes at runtime to monitor performance –> is there a tool that already does this?


我一直在研究各种 java 性能监控工具。

我制定了一个使用 perf4j aspectj 的解决方案,这样我就可以使用 aspectj 切入点表达式定义要监视的类。然而 aspectj 也(AFAIK),不允许您在运行时更改切入点表达式。因此,如果我需要监视新类,我将不得不更改 aop.xml 并重新编译(或者如果使用 AspectJ 加载时间编织,则至少重新启动应用程序)。

到目前为止,我还没有发现任何可以在运行时检测类而无需重新启动应用程序的东西。有没有可以做到这一点的工具/技术?

  • 有趣的问题,如果您不介意可以添加一个需要为类检测的场景吗?我想不出一个。
  • 有可能妨碍您的一般障碍(请参阅此问题卸载已加载的类)。


这些类型的工具通常不会在运行时检测类。相反,他们使用 JVMTI 接口(如果你不明白这是什么,请用谷歌搜索)。

使用它的主要产品示例:

Yourkit,JProfiler

有一些开源工具,但我还没有真正发现它们中的任何一个都像商业同行一样完美。

  • JRat (jrat.sourceforge.net) 是一个著名的开源分析器。查看源代码应该没问题。
  • visualvm 在功能上有些欠缺。它几乎没有 jprofiler 或 yourkit 之类的功能,尽管在某些情况下它可能非常有用。


找到了一个完美的小型库 BTrace,它正是我所需要的。它通过在运行时操作检测类的字节码来工作,无需重新启动应用程序。查看用户指南,了解设置它的难易程度。

关于 Btrace 的另一点值得一提的是,作者为使其在生产环境中工作的安全性付出了很多努力。

To guarantee that the tracing actions are”read-only” (i.e., the trace actions don’t change the state of the program traced) and bounded (i.e., trace actions terminate in bounded time), a BTrace program is allowed to do only a restricted set of actions.


正如 Matt 所说,YouKit Java Profiler 可以检测 Java 字节码。 YourKit 允许编写自己的探针并将它们插入到正在运行的 Java 应用程序中。 Probe API 允许访问方法参数、返回值、捕获异常等。

文档在这里:
http://www.yourkit.com/docs/11/help/probes.jsp

  • 两件事 1/ 我不喜欢在生产环境中运行分析器的想法。 2/ 它不是免费的。
  • 根据常见问题解答,请务必在回复中披露您与您推荐的产品的从属关系。


我建议使用 Eclipse(或 NetBeans)的调试器/分析器。
它非常强大。

还有一个专门用于这些工具的完整项目:
http://www.eclipse.org/projects/project.php?id=tptp.performance

还有一些有趣的插件:
http://code.google.com/a/eclipselabs.org/p/jvmmonitor/


来源:https://www.codenong.com/11780179/

微信公众号
手机浏览(小程序)

Warning: get_headers(): SSL operation failed with code 1. OpenSSL Error messages: error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed in /mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line 57

Warning: get_headers(): Failed to enable crypto in /mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line 57

Warning: get_headers(https://static.shanhubei.com/qrcode/qrcode_viewid_9027.jpg): failed to open stream: operation failed in /mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line 57
0
分享到:
没有账号? 忘记密码?