

def flush(self, ts, interval):
    if (not self.count):
        return []
    self.samples.sort()
    length = len(self.samples)
    min_ = self.samples[0]
    max_ = self.samples[(- 1)]
    med = self.samples[int(round(((length / 2) - 1)))]
    avg = (sum(self.samples) / float(length))
    aggregators = [('min', min_, MetricTypes.GAUGE), ('max', max_, MetricTypes.GAUGE), ('median', med, MetricTypes.GAUGE), ('avg', avg, MetricTypes.GAUGE), ('count', (self.count / value), MetricTypes.RATE)]
    metric_aggrs = [(agg_name, agg_func, m_type) for (agg_name, agg_func, m_type) in aggregators if (agg_name in self.aggregates)]
    metrics = [self.formatter(hostname=self.hostname, device_name=self.device_name, tags=self.tags, metric=('%s.%s' % (self.name, suffix)), value=value, timestamp=ts, metric_type=metric_type, interval=interval) for (suffix, value, metric_type) in metric_aggrs]
    for p in self.percentiles:
        val = self.samples[int(round(((p * length) - 1)))]
        name = ('%s.%spercentile' % (self.name, int((p * 100))))
        metrics.append(self.formatter(hostname=self.hostname, tags=self.tags, metric=name, value=val, timestamp=ts, metric_type=MetricTypes.GAUGE, interval=interval))
    self.samples = []
    self.count = 0
    return metrics

dataset/ETHPy150Open serverdensity/sd-agent/aggregator.py Histogram.flush/VarMisuse@157/186 `interval`->`value`