本文整理匯總了Python中carbon.rewrite.RewriteRuleManager.rules方法的典型用法代碼示例。如果您正苦於以下問題:Python RewriteRuleManager.rules方法的具體用法?Python RewriteRuleManager.rules怎麽用?Python RewriteRuleManager.rules使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類carbon.rewrite.RewriteRuleManager
的用法示例。
在下文中一共展示了RewriteRuleManager.rules方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: process
# 需要導入模塊: from carbon.rewrite import RewriteRuleManager [as 別名]
# 或者: from carbon.rewrite.RewriteRuleManager import rules [as 別名]
def process(self, metric, datapoint):
increment('datapointsReceived')
for rule in RewriteRuleManager.rules(PRE):
metric = rule.apply(metric)
aggregate_metrics = set()
for rule in RuleManager.rules:
aggregate_metric = rule.get_aggregate_metric(metric)
if aggregate_metric is None:
continue
else:
aggregate_metrics.add(aggregate_metric)
values_buffer = BufferManager.get_buffer(aggregate_metric)
if not values_buffer.configured:
values_buffer.configure_aggregation(rule.frequency, rule.aggregation_func)
values_buffer.input(datapoint)
for rule in RewriteRuleManager.rules(POST):
metric = rule.apply(metric)
if metric not in aggregate_metrics:
yield (metric, datapoint)
示例2: process
# 需要導入模塊: from carbon.rewrite import RewriteRuleManager [as 別名]
# 或者: from carbon.rewrite.RewriteRuleManager import rules [as 別名]
def process(self, metric, datapoint):
increment('datapointsReceived')
for rule in RewriteRuleManager.rules(PRE):
metric = rule.apply(metric)
aggregate_metrics = set()
for rule in RuleManager.rules:
aggregate_metric = rule.get_aggregate_metric(metric)
if aggregate_metric is None:
continue
else:
aggregate_metrics.add(aggregate_metric)
values_buffer = BufferManager.get_buffer(aggregate_metric)
if not values_buffer.configured:
values_buffer.configure_aggregation(rule.frequency, rule.aggregation_func)
values_buffer.input(datapoint)
for rule in RewriteRuleManager.rules(POST):
metric = rule.apply(metric)
if settings.FORWARD_ALL and metric not in aggregate_metrics:
if settings.LOG_AGGREGATOR_MISSES and len(aggregate_metrics) == 0:
log.msg(
"Couldn't match metric %s with any aggregation rule. Passing on un-aggregated." % metric)
yield (metric, datapoint)
示例3: test_comments_ignored
# 需要導入模塊: from carbon.rewrite import RewriteRuleManager [as 別名]
# 或者: from carbon.rewrite.RewriteRuleManager import rules [as 別名]
def test_comments_ignored(self):
import carbon.rewrite
open_mock = Mock(return_value=iter(self.commented_config.splitlines()))
RewriteRuleManager.rules_file = 'foo.conf'
with patch.object(carbon.rewrite, 'open', open_mock, create=True):
with patch.object(carbon.rewrite, 'exists', Mock(return_value=True)):
with patch.object(carbon.rewrite, 'getmtime', Mock(return_value=1234)):
RewriteRuleManager.read_rules()
self.assertEqual(1, len(RewriteRuleManager.rules('pre')))
示例4: test_request_for_nonexistent_rules_returns_iterable
# 需要導入模塊: from carbon.rewrite import RewriteRuleManager [as 別名]
# 或者: from carbon.rewrite.RewriteRuleManager import rules [as 別名]
def test_request_for_nonexistent_rules_returns_iterable(self):
try:
iter(RewriteRuleManager.rules('foo'))
except TypeError:
self.fail("RewriteRuleManager.rules() returned a non-iterable type")