(self, metric)
Process a metric by sending it to Librato
Process a metric by sending it to Librato
Process a metric by sending it to Librato
def process(self, metric):
        """
        Process a metric by sending it to Librato
        """
        path = metric.getCollectorPath()
        path += '.'
        path += metric.getMetricPath()
        if self.config['apply_metric_prefix']:
            path = metric.getPathPrefix() + '.' + path

        if self.include_reg.match(path):
            if metric.metric_type == 'GAUGE':
                m_type = 'gauge'
            else:
                m_type = 'counter'
            self.queue.add(path,                # name
                           float(metric.value),  # value
                           type=m_type,
                           source=metric.host,
                           measure_time=metric.timestamp)
            self.current_n_measurements += 1
        else:
            self.log.debug("LibratoHandler: Skip %s, no include_filters match",
                           path)

        if (self.current_n_measurements >= self.queue_max_size or
                time.time() >= self.queue_max_timestamp):
            self.log.debug("LibratoHandler: Sending batch size: %d",
                           self.current_n_measurements)
            self._send()
def process ( self , metric ) : path = metric . getCollectorPath ( ) path += '.' path += metric . getMetricPath ( ) if self . config [ 'apply_metric_prefix' ] : path = metric . getPathPrefix ( ) + '.' + path if self . include_reg . match ( path ) : if metric . metric_type == 'GAUGE' : m_type = 'gauge' else : m_type = 'counter' self . queue . add ( path , # name float ( metric . value ) , # value type = m_type , source = metric . host , measure_time = metric . timestamp ) self . current_n_measurements += 1 else : self . log . debug ( "LibratoHandler: Skip %s, no include_filters match" , path ) if ( self . current_n_measurements >= self . queue_max_size or time . time ( ) >= self . queue_max_timestamp ) : self . log . debug ( "LibratoHandler: Sending batch size: %d" , self . current_n_measurements ) self . _send ( )