本文整理汇总了Python中dogstatsd.MetricsAggregator.gauge方法的典型用法代码示例。如果您正苦于以下问题:Python MetricsAggregator.gauge方法的具体用法?Python MetricsAggregator.gauge怎么用?Python MetricsAggregator.gauge使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类dogstatsd.MetricsAggregator
的用法示例。
在下文中一共展示了MetricsAggregator.gauge方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_gauge
# 需要导入模块: from dogstatsd import MetricsAggregator [as 别名]
# 或者: from dogstatsd.MetricsAggregator import gauge [as 别名]
def test_gauge(self):
stats = MetricsAggregator('myhost')
# Track some counters.
stats.submit_packets('my.first.gauge:1|g')
stats.submit_packets('my.first.gauge:5|g')
stats.submit_packets('my.second.gauge:1.5|g')
# Ensure that gauges roll up correctly.
metrics = self.sort_metrics(stats.flush())
assert len(metrics) == 2
first, second = metrics
nt.assert_equals(first['metric'], 'my.first.gauge')
nt.assert_equals(first['points'][0][1], 5)
nt.assert_equals(first['host'], 'myhost')
nt.assert_equals(second['metric'], 'my.second.gauge')
nt.assert_equals(second['points'][0][1], 1.5)
# Ensure that old gauges get dropped due to old timestamps
stats.gauge('my.first.gauge', 5)
stats.gauge('my.first.gauge', 1, timestamp=1000000000)
stats.gauge('my.second.gauge', 20, timestamp=1000000000)
metrics = self.sort_metrics(stats.flush())
assert len(metrics) == 1
first = metrics[0]
nt.assert_equals(first['metric'], 'my.first.gauge')
nt.assert_equals(first['points'][0][1], 5)
nt.assert_equals(first['host'], 'myhost')