def report_stats(self, payload, is_retry=False):
        """
        Send data to graphite host

        :param payload: Data to send to graphite
        """
        if self.debug:
            if self.pickle_proto:
                print "reporting pickled stats"
            else:
                print "reporting stats -> {\n%s}" % payload
        try:
            graphite = socket.socket()
            with eventlet.Timeout(self.graphite_timeout, True):
                graphite.connect(self.graphite_addr)
                graphite.sendall(payload)
                graphite.close()
        except eventlet.timeout.Timeout:
            self.logger.critical("Timeout sending to graphite")
            if self.debug:
                print "Timeout talking to graphite"
            if not is_retry:
                self.logger.critical('Attempting 1 retry!')
                self.report_stats(payload, is_retry=True)
            else:
                self.logger.critical('Already retried once, giving up')
        except Exception as err:
            self.logger.critical("error connecting to graphite: %s" % err)
            if self.debug:
                print "error connecting to graphite: %s" % err
        finally:
            try:
                graphite.close()
            except Exception:
                pass
def report_stats ( self , payload , is_retry = False ) : if self . debug : if self . pickle_proto : print "reporting pickled stats" else : print "reporting stats -> {\n%s}" % payload try : graphite = socket . socket ( ) with eventlet . Timeout ( self . graphite_timeout , True ) : graphite . connect ( self . graphite_addr ) graphite . sendall ( payload ) graphite . close ( ) except eventlet . timeout . Timeout : self . logger . critical ( "Timeout sending to graphite" ) if self . debug : print "Timeout talking to graphite" if not is_retry : self . logger . critical ( 'Attempting 1 retry!' ) self . report_stats ( payload , is_retry = True ) else : self . logger . critical ( 'Already retried once, giving up' ) except Exception as err : self . logger . critical ( "error connecting to graphite: %s" % err ) if self . debug : print "error connecting to graphite: %s" % err finally : try : graphite . close ( ) except Exception : pass
Send data to graphite host

        :param payload: Data to send to graphite