How to use the c2cwsgiutils.stats.BACKENDS function in c2cwsgiutils

To help you get started, we’ve selected a few c2cwsgiutils examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github camptocamp / tilecloud-chain / tilecloud_chain / __init__.py View on Github external
def add_error_filters(self, queue_store=None, daemon=False):
        assert self.tilestream is not None

        self.imap(LogErrors(
            logger, logging.ERROR,
            "Error in tile: %(tilecoord)s, %(formated_metadata)s, %(error)r"
        ))

        if stats.BACKENDS:
            def add_stats(tile):
                if tile and tile.error:
                    stats.increment_counter(['error', tile.metadata.get('layer', 'None')])
                return tile
            self.imap(add_stats)

        if 'error_file' in self.config['generation']:

            def do(tile):
                if tile and tile.error:
                    self.log_tiles_error(tile=tile, message=repr(tile.error))
                return tile
            self.imap(do)
        if self.config['generation']['maxconsecutive_errors'] > 0 and not daemon:
            self.tilestream = map(MaximumConsecutiveErrors(
                self.config['generation']['maxconsecutive_errors']), self.tilestream)