Merge lp:~mleinartas/graphite/aggregation_overwrite into lp:~graphite-dev/graphite/main

Proposed by Michael Leinartas
Status: Merged
Merged at revision: 661
Proposed branch: lp:~mleinartas/graphite/aggregation_overwrite
Merge into: lp:~graphite-dev/graphite/main
Diff against target: 26 lines (+6/-1)
1 file modified
carbon/lib/carbon/aggregator/receiver.py (+6/-1)
To merge this branch: bzr merge lp:~mleinartas/graphite/aggregation_overwrite
Reviewer Review Type Date Requested Status
Michael Leinartas Approve
Review via email: mp+85606@code.launchpad.net

Commit message

keep aggregator from clobbering aggregated values with original ones

Description of the change

This is a small patch to address the issue here: https://answers.launchpad.net/graphite/+question/179788 which is something I also run into and have had to work around.

There is a use case for using carbon-aggregator to aggregate incoming metrics and have the original values discarded and replaced with the new, aggregated ones. This could, for instance, replace the role of statsd and its clones for some users. The existing behavior is also surprising and I cannot imagine a case where it would be a desired behavior.

To post a comment you must log in.
Revision history for this message
Michael Leinartas (mleinartas) wrote :

Oops, the issue I meant to link was this one: https://answers.launchpad.net/graphite/+question/180328

Revision history for this message
Michael Leinartas (mleinartas) wrote :

Pushing this forward as it doesn't break any existing behavior and fixes a violation of "principal of least surprise"

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'carbon/lib/carbon/aggregator/receiver.py'
2--- carbon/lib/carbon/aggregator/receiver.py 2011-08-19 07:19:16 +0000
3+++ carbon/lib/carbon/aggregator/receiver.py 2011-12-14 05:30:41 +0000
4@@ -11,11 +11,15 @@
5 for rule in RewriteRuleManager.preRules:
6 metric = rule.apply(metric)
7
8+ aggregate_metrics = []
9+
10 for rule in RuleManager.rules:
11 aggregate_metric = rule.get_aggregate_metric(metric)
12
13 if aggregate_metric is None:
14 continue
15+ else
16+ aggregate_metrics.append(aggregate_metric)
17
18 buffer = BufferManager.get_buffer(aggregate_metric)
19
20@@ -27,4 +31,5 @@
21 for rule in RewriteRuleManager.postRules:
22 metric = rule.apply(metric)
23
24- events.metricGenerated(metric, datapoint)
25+ if metric not in aggregate_metrics:
26+ events.metricGenerated(metric, datapoint)

Subscribers

People subscribed via source and target branches