Exemplo n.º 1
0
 def do_nothing():
     Statsd.timing("python.test.timer",500)
     Statsd.gauge("python.test.gauge",500)
     Statsd.increment("python.test.counter")
     Statsd.decrement("python.test.counter")
     Statsd.update_stats("python.test.counter", 5, sample_rate=1, message="ok")
     Statsd.update_stats("python.test.counter", -5, sample_rate=0)
Exemplo n.º 2
0
 def test_stats():
     Statsd.timing('python.test.timer', 500)
     Statsd.gauge('python.test.gauge', 500)
     Statsd.increment('python.test.counter')
     Statsd.decrement('python.test.counter')
     Statsd.update_stats('python.test.counter', 5, sample_rate=1)
     Statsd.update_stats('python.test.counter', -5, sample_rate=0)
Exemplo n.º 3
0
    def test_AFTransport_with_UDP(self):
        shlib = MagicMock()
        # TODO: not finished
        transport = AFTransport(useUDP=True)
        Statsd.set_transport(transport)

#        shlib.mq_open.return_value = 1
#        shlib.mq_send.return_value = 0

        Statsd.increment("mqtest")
        self.assertEqual(shlib.mq_open.call_count, 0)

        #post = "mqtest:1|c"
        self.assertEqual(shlib.mq_send.call_count, 0)
Exemplo n.º 4
0
    def test_AFTransport_with_UDP(self):
        shlib = MagicMock()
        # TODO: not finished
        transport = AFTransport(useUDP=True)
        Statsd.set_transport(transport)

        #        shlib.mq_open.return_value = 1
        #        shlib.mq_send.return_value = 0

        Statsd.increment("mqtest")
        self.assertEqual(shlib.mq_open.call_count, 0)

        #post = "mqtest:1|c"
        self.assertEqual(shlib.mq_send.call_count, 0)
Exemplo n.º 5
0
    def test_AFTransport(self):
        shlib = MagicMock()
        transport = AFTransport()

        transport.shlib = shlib
        Statsd.set_transport(transport)

        shlib.mq_open.return_value = 1
        shlib.mq_send.return_value = 0

        Statsd.increment("mqtest")
        shlib.mq_open.assert_called_once_with("/afcollectorapi", 04001)
        self.assertEqual(shlib.mq_open.call_args[0][0], "/afcollectorapi")
        self.assertEqual(shlib.mq_open.call_args[0][1], 04001)
        post = "mqtest:1|c"
        shlib.mq_send.assert_called_once_with(1, post, len(post), 3)
        self.assertEqual(shlib.mq_send.call_args[0][0], 1)
        self.assertEqual(shlib.mq_send.call_args[0][1], post)
        self.assertEqual(shlib.mq_send.call_args[0][2], len(post))
        self.assertEqual(shlib.mq_send.call_args[0][3], 3)
Exemplo n.º 6
0
    def test_AFTransport(self):
        shlib = MagicMock()
        transport = AFTransport()

        transport.shlib = shlib
        Statsd.set_transport(transport)

        shlib.mq_open.return_value = 1
        shlib.mq_send.return_value = 0

        Statsd.increment("mqtest")
        shlib.mq_open.assert_called_once_with("/afcollectorapi", 04001)
        self.assertEqual(shlib.mq_open.call_args[0][0], "/afcollectorapi")
        self.assertEqual(shlib.mq_open.call_args[0][1], 04001)
        post = "mqtest:1|c"
        shlib.mq_send.assert_called_once_with(1, post, len(post), 3)
        self.assertEqual(shlib.mq_send.call_args[0][0], 1)
        self.assertEqual(shlib.mq_send.call_args[0][1], post)
        self.assertEqual(shlib.mq_send.call_args[0][2], len(post))
        self.assertEqual(shlib.mq_send.call_args[0][3], 3)
Exemplo n.º 7
0
from client import Statsd

Statsd.increment("test.ten")
Statsd.increment("test.ten")
Statsd.increment("test.ten")
Statsd.increment("test.ten")
Statsd.increment("test.ten")
Exemplo n.º 8
0

class MQError(Exception):
    def __init__(self, msg=None):
        self.msg = msg or "Statsd Error"

    def __str__(self):
        return str(self.msg)


class MQSendError(Exception):
    def __init__(self, rc, msg=None):
        self.rc = rc
        self.msg = msg or "Statsd Error"

    def __str__(self):
        return str(self.msg) + " return errcode %s" % errno.errorcode(self.rc)


Statsd.set_transport(AFTransport())
Statsd.set_strategy(GeyserStategy())

if __name__ == "__main__":
    #    import time
    Statsd.set_transport(AFTransport(verbosity=True))
    count = 1
    while True:
        Statsd.increment("mqtest")
        print "send mqtest %s" % count
        count += 1