def fetch(self, startTime, endTime): try: data = whisper.fetch(self.fs_path, startTime, endTime) except IOError: log.exception("Failed fetch of whisper file '%s'" % self.fs_path) return None if not data: return None time_info, values = data (start, end, step) = time_info meta_info = whisper.info(self.fs_path) aggregation_method = meta_info['aggregationMethod'] lowest_step = min( [i['secondsPerPoint'] for i in meta_info['archives']]) # Merge in data from carbon's cache cached_datapoints = [] try: cached_datapoints = CarbonLink().query(self.real_metric_path) except: log.exception("Failed CarbonLink query '%s'" % self.real_metric_path) cached_datapoints = [] if isinstance(cached_datapoints, dict): cached_datapoints = cached_datapoints.items() values = merge_with_cache(cached_datapoints, start, step, values, aggregation_method) return time_info, values
def merge_with_carbonlink(metric, start, step, values, aggregation_method=None, raw_step=None): """Get points from carbonlink and merge them with existing values.""" cached_datapoints = [] try: cached_datapoints = CarbonLink().query(metric) except BaseException: log.exception("Failed CarbonLink query '%s'" % metric) cached_datapoints = [] if isinstance(cached_datapoints, dict): cached_datapoints = list(cached_datapoints.items()) return merge_with_cache( cached_datapoints, start, step, values, func=aggregation_method, raw_step=raw_step)
def fetch(self, startTime, endTime): data = self.ceres_node.read(startTime, endTime) time_info = (data.startTime, data.endTime, data.timeStep) values = list(data.values) # Merge in data from carbon's cache try: cached_datapoints = CarbonLink().query(self.real_metric_path) except: log.exception("Failed CarbonLink query '%s'" % self.real_metric_path) cached_datapoints = [] values = merge_with_cache(cached_datapoints, data.startTime, data.timeStep, values) return time_info, values
def CarbonLink(): """Return a carbonlink instance.""" # Late import to avoid pulling out too many dependencies with # readers.py which is usually imported by plugins. from graphite.carbonlink import CarbonLink return CarbonLink()