-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
[exporter/sumologic] Make the exporter to not mutate logs data #13923
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
The exporter unnecessary mutates log data just to temporarily copy resource attributes into log attributes. This change removes that redundant step which make the exporter not mutating anymore.
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -41,19 +41,22 @@ func newFilter(flds []string) (filter, error) { | |
}, nil | ||
} | ||
|
||
// filterIn returns fields which match at least one of the filter regexes | ||
func (f *filter) filterIn(attributes pcommon.Map) fields { | ||
// mergeAndFilterIn merges provided attribute maps and returns fields which match at least one of the filter regexes. | ||
// Later attribute maps take precedence over former ones. | ||
func (f *filter) mergeAndFilterIn(attrMaps ...pcommon.Map) fields { | ||
returnValue := pcommon.NewMap() | ||
|
||
attributes.Range(func(k string, v pcommon.Value) bool { | ||
for _, regex := range f.regexes { | ||
if regex.MatchString(k) { | ||
v.CopyTo(returnValue.UpsertEmpty(k)) | ||
return true | ||
for _, attributes := range attrMaps { | ||
attributes.Range(func(k string, v pcommon.Value) bool { | ||
for _, regex := range f.regexes { | ||
if regex.MatchString(k) { | ||
v.CopyTo(returnValue.UpsertEmpty(k)) | ||
return true | ||
} | ||
} | ||
} | ||
return true | ||
}) | ||
return true | ||
}) | ||
} | ||
returnValue.Sort() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Don't need to sort? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should be done in a separate PR, owners should look into this. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, sort seems redundant. didn't want to do unrelated refactoring in this PR |
||
return newFields(returnValue) | ||
} | ||
|
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.
EnsureCap?
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.
Same, this can be done in a separate PR.