(self, metric)
Yield a sample of processed data.
Yield a sample of processed data.
Yield a sample of processed data .
def generate_sample_data(self, metric):
        """
        Yield a sample of processed data.
        """

        label_normalizer = get_label_normalizer(metric.type)

        for sample in metric.samples:
            value = sample.value
            if isnan(value) or isinf(value):
                self.log.debug('Ignoring sample for metric `%s` as it has an invalid value: %s', metric.name, value)
                continue

            tags = []
            skip_sample = False
            labels = sample.labels
            self.label_aggregator.populate(labels)
            label_normalizer(labels)

            for label_name, label_value in labels.items():
                sample_excluder = self.exclude_metrics_by_labels.get(label_name)
                if sample_excluder is not None and sample_excluder(label_value):
                    skip_sample = True
                    break
                elif label_name in self.exclude_labels:
                    continue
                elif self.include_labels and label_name not in self.include_labels:
                    continue

                label_name = self.rename_labels.get(label_name, label_name)
                tags.append(f'{label_name}:{label_value}')

            if skip_sample:
                continue

            tags.extend(self.tags)

            hostname = self.hostname
            if self.hostname_label and self.hostname_label in labels:
                hostname = labels[self.hostname_label]
                if self.hostname_formatter is not None:
                    hostname = self.hostname_formatter(hostname)

            self.submit_telemetry_number_of_processed_metric_samples()
            yield sample, tags, hostname
def generate_sample_data ( self , metric ) : label_normalizer = get_label_normalizer ( metric . type ) for sample in metric . samples : value = sample . value if isnan ( value ) or isinf ( value ) : self . log . debug ( 'Ignoring sample for metric `%s` as it has an invalid value: %s' , metric . name , value ) continue tags = [ ] skip_sample = False labels = sample . labels self . label_aggregator . populate ( labels ) label_normalizer ( labels ) for label_name , label_value in labels . items ( ) : sample_excluder = self . exclude_metrics_by_labels . get ( label_name ) if sample_excluder is not None and sample_excluder ( label_value ) : skip_sample = True break elif label_name in self . exclude_labels : continue elif self . include_labels and label_name not in self . include_labels : continue label_name = self . rename_labels . get ( label_name , label_name ) tags . append ( f'{label_name}:{label_value}' ) if skip_sample : continue tags . extend ( self . tags ) hostname = self . hostname if self . hostname_label and self . hostname_label in labels : hostname = labels [ self . hostname_label ] if self . hostname_formatter is not None : hostname = self . hostname_formatter ( hostname ) self . submit_telemetry_number_of_processed_metric_samples ( ) yield sample , tags , hostname