metrics_reporter.py 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. from __future__ import absolute_import
  2. import abc
  3. class AbstractMetricsReporter(object):
  4. """
  5. An abstract class to allow things to listen as new metrics
  6. are created so they can be reported.
  7. """
  8. __metaclass__ = abc.ABCMeta
  9. @abc.abstractmethod
  10. def init(self, metrics):
  11. """
  12. This is called when the reporter is first registered
  13. to initially register all existing metrics
  14. Arguments:
  15. metrics (list of KafkaMetric): All currently existing metrics
  16. """
  17. raise NotImplementedError
  18. @abc.abstractmethod
  19. def metric_change(self, metric):
  20. """
  21. This is called whenever a metric is updated or added
  22. Arguments:
  23. metric (KafkaMetric)
  24. """
  25. raise NotImplementedError
  26. @abc.abstractmethod
  27. def metric_removal(self, metric):
  28. """
  29. This is called whenever a metric is removed
  30. Arguments:
  31. metric (KafkaMetric)
  32. """
  33. raise NotImplementedError
  34. @abc.abstractmethod
  35. def configure(self, configs):
  36. """
  37. Configure this class with the given key-value pairs
  38. Arguments:
  39. configs (dict of {str, ?})
  40. """
  41. raise NotImplementedError
  42. @abc.abstractmethod
  43. def close(self):
  44. """Called when the metrics repository is closed."""
  45. raise NotImplementedError