summaryrefslogtreecommitdiff
path: root/kafka/metrics/stats/count.py
blob: 183e4f25cfe443bf73dc55286207bfeb308ffec6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
from kafka.metrics.stats.sampled_stat import AbstractSampledStat


class Count(AbstractSampledStat):
    """
    An AbstractSampledStat that maintains a simple count of what it has seen.
    """
    def __init__(self):
        super(Count, self).__init__(0.0)

    def update(self, sample, config, value, now):
        sample.value += 1.0

    def combine(self, samples, config, now):
        return float(sum(sample.value for sample in samples))