Beispiel #1
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})
Beispiel #2
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}))
Beispiel #3
0
    def test_get(self):
        counter = metrics.Counter('requests')

        self.assertEqual(list(counter), [('requests', 0, {})])
Beispiel #4
0
    def test_increment_by_many(self):
        counter = metrics.Counter('requests')
        counter += 66

        self.assertEqual(list(counter), [('requests', 66, {})])
Beispiel #5
0
    def test_increment_by_one(self):
        counter = metrics.Counter('requests')
        counter += 1

        self.assertEqual(list(counter), [('requests', 1, {})])
Beispiel #6
0
    def test_repr(self):
        counter = metrics.Counter('requests')

        self.assertEqual(str(counter), repr(counter))
        self.assertEqual(repr(counter), "Counter(name='requests', tags={})")