Create the concept of a cachecounter metric; generating two counters specific to caches

This commit is contained in:
Paul "LeoNerd" Evans 2015-03-04 15:47:23 +00:00
parent 7d72e44eb9
commit ce8b5769f7
3 changed files with 73 additions and 8 deletions

View file

@ -13,7 +13,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
from .metric import CounterMetric
from .metric import CounterMetric, CacheCounterMetric
# We'll keep all the available metrics in a single toplevel dict, one shared
@ -43,6 +43,15 @@ class Metrics(object):
return metric
def register_cachecounter(self, name, *args, **kwargs):
full_name = "%s.%s" % (self.name_prefix, name)
metric = CacheCounterMetric(full_name, *args, **kwargs)
self._register(metric)
return metric
def counted(self, func):
""" A method decorator that registers a counter, to count invocations
of this method. """