Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add without aggregator modifier. #1376

Merged
merged 2 commits into from
Feb 8, 2016
Merged

Add without aggregator modifier. #1376

merged 2 commits into from
Feb 8, 2016

Conversation

brian-brazil
Copy link
Contributor

This has the advantage that the user doesn't need
to list all labels they want to keep (as with "by")
but without having to worry about inconsistent labels
as when there's only one time series (as with "keeping_common").

Almost all aggregation should use this rather than the existing
two options as it's much less error prone and easier to maintain
due to not having to always add in "job" plus whatever other common
job-level labels you have like "region".

@fabxc In terms of aggregation, this should make us feature complete.

groupingKey := model.SignatureForLabels(sample.Metric.Metric, grouping...)
var withoutMetric metric.Metric
if without {
withoutMetric = *sample.Metric.Copy()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For by we build the metric in the if condition above. Doing it here for without makes things inconsistent and hard to read.

Also metric.Metric is already the copy-on-write version. So this line can essentially be dropped.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The problem is we need this version in two places, so I didn't want to duplicate the code.

Dropped the line.


result := map[uint64]*groupedAggregation{}

for _, sample := range vec {
groupingKey := model.SignatureForLabels(sample.Metric.Metric, grouping...)
withoutMetric := sample.Metric
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

gofmt

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

This has the advantage that the user doesn't need
to list all labels they want to keep (as with "by")
but without having to worry about inconsistent labels
as when there's only one time series (as with "keeping_common").

Almost all aggregation should use this rather than the existing
two options as it's much less error prone and easier to maintain
due to not having to always add in "job" plus whatever other common
job-level labels you have like "region".
@fabxc
Copy link
Contributor

fabxc commented Feb 8, 2016

👍

brian-brazil added a commit that referenced this pull request Feb 8, 2016
Add without aggregator modifier.
@brian-brazil brian-brazil merged commit c0df1c7 into master Feb 8, 2016
@brian-brazil brian-brazil deleted the without branch February 8, 2016 14:09
@matthiasr
Copy link
Contributor

I realize I'm late to the party, but if this does what I think it does I would like to propose calling it over instead of without. The way to read that would be "sum over (dimensions)". To me, removing labels is a side effect of aggregations, not what they are about at their core. Additionally, " sum without" suggests that something is not being included in the sum, which is not the case.

@matthiasr
Copy link
Contributor

(just putting this out there before this is in a release)

@brian-brazil
Copy link
Contributor Author

"over" sounds more like what "by" does by default. I'd consider removing labels to be a key part of aggregation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants