コード例 #1
0
ファイル: test_log.py プロジェクト: rackerlabs/otter
 def test_non_matching(self):
     """If a log doesn't match a template, it's just logged as normal."""
     logs = []
     observer = logs.append
     throttler = throttling_wrapper(observer)
     event = {'message': ('foo bar',), 'system': 'baz'}
     throttler(event)
     self.assertEqual(logs, [event])
コード例 #2
0
ファイル: test_log.py プロジェクト: stephamon/otter
 def test_non_matching(self):
     """If a log doesn't match a template, it's just logged as normal."""
     logs = []
     observer = logs.append
     throttler = throttling_wrapper(observer)
     event = {'message': ('foo bar', ), 'system': 'baz'}
     throttler(event)
     self.assertEqual(logs, [event])
コード例 #3
0
ファイル: test_log.py プロジェクト: rackerlabs/otter
 def test_matching(self):
     """
     If a log matches a template, it's not immediately logged.
     """
     logs = []
     observer = logs.append
     throttler = throttling_wrapper(observer)
     event = {'message': ('Received Ping',), 'system': 'kazoo'}
     throttler(event)
     self.assertEqual(logs, [])
コード例 #4
0
ファイル: test_log.py プロジェクト: stephamon/otter
 def test_matching(self):
     """
     If a log matches a template, it's not immediately logged.
     """
     logs = []
     observer = logs.append
     throttler = throttling_wrapper(observer)
     event = {'message': ('Received Ping', ), 'system': 'kazoo'}
     throttler(event)
     self.assertEqual(logs, [])
コード例 #5
0
def make_observer_chain(ultimate_observer, indent):
    """
    Return our feature observers wrapped our the ultimate_observer
    """
    add_to_fanout(
        ObserverWrapper(JSONObserverWrapper(ultimate_observer,
                                            sort_keys=True,
                                            indent=indent or None),
                        hostname=socket.gethostname()))

    return throttling_wrapper(
        SpecificationObserverWrapper(
            PEP3101FormattingWrapper(
                SystemFilterWrapper(
                    ErrorFormattingWrapper(cf_id_wrapper(get_fanout()))))))
コード例 #6
0
ファイル: test_log.py プロジェクト: rackerlabs/otter
 def test_aggregate(self):
     """
     After so many events are received, a matching message gets logged along
     with the number of times it was throttled.
     """
     logs = []
     observer = logs.append
     throttler = throttling_wrapper(observer)
     event = {'message': ('Received Ping',), 'system': 'kazoo'}
     for i in range(50):
         throttler(event)
     self.assertEqual(
         logs,
         [{'message': ('Received Ping',), 'system': 'kazoo',
           'num_duplicate_throttled': 50}])
コード例 #7
0
ファイル: test_log.py プロジェクト: stephamon/otter
 def test_aggregate(self):
     """
     After so many events are received, a matching message gets logged along
     with the number of times it was throttled.
     """
     logs = []
     observer = logs.append
     throttler = throttling_wrapper(observer)
     event = {'message': ('Received Ping', ), 'system': 'kazoo'}
     for i in range(50):
         throttler(event)
     self.assertEqual(logs, [{
         'message': ('Received Ping', ),
         'system': 'kazoo',
         'num_duplicate_throttled': 50
     }])
コード例 #8
0
ファイル: setup.py プロジェクト: rackerlabs/otter
def make_observer_chain(ultimate_observer, indent):
    """
    Return our feature observers wrapped our the ultimate_observer
    """
    add_to_fanout(
        ObserverWrapper(
            JSONObserverWrapper(
                ultimate_observer,
                sort_keys=True,
                indent=indent or None),
            hostname=socket.gethostname()))

    return throttling_wrapper(
        SpecificationObserverWrapper(
            PEP3101FormattingWrapper(
                SystemFilterWrapper(
                    ErrorFormattingWrapper(
                        cf_id_wrapper(
                            get_fanout()))))))