如何从 Codahale 指标计时器中获取最后经过的时间?

How do I get the last elapsed time from Codahale metrics timers?

我在我的 Scala 应用程序中使用 Codahale 指标,但似乎没有找到获取定时操作的最后一个值的方法。我可以得到均值、中位数和百分位数 - 所有来自直方图的好东西 - 但我只想知道上次操作花了多长时间!

查看快照中的条目零并将其从以纳秒为单位的值缩小到毫秒?好像不太对...

我一定是漏掉了明显的东西!

    t.time {

      iService.availCheck(q)

    } match {

      case ReturnInfo(Some(true)) =>

        // The HUB says TRUE, this name is available. That's gold.

        logger.debug("Avail check for (" + q + ") HUB TRUE: " + (t.snapshot.getValues()(0) / 100000.0).toString + "ms")

        Ok(Some(true))
    }

找到答案 - 嵌入在 t.time 调用中的 stop() 函数,returns 已用时间。我只需要重构我的代码就可以访问它。如果不消耗,它就会丢失。噗。

去计算 ;)