<s> from carbon . aggregator . rules import RuleManager <EOL> from carbon . aggregator . buffers import BufferManager <EOL> from carbon . instrumentation import increment <EOL> from carbon . pipeline import Processor <EOL> from carbon . rewrite import PRE , POST , RewriteRuleManager <EOL> from carbon . conf import settings <EOL> from carbon import log <EOL> class AggregationProcessor ( Processor ) : <EOL> plugin_name = '<STR_LIT>' <EOL> def process ( self , metric , datapoint ) : <EOL> increment ( '<STR_LIT>' ) <EOL> for rule in RewriteRuleManager . rules ( PRE ) : <EOL> metric = rule . apply ( metric ) <EOL> aggregate_metrics = set ( ) <EOL> for rule in RuleManager . rules : <EOL> aggregate_metric = rule . get_aggregate_metric ( metric ) <EOL> if aggregate_metric is None : <EOL> continue <EOL> else : <EOL> aggregate_metrics . add ( aggregate_metric ) <EOL> values_buffer = BufferManager . get_buffer ( aggregate_metric ) <EOL> if not values_buffer . configured : <EOL> values_buffer . configure_aggregation ( rule . frequency , rule . aggregation_func ) <EOL> values_buffer . input ( datapoint ) <EOL> for rule in RewriteRuleManager . rules ( POST ) : <EOL> metric = rule . apply ( metric ) <EOL> if settings . FORWARD_ALL and metric not in aggregate_metrics : <EOL> if settings . LOG_AGGREGATOR_MISSES and len ( aggregate_metrics ) == <NUM_LIT:0> : <EOL> log . msg ( "<STR_LIT>" % metric ) <EOL> yield ( metric , datapoint ) </s>
