mirror of
https://github.com/ClusterCockpit/cc-metric-collector.git
synced 2024-12-25 15:09:05 +01:00
Add comments
This commit is contained in:
parent
2031f35d9b
commit
a8821b7ac5
@ -159,12 +159,13 @@ func getParamMap(point lp.CCMetric) map[string]interface{} {
|
|||||||
|
|
||||||
// DoAddTags adds a tag when condition is fullfiled
|
// DoAddTags adds a tag when condition is fullfiled
|
||||||
func (r *metricRouter) DoAddTags(point lp.CCMetric) {
|
func (r *metricRouter) DoAddTags(point lp.CCMetric) {
|
||||||
|
var conditionMatches bool
|
||||||
for _, m := range r.config.AddTags {
|
for _, m := range r.config.AddTags {
|
||||||
var conditionMatches bool = false
|
|
||||||
|
|
||||||
if m.Condition == "*" {
|
if m.Condition == "*" {
|
||||||
|
// Condition is always matched
|
||||||
conditionMatches = true
|
conditionMatches = true
|
||||||
} else {
|
} else {
|
||||||
|
// Evaluate condition
|
||||||
var err error
|
var err error
|
||||||
conditionMatches, err = agg.EvalBoolCondition(m.Condition, getParamMap(point))
|
conditionMatches, err = agg.EvalBoolCondition(m.Condition, getParamMap(point))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -180,12 +181,13 @@ func (r *metricRouter) DoAddTags(point lp.CCMetric) {
|
|||||||
|
|
||||||
// DoDelTags removes a tag when condition is fullfiled
|
// DoDelTags removes a tag when condition is fullfiled
|
||||||
func (r *metricRouter) DoDelTags(point lp.CCMetric) {
|
func (r *metricRouter) DoDelTags(point lp.CCMetric) {
|
||||||
|
var conditionMatches bool
|
||||||
for _, m := range r.config.DelTags {
|
for _, m := range r.config.DelTags {
|
||||||
var conditionMatches bool = false
|
|
||||||
|
|
||||||
if m.Condition == "*" {
|
if m.Condition == "*" {
|
||||||
|
// Condition is always matched
|
||||||
conditionMatches = true
|
conditionMatches = true
|
||||||
} else {
|
} else {
|
||||||
|
// Evaluate condition
|
||||||
var err error
|
var err error
|
||||||
conditionMatches, err = agg.EvalBoolCondition(m.Condition, getParamMap(point))
|
conditionMatches, err = agg.EvalBoolCondition(m.Condition, getParamMap(point))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -202,16 +204,23 @@ func (r *metricRouter) DoDelTags(point lp.CCMetric) {
|
|||||||
// Conditional test whether a metric should be dropped
|
// Conditional test whether a metric should be dropped
|
||||||
func (r *metricRouter) dropMetric(point lp.CCMetric) bool {
|
func (r *metricRouter) dropMetric(point lp.CCMetric) bool {
|
||||||
// Simple drop check
|
// Simple drop check
|
||||||
if _, ok := r.config.dropMetrics[point.Name()]; ok {
|
if conditionMatches, ok := r.config.dropMetrics[point.Name()]; ok {
|
||||||
return true
|
return conditionMatches
|
||||||
}
|
}
|
||||||
|
|
||||||
// Checking the dropping conditions
|
// Checking the dropping conditions
|
||||||
for _, m := range r.config.DropMetricsIf {
|
for _, m := range r.config.DropMetricsIf {
|
||||||
conditionMatches, err := agg.EvalBoolCondition(m, getParamMap(point))
|
conditionMatches, err := agg.EvalBoolCondition(m, getParamMap(point))
|
||||||
if conditionMatches || err != nil {
|
if err != nil {
|
||||||
return true
|
cclog.ComponentError("MetricRouter", err.Error())
|
||||||
|
conditionMatches = false
|
||||||
|
}
|
||||||
|
if conditionMatches {
|
||||||
|
return conditionMatches
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// No dropping condition met
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user