當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。