(self, name, value, raw_value=None, precision=0,
                metric_type='GAUGE', instance=None)
Publish a metric with the given name
Publish a metric with the given name
Publish a metric with the given name
def publish(self, name, value, raw_value=None, precision=0,
                metric_type='GAUGE', instance=None):
        """
        Publish a metric with the given name
        """
        # Check whitelist/blacklist
        if self.config['metrics_whitelist']:
            if not self.config['metrics_whitelist'].match(name):
                return
        elif self.config['metrics_blacklist']:
            if self.config['metrics_blacklist'].match(name):
                return

        # Get metric Path
        path = self.get_metric_path(name, instance=instance)

        # Get metric TTL
        ttl = float(self.config['interval']) * float(
            self.config['ttl_multiplier'])

        # Create Metric
        try:
            metric = Metric(path, value, raw_value=raw_value, timestamp=None,
                            precision=precision, host=self.get_hostname(),
                            metric_type=metric_type, ttl=ttl)
        except DiamondException:
            self.log.error(('Error when creating new Metric: path=%r, '
                            'value=%r'), path, value)
            raise

        # Publish Metric
        self.publish_metric(metric)
def publish ( self , name , value , raw_value = None , precision = 0 , metric_type = 'GAUGE' , instance = None ) : # Check whitelist/blacklist if self . config [ 'metrics_whitelist' ] : if not self . config [ 'metrics_whitelist' ] . match ( name ) : return elif self . config [ 'metrics_blacklist' ] : if self . config [ 'metrics_blacklist' ] . match ( name ) : return # Get metric Path path = self . get_metric_path ( name , instance = instance ) # Get metric TTL ttl = float ( self . config [ 'interval' ] ) * float ( self . config [ 'ttl_multiplier' ] ) # Create Metric try : metric = Metric ( path , value , raw_value = raw_value , timestamp = None , precision = precision , host = self . get_hostname ( ) , metric_type = metric_type , ttl = ttl ) except DiamondException : self . log . error ( ( 'Error when creating new Metric: path=%r, ' 'value=%r' ) , path , value ) raise # Publish Metric self . publish_metric ( metric )