当前位置: 首页>>代码示例>>Python>>正文


Python RewriteRuleManager.rules方法代码示例

本文整理汇总了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)
开发者ID:Akulatraxas,项目名称:carbon,代码行数:30,代码来源:processor.py

示例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)
开发者ID:NixM0nk3y,项目名称:carbon,代码行数:33,代码来源:processor.py

示例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')))
开发者ID:Akulatraxas,项目名称:carbon,代码行数:13,代码来源:test_rewrite.py

示例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")
开发者ID:Akulatraxas,项目名称:carbon,代码行数:7,代码来源:test_rewrite.py


注:本文中的carbon.rewrite.RewriteRuleManager.rules方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。