示例#1
0
    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()
示例#2
0
    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)
示例#3
0
    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())
示例#4
0
 def _flush(self):
     log.cache("flushing the accessor")
     if self._accessor:
         self.accessor.flush()