本文整理汇总了Python中dogstatsd.MetricsAggregator.flush_events方法的典型用法代码示例。如果您正苦于以下问题:Python MetricsAggregator.flush_events方法的具体用法?Python MetricsAggregator.flush_events怎么用?Python MetricsAggregator.flush_events使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类dogstatsd.MetricsAggregator
的用法示例。
在下文中一共展示了MetricsAggregator.flush_events方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_event_tags
# 需要导入模块: from dogstatsd import MetricsAggregator [as 别名]
# 或者: from dogstatsd.MetricsAggregator import flush_events [as 别名]
def test_event_tags(self):
stats = MetricsAggregator('myhost')
stats.submit_packets('_e{6,4}:title1|text')
stats.submit_packets('_e{6,4}:title2|text|#t1')
stats.submit_packets('_e{6,4}:title3|text|#t1,t2:v2,t3,t4')
stats.submit_packets('_e{6,4}:title4|text|k:key|p:normal|#t1,t2')
events = self.sort_events(stats.flush_events())
assert len(events) == 4
first, second, third, fourth = events
try:
first['tags']
except Exception:
assert True
else:
assert False, "event['tags'] shouldn't be defined when no tags aren't explicited in the packet"
nt.assert_equal(first['title'], 'title1')
nt.assert_equal(first['text'], 'text')
nt.assert_equal(second['title'], 'title2')
nt.assert_equal(second['text'], 'text')
nt.assert_equal(second['tags'], sorted(['t1']))
nt.assert_equal(third['title'], 'title3')
nt.assert_equal(third['text'], 'text')
nt.assert_equal(third['tags'], sorted(['t1', 't2:v2', 't3', 't4']))
nt.assert_equal(fourth['title'], 'title4')
nt.assert_equal(fourth['text'], 'text')
nt.assert_equal(fourth['aggregation_key'], 'key')
nt.assert_equal(fourth['priority'], 'normal')
nt.assert_equal(fourth['tags'], sorted(['t1', 't2']))
示例2: test_event_text
# 需要导入模块: from dogstatsd import MetricsAggregator [as 别名]
# 或者: from dogstatsd.MetricsAggregator import flush_events [as 别名]
def test_event_text(self):
stats = MetricsAggregator('myhost')
stats.submit_packets('_e{2,0}:t1|')
stats.submit_packets('_e{2,12}:t2|text|content')
stats.submit_packets('_e{2,23}:t3|First line\\nSecond line') # \n is a newline
stats.submit_packets(u'_e{2,19}:t4|♬ †øU †øU ¥ºu T0µ ♪') # utf-8 compliant
events = self.sort_events(stats.flush_events())
assert len(events) == 4
first, second, third, fourth = events
nt.assert_equal(first['text'], '')
nt.assert_equal(second['text'], 'text|content')
nt.assert_equal(third['text'], 'First line\nSecond line')
nt.assert_equal(fourth['text'], u'♬ †øU †øU ¥ºu T0µ ♪')
示例3: test_event_title
# 需要导入模块: from dogstatsd import MetricsAggregator [as 别名]
# 或者: from dogstatsd.MetricsAggregator import flush_events [as 别名]
def test_event_title(self):
stats = MetricsAggregator('myhost')
stats.submit_packets('_e{0,4}:|text')
stats.submit_packets(u'_e{9,4}:2intitulé|text')
stats.submit_packets('_e{14,4}:3title content|text')
stats.submit_packets('_e{14,4}:4title|content|text')
stats.submit_packets('_e{13,4}:5title\\ntitle|text') # \n stays escaped
events = self.sort_events(stats.flush_events())
assert len(events) == 5
first, second, third, fourth, fifth = events
nt.assert_equal(first['title'], '')
nt.assert_equal(second['title'], u'2intitulé')
nt.assert_equal(third['title'], '3title content')
nt.assert_equal(fourth['title'], '4title|content')
nt.assert_equal(fifth['title'], '5title\\ntitle')