Skip to content
This repository has been archived by the owner on Oct 17, 2018. It is now read-only.

Commit

Permalink
Address feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
Rob Skillington committed Jul 24, 2018
1 parent 00e8df3 commit cb5f0fc
Show file tree
Hide file tree
Showing 7 changed files with 47 additions and 47 deletions.
66 changes: 33 additions & 33 deletions generated/proto/policypb/policy.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion generated/proto/policypb/policy.proto
Original file line number Diff line number Diff line change
Expand Up @@ -48,5 +48,5 @@ message Policy {
enum DropPolicy {
NONE = 0;
DROP_MUST = 1;
DROP_EXCEPT_IF_OTHER_MATCH = 2;
DROP_IF_ONLY_MATCH = 2;
}
8 changes: 4 additions & 4 deletions policy/drop_policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ const (
// DropMust specifies to always drop matched metrics, irregardless of
// other rules.
DropMust
// DropExceptIfOtherMatch specifies to drop matched metrics, but only if no
// DropIfOnlyMatch specifies to drop matched metrics, but only if no
// other rules match.
DropExceptIfOtherMatch
DropIfOnlyMatch

// DefaultDropPolicy is to drop none.
DefaultDropPolicy = DropNone
Expand All @@ -42,7 +42,7 @@ const (
var validDropPolicies = []DropPolicy{
DropNone,
DropMust,
DropExceptIfOtherMatch,
DropIfOnlyMatch,
}

// IsDefault returns whether the drop policy is the default drop none policy.
Expand All @@ -56,7 +56,7 @@ func (p DropPolicy) String() string {
return "drop_none"
case DropMust:
return "drop_must"
case DropExceptIfOtherMatch:
case DropIfOnlyMatch:
return "drop_except_if_other_match"
}
return DropNone.String()
Expand Down
8 changes: 4 additions & 4 deletions rules/active_ruleset.go
Original file line number Diff line number Diff line change
Expand Up @@ -748,21 +748,21 @@ func (res *ruleMatchResults) unique() *ruleMatchResults {
}

// First resolve any drop policies
dropExceptIfOtherMatchPipelines := 0
DropIfOnlyMatchPipelines := 0
nonDropPipelines := 0
for i := range res.pipelines {
switch res.pipelines[i].DropPolicy {
case policy.DropMust:
// Immediately return, the result is a must drop
res.pipelines = metadata.DropPipelineMetadatas
return res
case policy.DropExceptIfOtherMatch:
dropExceptIfOtherMatchPipelines++
case policy.DropIfOnlyMatch:
DropIfOnlyMatchPipelines++
continue
}
nonDropPipelines++
}
if dropExceptIfOtherMatchPipelines > 0 && nonDropPipelines == 0 {
if DropIfOnlyMatchPipelines > 0 && nonDropPipelines == 0 {
// A drop policy is effective as no other non-drop pipelines
res.pipelines = metadata.DropPipelineMetadatas
return res
Expand Down
4 changes: 2 additions & 2 deletions rules/active_ruleset_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3336,7 +3336,7 @@ func testMappingRules(t *testing.T) []*mappingRule {
filter: filter6,
aggregationID: aggregation.DefaultID,
storagePolicies: policy.StoragePolicies{},
dropPolicy: policy.DropExceptIfOtherMatch,
dropPolicy: policy.DropIfOnlyMatch,
},
},
}
Expand Down Expand Up @@ -3369,7 +3369,7 @@ func testMappingRules(t *testing.T) []*mappingRule {
filter: filter7,
aggregationID: aggregation.DefaultID,
storagePolicies: policy.StoragePolicies{},
dropPolicy: policy.DropExceptIfOtherMatch,
dropPolicy: policy.DropIfOnlyMatch,
},
},
}
Expand Down
4 changes: 2 additions & 2 deletions rules/mapping_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ var (
LastUpdatedAtNanos: 67890000000,
LastUpdatedBy: "someone-else",
StoragePolicies: []*policypb.StoragePolicy{},
DropPolicy: policypb.DropPolicy_DROP_EXCEPT_IF_OTHER_MATCH,
DropPolicy: policypb.DropPolicy_DROP_IF_ONLY_MATCH,
}
testMappingRule1V1Proto = &rulepb.MappingRule{
Uuid: "12669817-13ae-40e6-ba2f-33087b262c68",
Expand Down Expand Up @@ -278,7 +278,7 @@ var (
rawFilter: "tag1:value1 tag2:value2",
aggregationID: aggregation.DefaultID,
storagePolicies: policy.StoragePolicies{},
dropPolicy: policy.DropExceptIfOtherMatch,
dropPolicy: policy.DropIfOnlyMatch,
lastUpdatedAtNanos: 67890000000,
lastUpdatedBy: "someone-else",
}
Expand Down
2 changes: 1 addition & 1 deletion rules/view/mapping_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ func TestMappingRuleNotEqual(t *testing.T) {
StoragePolicies: policy.StoragePolicies{
policy.NewStoragePolicy(10*time.Second, xtime.Second, time.Hour),
},
DropPolicy: policy.DropExceptIfOtherMatch,
DropPolicy: policy.DropIfOnlyMatch,
},
}
for i := 0; i < len(rules); i++ {
Expand Down

0 comments on commit cb5f0fc

Please sign in to comment.