【发布时间】:2016-06-13 18:40:19
【问题描述】:
我正在尝试对我的一些 API 进行非常简单的性能测量,以确定它们需要多长时间。 我添加了一个测试资源:
private static final MetricRegistry metrics = new MetricRegistry();
private final Timer responses = metrics.timer("test_responses");
@GET
public void test() {
final Timer.Context context = responses.time();
try {
log.info("sleeping...");
Thread.sleep(10*1000);
} catch (InterruptedException e) {
} finally {
context.stop();//2
}
}
并将以下内容添加到我的主应用程序类中:
ConsoleReporter reporter = ConsoleReporter.forRegistry(metrics).convertRatesTo(TimeUnit.SECONDS).convertDurationsTo(TimeUnit.MILLISECONDS).build();
reporter.start(10, TimeUnit.SECONDS);
每十秒我看到一次:
2016 年 6 月 13 日上午 11:38:51 ==================================== =========================
6/13/16 上午 11:39:01 ==================================== =========================
但没有提供关于我创建的“test_responses”指标的信息。非常感谢任何帮助!
【问题讨论】:
-
你调用了你的测试方法吗?
标签: dropwizard graphite