def check(self, instance):
        url = instance['url']
        default_timeout = self.init_config.get('default_timeout', 5)
        timeout = float(instance.get('timeout', default_timeout))
        tags = instance.get('tags', [])
        service_check_tags = ['url:%s' % url]

        try:
            h = Http(timeout=timeout)
            resp, content = h.request(url, "GET")
        except (socket.timeout, socket.error, HttpLib2Error) as e:
            self.service_check(self.SERVICE_CHECK_NAME, AgentCheck.CRITICAL,
                               message="Unable to fetch Riak stats: %s" % str(e),
                               tags=service_check_tags)
            raise

        if resp.status != 200:
            self.service_check(self.SERVICE_CHECK_NAME, AgentCheck.CRITICAL,
                               tags=service_check_tags,
                               message="Unexpected status of %s when fetching Riak stats, "
                               "response: %s" % (resp.status, content))

        stats = json.loads(content)
        self.service_check(
            self.SERVICE_CHECK_NAME, AgentCheck.OK, tags=service_check_tags)

        [self.gauge("riak." + k, stats[k], tags=tags) for k in self.keys if k in stats]

        coord_redirs_total = stats["coord_redirs_total"]
        if self.prev_coord_redirs_total > -1:
            count = coord_redirs_total - self.prev_coord_redirs_total
            self.gauge('riak.coord_redirs', count)

        self.prev_coord_redirs_total = coord_redirs_total
dataset/ETHPy150Open serverdensity/sd-agent/checks.d/riak.py/Riak.check/original