Example #1
0
    def test_incr_one_type(self):
        error_counter = metrics.TaggedCounter('exception')

        error_counter.incr(type='ValueError')
        error_counter.incr(4, type='ValueError')

        self.assertEqual(list(error_counter), [
            ('exception', 5, {'type': 'ValueError'})])
Example #2
0
 def on_start(self):
     super(ZmqRPCServer, self).on_start()
     self.metrics.add(
         metrics.Callable('rpc.connection_count',
                          lambda: len(self.connections)))
     self.request_counts = self.metrics.add(metrics.TaggedCounter('rpc'))
     self._bind()
     self.running = True
     self.recv_loop_greenlet = self.spawn(self._recv_loop)
Example #3
0
    def __init__(self, container, address, timeout=REQUEST_TIMEOUT, namespace='', error_map=None):
        super(Proxy, self).__init__()
        self._container = container
        self._address = address
        self._method_cache = {}
        self._timeout = timeout
        self._namespace = namespace or address
        self._error_map = error_map or {}

        self.timeout_counts = metrics.Counter('timeout', {'address': address})
        self.exception_counts = metrics.TaggedCounter('exceptions', {'address': address})
Example #4
0
    def test_incr_different_types(self):
        error_counter = metrics.TaggedCounter('exception')

        error_counter.incr(type='ValueError')
        error_counter.incr(type='ValueError')

        error_counter.incr(type='Nack')

        self.assertEqual(
            sorted(error_counter, key=operator.itemgetter(1)), [
                ('exception', 1, {'type': 'Nack'}),
                ('exception', 2, {'type': 'ValueError'}),
            ])
Example #5
0
    def __init__(self, ip='127.0.0.1', port=None, pool=None):
        super(ZmqRPCServer, self).__init__(pool=pool)
        self.ip = ip
        self.port = port

        self.zctx = zmq.Context.instance()
        self.endpoint = None
        self.bound = False
        self.request_counts = metrics.TaggedCounter('rpc')
        self.recv_loop_greenlet = None
        self.channels = {}
        self.connections = {}
        self.running = False
        self.request_handler = lambda channel: None
Example #6
0
 def on_start(self):
     super(Proxy, self).on_start()
     self.timeout_counts = self.metrics.add(metrics.Counter('rpc.timeout_count', {'address': self._address}))
     self.exception_counts = self.metrics.add(metrics.TaggedCounter('rpc.exception_count', {'address': self._address}))