lib/tabs/tabs.rb in tabs-0.7.1 vs lib/tabs/tabs.rb in tabs-0.8.0
- old
+ new
@@ -57,11 +57,11 @@
raise UnknownMetricError.new("Unknown metric: #{key}") unless metric_exists?(key)
type = hget("metrics", key)
metric_klass(type).new(key)
end
- def counter_total(key, period=nil)
+ def counter_total(key)
raise UnknownMetricError.new("Unknown metric: #{key}") unless metric_exists?(key)
raise MetricTypeMismatchError.new("Only counter metrics can be incremented") unless metric_type(key) == "counter"
get_metric(key).total
end
@@ -82,14 +82,19 @@
def metric_exists?(key)
list_metrics.include? key
end
- def drop_metric(key)
+ def drop_metric!(key)
raise UnknownMetricError.new("Unknown metric: #{key}") unless metric_exists?(key)
metric = get_metric(key)
metric.drop!
hdel "metrics", key
+ end
+
+ def drop_all_metrics!
+ metrics = self.list_metrics
+ metrics.each { |key| self.drop_metric! key }
end
private
def metric_klass(type)