(self, scraper_config, headers=None)
Returns a valid `requests.Response`, otherwise raise requests.HTTPError if the status code of the
        response isn't valid - see `response.raise_for_status()`

        The caller needs to close the requests.Response.

        Custom headers can be added to the default headers.
Returns a valid `requests.Response`, otherwise raise requests.HTTPError if the status code of the
        response isn't valid - see `response.raise_for_status()`
Returns a valid requests . Response otherwise raise requests . HTTPError if the status code of the response isn t valid - see response . raise_for_status ()
def poll(self, scraper_config, headers=None):
        """
        Returns a valid `requests.Response`, otherwise raise requests.HTTPError if the status code of the
        response isn't valid - see `response.raise_for_status()`

        The caller needs to close the requests.Response.

        Custom headers can be added to the default headers.
        """
        endpoint = scraper_config.get('prometheus_url')

        # Should we send a service check for when we make a request
        health_service_check = scraper_config['health_service_check']
        service_check_name = self._metric_name_with_namespace('prometheus.health', scraper_config)
        service_check_tags = ['endpoint:{}'.format(endpoint)]
        service_check_tags.extend(scraper_config['custom_tags'])

        try:
            response = self.send_request(endpoint, scraper_config, headers)
        except requests.exceptions.SSLError:
            self.log.error("Invalid SSL settings for requesting %s endpoint", endpoint)
            raise
        except IOError:
            if health_service_check:
                self.service_check(service_check_name, AgentCheck.CRITICAL, tags=service_check_tags)
            raise
        try:
            response.raise_for_status()
            if health_service_check:
                self.service_check(service_check_name, AgentCheck.OK, tags=service_check_tags)
            return response
        except requests.HTTPError:
            response.close()
            if health_service_check:
                self.service_check(service_check_name, AgentCheck.CRITICAL, tags=service_check_tags)
            raise
def poll ( self , scraper_config , headers = None ) : endpoint = scraper_config . get ( 'prometheus_url' ) # Should we send a service check for when we make a request health_service_check = scraper_config [ 'health_service_check' ] service_check_name = self . _metric_name_with_namespace ( 'prometheus.health' , scraper_config ) service_check_tags = [ 'endpoint:{}' . format ( endpoint ) ] service_check_tags . extend ( scraper_config [ 'custom_tags' ] ) try : response = self . send_request ( endpoint , scraper_config , headers ) except requests . exceptions . SSLError : self . log . error ( "Invalid SSL settings for requesting %s endpoint" , endpoint ) raise except IOError : if health_service_check : self . service_check ( service_check_name , AgentCheck . CRITICAL , tags = service_check_tags ) raise try : response . raise_for_status ( ) if health_service_check : self . service_check ( service_check_name , AgentCheck . OK , tags = service_check_tags ) return response except requests . HTTPError : response . close ( ) if health_service_check : self . service_check ( service_check_name , AgentCheck . CRITICAL , tags = service_check_tags ) raise