(self, message, **kwargs)
Handle a prometheus metric message according to the following flow:
            - search self.metrics_mapper for a prometheus.metric <--> datadog.metric mapping
            - call check method with the same name as the metric
            - log some info if none of the above worked

        `send_histograms_buckets` is used to specify if yes or no you want to send
        the buckets as tagged values when dealing with histograms.
Handle a prometheus metric message according to the following flow:
            - search self.metrics_mapper for a prometheus.metric <--> datadog.metric mapping
            - call check method with the same name as the metric
            - log some info if none of the above worked
Handle a prometheus metric message according to the following flow : - search self . metrics_mapper for a prometheus . metric < -- > datadog . metric mapping - call check method with the same name as the metric - log some info if none of the above worked
def process_metric(self, message, **kwargs):
        """
        Handle a prometheus metric message according to the following flow:
            - search self.metrics_mapper for a prometheus.metric <--> datadog.metric mapping
            - call check method with the same name as the metric
            - log some info if none of the above worked

        `send_histograms_buckets` is used to specify if yes or no you want to send
        the buckets as tagged values when dealing with histograms.
        """

        # If targeted metric, store labels
        self.store_labels(message)

        if message.name in self.ignore_metrics:
            return  # Ignore the metric

        # Filter metric to see if we can enrich with joined labels
        self.join_labels(message)

        send_histograms_buckets = kwargs.get('send_histograms_buckets', True)
        send_monotonic_counter = kwargs.get('send_monotonic_counter', False)
        custom_tags = kwargs.get('custom_tags')
        ignore_unmapped = kwargs.get('ignore_unmapped', False)

        try:
            if not self._dry_run:
                try:
                    self._submit(
                        self.metrics_mapper[message.name],
                        message,
                        send_histograms_buckets,
                        send_monotonic_counter,
                        custom_tags,
                    )
                except KeyError:
                    if not ignore_unmapped:
                        # call magic method (non-generic check)
                        handler = getattr(self, message.name)  # Lookup will throw AttributeError if not found
                        try:
                            handler(message, **kwargs)
                        except Exception as err:
                            self.log.warning("Error handling metric: %s - error: %s", message.name, err)
                    else:
                        # build the wildcard list if first pass
                        if self._metrics_wildcards is None:
                            self._metrics_wildcards = [x for x in self.metrics_mapper.keys() if '*' in x]
                        # try matching wildcard (generic check)
                        for wildcard in self._metrics_wildcards:
                            if fnmatchcase(message.name, wildcard):
                                self._submit(
                                    message.name, message, send_histograms_buckets, send_monotonic_counter, custom_tags
                                )

        except AttributeError as err:
            self.log.debug("Unable to handle metric: %s - error: %s", message.name, err)
def process_metric ( self , message , * * kwargs ) : # If targeted metric, store labels self . store_labels ( message ) if message . name in self . ignore_metrics : return # Ignore the metric # Filter metric to see if we can enrich with joined labels self . join_labels ( message ) send_histograms_buckets = kwargs . get ( 'send_histograms_buckets' , True ) send_monotonic_counter = kwargs . get ( 'send_monotonic_counter' , False ) custom_tags = kwargs . get ( 'custom_tags' ) ignore_unmapped = kwargs . get ( 'ignore_unmapped' , False ) try : if not self . _dry_run : try : self . _submit ( self . metrics_mapper [ message . name ] , message , send_histograms_buckets , send_monotonic_counter , custom_tags , ) except KeyError : if not ignore_unmapped : # call magic method (non-generic check) handler = getattr ( self , message . name ) # Lookup will throw AttributeError if not found try : handler ( message , * * kwargs ) except Exception as err : self . log . warning ( "Error handling metric: %s - error: %s" , message . name , err ) else : # build the wildcard list if first pass if self . _metrics_wildcards is None : self . _metrics_wildcards = [ x for x in self . metrics_mapper . keys ( ) if '*' in x ] # try matching wildcard (generic check) for wildcard in self . _metrics_wildcards : if fnmatchcase ( message . name , wildcard ) : self . _submit ( message . name , message , send_histograms_buckets , send_monotonic_counter , custom_tags ) except AttributeError as err : self . log . debug ( "Unable to handle metric: %s - error: %s" , message . name , err )