(self, name, metric, custom_tags=None, hostname=None)
Extracts metrics from a prometheus summary metric and sends them as gauges
Extracts metrics from a prometheus summary metric and sends them as gauges
Extracts metrics from a prometheus summary metric and sends them as gauges
def _submit_gauges_from_summary(self, name, metric, custom_tags=None, hostname=None):
        """
        Extracts metrics from a prometheus summary metric and sends them as gauges
        """
        if custom_tags is None:
            custom_tags = []
        # summaries do not have a value attribute
        val = getattr(metric, self.METRIC_TYPES[2]).sample_count
        if self._is_value_valid(val):
            self._submit_gauge("{}.count".format(name), val, metric, custom_tags)
        else:
            self.log.debug("Metric value is not supported for metric %s.count.", name)
        val = getattr(metric, self.METRIC_TYPES[2]).sample_sum
        if self._is_value_valid(val):
            self._submit_gauge("{}.sum".format(name), val, metric, custom_tags)
        else:
            self.log.debug("Metric value is not supported for metric %s.sum.", name)
        for quantile in getattr(metric, self.METRIC_TYPES[2]).quantile:
            val = quantile.value
            limit = quantile.quantile
            if self._is_value_valid(val):
                self._submit_gauge(
                    "{}.quantile".format(name),
                    val,
                    metric,
                    custom_tags=custom_tags + ["quantile:{}".format(limit)],
                    hostname=hostname,
                )
            else:
                self.log.debug("Metric value is not supported for metric %s.quantile.", name)
def _submit_gauges_from_summary ( self , name , metric , custom_tags = None , hostname = None ) : if custom_tags is None : custom_tags = [ ] # summaries do not have a value attribute val = getattr ( metric , self . METRIC_TYPES [ 2 ] ) . sample_count if self . _is_value_valid ( val ) : self . _submit_gauge ( "{}.count" . format ( name ) , val , metric , custom_tags ) else : self . log . debug ( "Metric value is not supported for metric %s.count." , name ) val = getattr ( metric , self . METRIC_TYPES [ 2 ] ) . sample_sum if self . _is_value_valid ( val ) : self . _submit_gauge ( "{}.sum" . format ( name ) , val , metric , custom_tags ) else : self . log . debug ( "Metric value is not supported for metric %s.sum." , name ) for quantile in getattr ( metric , self . METRIC_TYPES [ 2 ] ) . quantile : val = quantile . value limit = quantile . quantile if self . _is_value_valid ( val ) : self . _submit_gauge ( "{}.quantile" . format ( name ) , val , metric , custom_tags = custom_tags + [ "quantile:{}" . format ( limit ) ] , hostname = hostname , ) else : self . log . debug ( "Metric value is not supported for metric %s.quantile." , name )