Skip to content

Commit

Permalink
Add clearCounter or clearing a specific counter.
Browse files Browse the repository at this point in the history
  • Loading branch information
Cory G Watson authored and Cory G Watson committed Sep 19, 2011
1 parent 45344f3 commit acd7257
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
Expand Up @@ -134,6 +134,10 @@ class StatsCollection extends StatsProvider with JsonSerializable {
counter
}

def clearCounter(name: String) = {
counterMap.remove(name);
}

protected def newCounter(name: String) = {
new Counter()
}
Expand Down
Expand Up @@ -74,6 +74,14 @@ object StatsCollectionSpec extends Specification {
collection.incr("widgets", -1)
collection.getCounters() mustEqual Map("widgets" -> 2)
}

"clearCounter" in {
collection.getCounter("smellyfeet")
collection.incr("smellyfeet", 1)
collection.getCounters() mustEqual Map("smellyfeet" -> 1)
collection.clearCounter("smellyfeet")
collection.getCounters() mustEqual Map()
}
}

"metrics" in {
Expand Down

0 comments on commit acd7257

Please sign in to comment.