(self)
Send data to statsd. Fire and forget.  Cross fingers and it'll arrive.
Send data to statsd. Fire and forget.  Cross fingers and it'll arrive.
Send data to statsd . Fire and forget . Cross fingers and it ll arrive .
def _send(self):
        """
        Send data to statsd. Fire and forget.  Cross fingers and it'll arrive.
        """
        if not statsd:
            return
        for metric in self.metrics:

            # Split the path into a prefix and a name
            # to work with the statsd module's view of the world.
            # It will get re-joined by the python-statsd module.
            #
            # For the statsd module, you specify prefix in the constructor
            # so we just use the full metric path.
            (prefix, name) = metric.path.rsplit(".", 1)
            logging.debug("Sending %s %s|g", name, metric.value)

            if metric.metric_type == 'GAUGE':
                if hasattr(statsd, 'StatsClient'):
                    self.connection.gauge(metric.path, metric.value)
                else:
                    statsd.Gauge(prefix, self.connection).send(
                        name, metric.value)
            else:
                # To send a counter, we need to just send the delta
                # but without any time delta changes
                value = metric.raw_value
                if metric.path in self.old_values:
                    value = value - self.old_values[metric.path]
                self.old_values[metric.path] = metric.raw_value

                if hasattr(statsd, 'StatsClient'):
                    self.connection.incr(metric.path, value)
                else:
                    statsd.Counter(prefix, self.connection).increment(
                        name, value)

        if hasattr(statsd, 'StatsClient'):
            self.connection.send()
        self.metrics = []
def _send ( self ) : if not statsd : return for metric in self . metrics : # Split the path into a prefix and a name # to work with the statsd module's view of the world. # It will get re-joined by the python-statsd module. # # For the statsd module, you specify prefix in the constructor # so we just use the full metric path. ( prefix , name ) = metric . path . rsplit ( "." , 1 ) logging . debug ( "Sending %s %s|g" , name , metric . value ) if metric . metric_type == 'GAUGE' : if hasattr ( statsd , 'StatsClient' ) : self . connection . gauge ( metric . path , metric . value ) else : statsd . Gauge ( prefix , self . connection ) . send ( name , metric . value ) else : # To send a counter, we need to just send the delta # but without any time delta changes value = metric . raw_value if metric . path in self . old_values : value = value - self . old_values [ metric . path ] self . old_values [ metric . path ] = metric . raw_value if hasattr ( statsd , 'StatsClient' ) : self . connection . incr ( metric . path , value ) else : statsd . Counter ( prefix , self . connection ) . increment ( name , value ) if hasattr ( statsd , 'StatsClient' ) : self . connection . send ( ) self . metrics = [ ]