-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
feat(processors.enum): Add fields and tags config options #13824
Conversation
Download PR build artifacts for linux_amd64.tar.gz, darwin_amd64.tar.gz, and windows_amd64.zip. 📦 Click here to get additional PR build artifactsArtifact URLs |
if mapping.Field != "" { | ||
fieldFilter, err := filter.NewIncludeExcludeFilter([]string{mapping.Field}, nil) | ||
if err != nil { | ||
return fmt.Errorf("failed to create new field filter: %w", err) | ||
return fmt.Errorf("failed to create new field filter from field: %w", err) | ||
} | ||
mapper.FieldFilters[mapping.Field] = fieldFilter | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about just adding the single Field
to the Fields
array?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do agree with @Hipska. With the deprecation this would be the best way...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I really would love to deprecate the singular options, create the filters for fields/tags and base all further processing (beyond Init()
) on those filters.
Tag string | ||
Tags []string | ||
Field string | ||
Fields []string |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we please add add TOML annotations here and deprecate the singular options in favor of the plural ones?
if mapping.Field != "" { | ||
fieldFilter, err := filter.NewIncludeExcludeFilter([]string{mapping.Field}, nil) | ||
if err != nil { | ||
return fmt.Errorf("failed to create new field filter: %w", err) | ||
return fmt.Errorf("failed to create new field filter from field: %w", err) | ||
} | ||
mapper.FieldFilters[mapping.Field] = fieldFilter | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do agree with @Hipska. With the deprecation this would be the best way...
} | ||
mapper.FieldFilters[mapping.Field] = fieldFilter | ||
} | ||
if len(mapping.Fields) != 0 { | ||
fieldFilter, err := filter.NewIncludeExcludeFilter(mapping.Fields, nil) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should use a simple filter instead of an IncludeExcludeFilter
here.
if err != nil { | ||
return fmt.Errorf("failed to create new field filter from fields: %w", err) | ||
} | ||
mapper.FieldFilters[mapping.Field] = fieldFilter |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand why you use a map for the filter... The key for the map is either empty (if no field is defined) or has the field name, i.e. the map will only contain a single entry. I think you should store the filter directly instead of using a map.
if mapping.Field != "" { | ||
if mapping.Field != "" || len(mapping.Fields) != 0 { | ||
mapper.fieldMapping(metric, mapping, newFields) | ||
} | ||
if mapping.Tag != "" { | ||
if mapping.Tag != "" || len(mapping.Tags) != 0 { | ||
mapper.tagMapping(metric, mapping, newTags) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As said before, I would prefer to create a filter for tags and fields and then simply check for the filter being not-nil here. I think this will simplify the code...
fixes: #10892