def _store_labels(self, metric, scraper_config):
    if (metric.name not in scraper_config['label_joins']):
        return
    watched = scraper_config['_watched_labels']
    matching_labels = watched['sets'][metric.name]
    mapping_key = watched['keys'][metric.name]
    labels_to_get = scraper_config['label_joins'][metric.name]['labels_to_get']
    get_all = ('*' in labels_to_get)
    match_all = (mapping_key == '*')
    for sample in metric.samples:
        if (sample[self.SAMPLE_VALUE] != 1):
            continue
        sample_labels = sample[self.SAMPLE_LABELS]
        sample_labels_keys = sample_labels.keys()
        if (match_all or matching_labels.issubset(sample_labels_keys)):
            label_dict = dict()
            if get_all:
                for (label_name, label_value) in iteritems(sample_labels):
                    if (label_name in matching_labels):
                        continue
                    label_dict[label_name] = label_value
            else:
                for label_name in labels_to_get:
                    if (label_name in sample_labels):
                        label_dict[label_name] = sample_labels[label_name]
            if match_all:
                mapping_value = '*'
            else:
                mapping_value = ','.join([sample_labels[l] for l in matching_labels])
            scraper_config['_label_mapping'].setdefault(mapping_key, {}).setdefault(mapping_value, {}).update(label_dict)
def _store_labels(self, metric, scraper_config):
    if (metric.name not in scraper_config['label_joins']):
        return
    watched = scraper_config['_watched_labels']
    matching_labels = watched['sets'][metric.name]
    mapping_key = watched['keys'][metric.name]
    labels_to_get = scraper_config['label_joins'][metric.name]['labels_to_get']
    get_all = ('*' in labels_to_get)
    match_all = (mapping_key == '*')
    for sample in metric.samples:
        if (sample[self.SAMPLE_VALUE] != 1):
            continue
        sample_labels = sample[self.SAMPLE_LABELS]
        sample_labels_keys = sample_labels.keys()
        if (match_all or matching_labels.issubset(sample_labels_keys)):
            label_dict = dict()
            if get_all:
                for (label_name, label_value) in iteritems(sample_labels):
                    if (label_name in matching_labels):
                        continue
                    label_dict[label_name] = label_value
            else:
                for label_name in labels_to_get:
                    if (label_name in sample_labels):
                        label_dict[label_name] = sample_labels[label_name]
            if match_all:
                mapping_value = '*'
            else:
                mapping_value = ','.join([sample_labels[l] for l in matching_labels])
            scraper_config['_label_mapping'].setdefault(mapping_key, {}).setdefault(mapping_value, {}).update(label_dict)