def _read_metadata(metric_name, path): info = whisper.info(path) if not info: return None retentions = bg_accessor.Retention([ bg_accessor.Stage(precision=a["secondsPerPoint"], points=a["points"]) for a in info["archives"] ]) aggregator = bg_accessor.Aggregator.from_carbon_name( info["aggregationMethod"]) return bg_accessor.MetricMetadata( aggregator=aggregator, retention=retentions, carbon_xfilesfactor=info["xFilesFactor"], )
def test_create_async(self): metric_name = "a.b.c" metric = self.make_metric(metric_name) self._plugin._createAsyncOrig(metric) self.assertFalse(self._plugin.exists(metric_name)) self._plugin._createOneMetric() self.assertTrue(self._plugin.exists(metric_name)) # See if we can update. metric = self.make_metric(metric_name) metric.metadata.retention = bg_accessor.Retention( [bg_accessor.Stage(1, 1)]) self._plugin._createAsyncOrig(metric) self._plugin._createOneMetric() retention = self._plugin.getMetadata(metric_name, "retention") self.assertEquals(retention, metric.metadata.retention)