def _background(self): # import here because else it will import cache.py too early from carbon import instrumentation log.cache("background operations") for metric in prometheus_client.REGISTRY.collect(): for name, labels, value in metric.samples: name = name if labels: name += "." + ".".join( ["%s.%s" % (k, v.replace('.', '_')) for k, v in sorted(labels.items())]) instrumentation.cache_record(name, value) if self._accessor: self.accessor.background()
def _background(self): # import here because else it will import cache.py too early from carbon import instrumentation log.cache("background operations") for metric in prometheus_client.REGISTRY.collect(): for sample in metric.samples: name = sample.name if sample.labels: name += "." + ".".join( [ "%s.%s" % (k, v.replace(".", "_")) for k, v in sorted(sample.labels.items()) ] ) instrumentation.cache_record(name, sample.value) if self._accessor: self.reactor.callInThread(self.accessor.background)
def _background(self): # import here because else it will import cache.py too early from carbon import instrumentation log.cache("background operations") for metric in prometheus_client.REGISTRY.collect(): for sample in metric.samples: name = sample.name if sample.labels: name += "." + ".".join([ "%s.%s" % (k, v.replace(".", "_")) for k, v in sorted(sample.labels.items()) ]) instrumentation.cache_record(name, sample.value) if self._accessor: self.reactor.callInThread(self.accessor.background) # check if metadata are enabled metadata_enabled = self.metadata_switch.enabled() self.metadata_switch.watch() if metadata_enabled != self.metadata_switch.enabled(): log.cache("Metadata enabled: %s" % self.metadata_switch.enabled())
def _flush(self): log.cache("flushing the accessor") if self._accessor: self.accessor.flush()