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])
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])
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, [])
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, [])
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()))))))
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}])
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 }])
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()))))))