blob: b06d4d789ba456af66fbf6682ac22be13869d15a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
from __future__ import absolute_import
import abc
class AbstractMeasurable(object):
"""A measurable quantity that can be registered as a metric"""
@abc.abstractmethod
def measure(self, config, now):
"""
Measure this quantity and return the result
Arguments:
config (MetricConfig): The configuration for this metric
now (int): The POSIX time in milliseconds the measurement
is being taken
Returns:
The measured value
"""
raise NotImplementedError
class AnonMeasurable(AbstractMeasurable):
def __init__(self, measure_fn):
self._measure_fn = measure_fn
def measure(self, config, now):
return float(self._measure_fn(config, now))
|