(self, metric_name, metric, scraper_config, hostname=None)
For each sample in the metric, report it as a gauge with all labels as tags
        except if a labels `dict` is passed, in which case keys are label names we'll extract
        and corresponding values are tag names we'll use (eg: {'node': 'node'}).

        Histograms generate a set of values instead of a unique metric.
        `send_histograms_buckets` is used to specify if you want to
        send the buckets as tagged values when dealing with histograms.

        `custom_tags` is an array of `tag:value` that will be added to the
        metric when sending the gauge to Datadog.
For each sample in the metric, report it as a gauge with all labels as tags
        except if a labels `dict` is passed, in which case keys are label names we'll extract
        and corresponding values are tag names we'll use (eg: {'node': 'node'}).
For each sample in the metric report it as a gauge with all labels as tags except if a labels dict is passed in which case keys are label names we ll extract and corresponding values are tag names we ll use ( eg : { node : node } ) .
def submit_openmetric(self, metric_name, metric, scraper_config, hostname=None):
        """
        For each sample in the metric, report it as a gauge with all labels as tags
        except if a labels `dict` is passed, in which case keys are label names we'll extract
        and corresponding values are tag names we'll use (eg: {'node': 'node'}).

        Histograms generate a set of values instead of a unique metric.
        `send_histograms_buckets` is used to specify if you want to
        send the buckets as tagged values when dealing with histograms.

        `custom_tags` is an array of `tag:value` that will be added to the
        metric when sending the gauge to Datadog.
        """
        if metric.type in ["gauge", "counter", "rate"]:
            metric_name_with_namespace = self._metric_name_with_namespace(metric_name, scraper_config)
            for sample in metric.samples:
                if self._ignore_metrics_by_label(scraper_config, metric_name, sample):
                    continue

                val = sample[self.SAMPLE_VALUE]
                if not self._is_value_valid(val):
                    self.log.debug("Metric value is not supported for metric %s", sample[self.SAMPLE_NAME])
                    continue
                custom_hostname = self._get_hostname(hostname, sample, scraper_config)
                # Determine the tags to send
                tags = self._metric_tags(metric_name, val, sample, scraper_config, hostname=custom_hostname)
                if metric.type == "counter" and scraper_config['send_monotonic_counter']:
                    self.monotonic_count(
                        metric_name_with_namespace,
                        val,
                        tags=tags,
                        hostname=custom_hostname,
                        flush_first_value=scraper_config['_flush_first_value'],
                    )
                elif metric.type == "rate":
                    self.rate(metric_name_with_namespace, val, tags=tags, hostname=custom_hostname)
                else:
                    self.gauge(metric_name_with_namespace, val, tags=tags, hostname=custom_hostname)

                    # Metric is a "counter" but legacy behavior has "send_as_monotonic" defaulted to False
                    # Submit metric as monotonic_count with appended name
                    if metric.type == "counter" and scraper_config['send_monotonic_with_gauge']:
                        self.monotonic_count(
                            metric_name_with_namespace + '.total',
                            val,
                            tags=tags,
                            hostname=custom_hostname,
                            flush_first_value=scraper_config['_flush_first_value'],
                        )
        elif metric.type == "histogram":
            self._submit_gauges_from_histogram(metric_name, metric, scraper_config)
        elif metric.type == "summary":
            self._submit_gauges_from_summary(metric_name, metric, scraper_config)
        else:
            self.log.error("Metric type %s unsupported for metric %s.", metric.type, metric_name)
def submit_openmetric ( self , metric_name , metric , scraper_config , hostname = None ) : if metric . type in [ "gauge" , "counter" , "rate" ] : metric_name_with_namespace = self . _metric_name_with_namespace ( metric_name , scraper_config ) for sample in metric . samples : if self . _ignore_metrics_by_label ( scraper_config , metric_name , sample ) : continue val = sample [ self . SAMPLE_VALUE ] if not self . _is_value_valid ( val ) : self . log . debug ( "Metric value is not supported for metric %s" , sample [ self . SAMPLE_NAME ] ) continue custom_hostname = self . _get_hostname ( hostname , sample , scraper_config ) # Determine the tags to send tags = self . _metric_tags ( metric_name , val , sample , scraper_config , hostname = custom_hostname ) if metric . type == "counter" and scraper_config [ 'send_monotonic_counter' ] : self . monotonic_count ( metric_name_with_namespace , val , tags = tags , hostname = custom_hostname , flush_first_value = scraper_config [ '_flush_first_value' ] , ) elif metric . type == "rate" : self . rate ( metric_name_with_namespace , val , tags = tags , hostname = custom_hostname ) else : self . gauge ( metric_name_with_namespace , val , tags = tags , hostname = custom_hostname ) # Metric is a "counter" but legacy behavior has "send_as_monotonic" defaulted to False # Submit metric as monotonic_count with appended name if metric . type == "counter" and scraper_config [ 'send_monotonic_with_gauge' ] : self . monotonic_count ( metric_name_with_namespace + '.total' , val , tags = tags , hostname = custom_hostname , flush_first_value = scraper_config [ '_flush_first_value' ] , ) elif metric . type == "histogram" : self . _submit_gauges_from_histogram ( metric_name , metric , scraper_config ) elif metric . type == "summary" : self . _submit_gauges_from_summary ( metric_name , metric , scraper_config ) else : self . log . error ( "Metric type %s unsupported for metric %s." , metric . type , metric_name )