def scrape_metrics(self, scraper_config):
    '\n        Poll the data from Prometheus and return the metrics as a generator.\n        '
    response = self.poll(scraper_config)
    if scraper_config['telemetry']:
        if ('content-length' in response.headers):
            content_len = int(response.headers['content-length'])
        else:
            content_len = len(response.content)
        self._send_telemetry_gauge(self.TELEMETRY_GAUGE_MESSAGE_SIZE, content_len, scraper_config)
    try:
        if (not scraper_config['label_joins']):
            scraper_config['_dry_run'] = False
        elif (not scraper_config['_watched_labels']):
            watched = scraper_config['_watched_labels']
            watched['sets'] = {}
            watched['keys'] = {}
            watched['singles'] = set()
            for (key, val) in iteritems(scraper_config['label_joins']):
                labels = []
                if ('labels_to_match' in val):
                    labels = val['labels_to_match']
                elif ('label_to_match' in val):
                    self.log.warning('`label_to_match` is being deprecated, please use `labels_to_match`')
                    if isinstance(val['label_to_match'], list):
                        labels = val['label_to_match']
                    else:
                        labels = [val['label_to_match']]
                if labels:
                    s = frozenset(labels)
                    watched['sets'][key] = s
                    watched['keys'][key] = ','.join(s)
                    if (len(labels) == 1):
                        watched['singles'].add(labels[0])
        for metric in self.parse_metric_family(response, scraper_config):
            (yield metric)
        scraper_config['_dry_run'] = False
        for (metric, mapping) in list(iteritems(scraper_config['_label_mapping'])):
            for key in list(mapping):
                if ((metric in scraper_config['_active_label_mapping']) and (key not in scraper_config['_active_label_mapping'][metric])):
                    del scraper_config['_label_mapping'][metric][key]
        scraper_config['_active_label_mapping'] = {}
    finally:
        response.close()
Poll the data from Prometheus and return the metrics as a generator.
def scrape_metrics(self, scraper_config):
    '\n        \n        '
    response = self.poll(scraper_config)
    if scraper_config['telemetry']:
        if ('content-length' in response.headers):
            content_len = int(response.headers['content-length'])
        else:
            content_len = len(response.content)
        self._send_telemetry_gauge(self.TELEMETRY_GAUGE_MESSAGE_SIZE, content_len, scraper_config)
    try:
        if (not scraper_config['label_joins']):
            scraper_config['_dry_run'] = False
        elif (not scraper_config['_watched_labels']):
            watched = scraper_config['_watched_labels']
            watched['sets'] = {}
            watched['keys'] = {}
            watched['singles'] = set()
            for (key, val) in iteritems(scraper_config['label_joins']):
                labels = []
                if ('labels_to_match' in val):
                    labels = val['labels_to_match']
                elif ('label_to_match' in val):
                    self.log.warning('`label_to_match` is being deprecated, please use `labels_to_match`')
                    if isinstance(val['label_to_match'], list):
                        labels = val['label_to_match']
                    else:
                        labels = [val['label_to_match']]
                if labels:
                    s = frozenset(labels)
                    watched['sets'][key] = s
                    watched['keys'][key] = ','.join(s)
                    if (len(labels) == 1):
                        watched['singles'].add(labels[0])
        for metric in self.parse_metric_family(response, scraper_config):
            (yield metric)
        scraper_config['_dry_run'] = False
        for (metric, mapping) in list(iteritems(scraper_config['_label_mapping'])):
            for key in list(mapping):
                if ((metric in scraper_config['_active_label_mapping']) and (key not in scraper_config['_active_label_mapping'][metric])):
                    del scraper_config['_label_mapping'][metric][key]
        scraper_config['_active_label_mapping'] = {}
    finally:
        response.close()