count.py 487 B

1234567891011121314151617
  1. from __future__ import absolute_import
  2. from kafka.metrics.stats.sampled_stat import AbstractSampledStat
  3. class Count(AbstractSampledStat):
  4. """
  5. An AbstractSampledStat that maintains a simple count of what it has seen.
  6. """
  7. def __init__(self):
  8. super(Count, self).__init__(0.0)
  9. def update(self, sample, config, value, now):
  10. sample.value += 1.0
  11. def combine(self, samples, config, now):
  12. return float(sum(sample.value for sample in samples))