Exemple #1
0
 def __init__(self):
     """Create a new MemoryAccessor."""
     super(_MemoryAccessor, self).__init__("memory")
     self._metric_to_points = collections.defaultdict(
         sortedcontainers.SortedDict)
     self._name_to_metric = {}
     self._directory_names = sortedcontainers.SortedSet()
     self.__downsampler = _downsampling.Downsampler()
     self.__delayed_writer = _delayed_writer.DelayedWriter(self)
    def setUp(self):
        """Set up a Downsampler, aggregating with the sum and average function."""
        capacity_precisions = (self.CAPACITY, self.PRECISION, self.CAPACITY,
                               self.PRECISION**2)
        retention_string = "%d*%ds:%d*%ds" % (capacity_precisions)
        retention = bg_accessor.Retention.from_string(retention_string)
        self.stage_0 = retention.stages[0]
        self.stage_1 = retention.stages[1]
        uid = uuid.uuid4()
        metric_metadata = bg_accessor.MetricMetadata(
            aggregator=bg_accessor.Aggregator.total, retention=retention)
        self.metric_sum = bg_accessor.Metric(self.METRIC_NAME_SUM, uid,
                                             metric_metadata)

        uid = uuid.uuid4()
        metric_metadata = bg_accessor.MetricMetadata(
            aggregator=bg_accessor.Aggregator.average, retention=retention)
        self.metric_avg = bg_accessor.Metric(self.METRIC_NAME_AVG, uid,
                                             metric_metadata)
        self.ds = bg_ds.Downsampler(self.CAPACITY)