compound_stat.py 776 B

12345678910111213141516171819202122232425262728293031323334
  1. from __future__ import absolute_import
  2. import abc
  3. from kafka.metrics.stat import AbstractStat
  4. class AbstractCompoundStat(AbstractStat):
  5. """
  6. A compound stat is a stat where a single measurement and associated
  7. data structure feeds many metrics. This is the example for a
  8. histogram which has many associated percentiles.
  9. """
  10. __metaclass__ = abc.ABCMeta
  11. def stats(self):
  12. """
  13. Return list of NamedMeasurable
  14. """
  15. raise NotImplementedError
  16. class NamedMeasurable(object):
  17. def __init__(self, metric_name, measurable_stat):
  18. self._name = metric_name
  19. self._stat = measurable_stat
  20. @property
  21. def name(self):
  22. return self._name
  23. @property
  24. def stat(self):
  25. return self._stat