def send()

in clay/stats.py [0:0]


    def send(self, stat):
        '''
        Send a raw stat line to statsd. A new socket will be opened and
        connected if necessary. Returns True if the stat was sent successfully.

        :param stat: The stat to be sent to statsd, with no trailing newline
        :type stat: string
        :rtype: boolean
        '''
        proto, sock = self.get_socket()
        if sock is None:
            return False

        if not stat.endswith('\n'):
            stat += '\n'

        try:
            if proto == 'udp':
                sock.sendto(stat, 0, (self.host, self.port))
                return True

            if proto == 'tcp':
                sock.sendall(stat)
                return True
        except socket.error:
            log.exception('Unable to send to statsd, resetting socket')
            self.reset()
        return False