监控多语言产品中的代码指标
我们有一个由 C++ 和 Java 部分组成的产品。 C++ 的东西是使用 make 构建的,而 java 项目由一些 ant 项目和一些 maven2 项目组成。
我正在寻找一种工具,可以帮助我随着时间的推移从构建系统中获取有用的指标。 我可能
* Total build time
* C++ project build time
* Java build time
* Number of compiler warnings
* Number of unit tests (run/passed/failed/errors). (Tests are written in cxxTest and JUnit)
* Acceptance test metrics (run/passed/failed/errors)
* Total number of files
* LOC (to keep the managers happy)
能想到很多其他指标,但你明白了。
获取一次性报告的这些指标非常简单。我真正需要的是一个简单的工具,可以让我随时间绘制这些指标。
一个非常有用的简单用例是编译器警告,因为我们可以看到警告数量随着时间的推移趋向于零。 (我们无法一次性解决所有问题,因为这是一个相当大的项目,而且我们没有时间采取大爆炸的方法)。它还将帮助我们在引入新警告时快速发现它们。
我见过这个问题 Monitoring codemetrics in Java over long time时期,但我正在寻找一些与语言无关的东西
所以,总结一下。我正在寻找能够随时间报告指标、易于扩展、具有基于网络的报告 GUI 并且最好便宜的东西。 (要求不高啊!)
编辑:为了明确起见,我们使用 CruiseControl 作为我们的 CI 服务器。我只是还没有找到一种简单的方法来向其输出添加指标或基于时间的指标。也许我错过了一些明显的东西。我似乎此页面有关添加自定义指标,但它有点笨拙为我。
理想情况下,我希望以简单的格式将指标写入文件,并让某些东西动态生成指标。理想情况下,我想将下面的输出变成一个简单的图表
Build Id | Build Time | Metric | Value
00000001 10:45 TestPassRate 95
00000001 10:45 BuildTime 300
00000001 10:45 C++BuildTime 200
00000001 10:45 JavaBuildTime 50
00000001 10:45 TestTime 50
00000002 11:45 ......
We've got a product that's made up of C++ and Java parts. The C++ stuff is build using make and the java projects are made up of some ant projects and some maven2 projects.
I'm looking for a tool that will help me get useful metrics out of the build system over time. examples include
* Total build time
* C++ project build time
* Java build time
* Number of compiler warnings
* Number of unit tests (run/passed/failed/errors). (Tests are written in cxxTest and JUnit)
* Acceptance test metrics (run/passed/failed/errors)
* Total number of files
* LOC (to keep the managers happy)
There's probably loads of other metrics I could think of, but you get the idea.
Getting these metrics for a once-off report is pretty simple. What I really need is a simple tool that will let me plot these metrics over time.
A simple use case where this would be pretty useful would be compiler warnings as we could see the number of warnings trending towards zero over time. (we can't fix them all at once as it's a pretty big project and we just don't have the time for a big-bang approach). It would also help us quickly spot new warnings as they're introduced.
I've seen this question Monitoring code metrics in Java over longer time period, but I'm looking for something a little more language agnostic
So, to sum up. I'm looking for something that reports metrics over time, that's easily extensible, has a web-based reporting gui and preferably cheap. (not asking for much huh!)
Edit: Just to be clear, we're using CruiseControl as our CI server. I just haven't seen an easy way to add metrics or time-based metrics to it's output. Maybe I'm missing something obvious. I've seem this page about adding custom metrics, but it's a little clunky for me.
Ideally I'd love to write out the metrics to a file in a simple format and have something generate the metrics dynamically. Ideally I'd like to turn something like the output below into a simple chart
Build Id | Build Time | Metric | Value
00000001 10:45 TestPassRate 95
00000001 10:45 BuildTime 300
00000001 10:45 C++BuildTime 200
00000001 10:45 JavaBuildTime 50
00000001 10:45 TestTime 50
00000002 11:45 ......
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
如果您使用 Java CruiseControl,您可以轻松获得您想要的指标。您可以使用 在日志文件中包含任意 .xml,然后引用任何报告 .jsp 页面中的值。这正是 PMD、checkstyle 和 Javadoc 错误的趋势图的制作方式。来自metrics.jsp:
您只需将其粘贴到metrics.jsp 中,将xpath 查询替换为指标的xpath 即可。
If you're using the Java CruiseControl you can get the kind of metrics you want easily. You can include arbitrary .xml in the log file with and then reference any of the values in the reporting .jsp pages. That's exactly how the trend chart for PMD, and checkstyle and Javadoc errors is done. From metrics.jsp:
You can just paste this into the metrics.jsp replace the xpath queries w/the xpath to your metrics and you're good to go.
您可能正在寻找 CI 服务器(持续集成)。这些服务器监视源存储库(CVS、Subversion 等)并构建所有已更改的项目以及所有相关项目。
在我们这里,我们使用 TeamCity 但还有更多 (维基百科上的列表)
[编辑] 大多数 CI 服务器在构建后显示某种报告(花费了多长时间,有多少测试运行等)。您需要做的就是在构建后触发一个程序,该程序会获取此信息并将其保存在数据库中。
您可以获取 CI 服务器的历史构建页面,但它们通常不会到达很远的地方,这就是为什么最好将数据保存在不同的位置。如果您正在寻找简单的收获方法,请尝试使用 Python 和 Beautiful Soup。否则,Java 和 HTTP 客户端 加上 jTidy 是正确的选择。
You're probably looking for a CI server (continuous integration). These servers watch a source repository (CVS, Subversion, whatever) and build all projects that have changed plus all dependent projects.
In our place, we use TeamCity but there are lots more (list on wikipedia)
[EDIT] Most CI servers show some kind of report after the build (how long it took, how many tests ran, etc). All you need to do is trigger a program after the build which fetches this info and saves it in a database.
You could harvest the historical build pages of the CI server but they usually don't reach very far back which is why it's better to save the data in a different place. If you're looking for something simple for the harvesting, try Python with Beautiful Soup. Otherwise, Java and HTTP Client plus jTidy is the way to go.
rrdtool 可能会提供您正在寻找的历史视图。您只需要让 CI 服务器在每次运行时将构建报告转储到正确的位置,rrdtool 就可以从那里获取它。
rrdtool might provide the kind of historical view you're looking for. You just need to get your CI server to dump a build report in the right place each time it runs, and rrdtool can take it from there.