Permalink
Browse files

allow an option to not reset ostrich metrics

  • Loading branch information...
1 parent 9ab7f42 commit acaf2214dfb62d97fc11c173062a1d970de39bda Kyle Maxwell committed Jun 7, 2011
@@ -180,6 +180,14 @@ class StatsCollection extends StatsProvider with JsonSerializable {
metrics
}
+ def getMetricsNoReset() = {
+ val metrics = new mutable.HashMap[String, Distribution]
+ for ((key, metric) <- metricMap.asScala) {
+ metrics += (key -> metric(false))
+ }
+ metrics
+ }
+
def getGauges() = {
val gauges = new mutable.HashMap[String, Double]
if (includeJvmStats) fillInJvmGauges(gauges)
@@ -164,6 +164,17 @@ object StatsCollectionSpec extends Specification {
Stats.getMetrics()("foobar").count mustEqual 3
}
+ "getMetricsNoResetIsCumulative" in {
+ Stats.addMetric("foobar", new Distribution(1, 0, 0, 0))
+ Stats.getMetrics()("foobar").count mustEqual 1
+ Stats.getMetrics()("foobar").count mustEqual 0
+
+ Stats.addMetric("foobar", new Distribution(1, 0, 0, 0))
+ Stats.getMetricsNoReset()("foobar").count mustEqual 1
+ Stats.getMetricsNoReset()("foobar").count mustEqual 1
+
+ }
+
"report text in sorted order" in {
Stats.addMetric("alpha", new Distribution(1, 0, 0, 0))
Stats.getMetrics()("alpha").toString mustEqual

2 comments on commit acaf221

+1

Contributor

what pull request is this a part of?

Please sign in to comment.