-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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 tag "truncated" to "log.flags" if incoming line is longer than configured limit #7991
Merged
kvch
merged 16 commits into
elastic:master
from
kvch:feature/filebeat/add-number-of-truncated-bytes-if-too-long
Aug 30, 2018
Merged
Changes from 1 commit
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
5aaadff
provide arbitrary name for tags
kvch e13ab92
add function to add tag to a message
kvch a81626a
add truncated flag in LimitReader
kvch af7c81d
add "truncated" flag to MultilineReader
kvch f8eb9c7
add documentation for log.status
kvch b16cff8
add changelog entry
kvch 84584c5
feed the hound with comments
kvch 03ee796
rename reciever
kvch 496ebe4
fix variable
kvch a01440c
rm debug print
kvch b9aa508
make AddTagsWithKey variadic function
kvch cd0561e
rename d to subMap
kvch 43b8c57
address review notes
kvch da33c4d
feed the hound
kvch 2870f20
add AddTagsWithKey to developer changelog
kvch 5d8cb05
follow up changelog
kvch File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next
Next commit
provide arbitrary name for tags
- Loading branch information
commit 5aaadff36d77a1ef36902111aabe8cb363e22786
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -305,25 +305,38 @@ func MergeFields(ms, fields MapStr, underRoot bool) error { | |
// exist then it will be created. If the tags field exists and is not a []string | ||
// then an error will be returned. It does not deduplicate the list of tags. | ||
func AddTags(ms MapStr, tags []string) error { | ||
return AddTagsWithKey(ms, TagsKey, tags) | ||
} | ||
|
||
// AddTagsWithKey appends a tag to the key field of ms. If the field does not | ||
// exist then it will be created. If the field exists and is not a []string | ||
// then an error will be returned. It does not deduplicate the list. | ||
func AddTagsWithKey(ms MapStr, key string, tags []string) error { | ||
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. Note: I would keep the naming here as 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. Agreed. Done. |
||
if ms == nil || len(tags) == 0 { | ||
return nil | ||
} | ||
eventTags, exists := ms[TagsKey] | ||
if !exists { | ||
ms[TagsKey] = tags | ||
|
||
k, d, oldTags, present, err := mapFind(key, ms, true) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
if !present { | ||
d[k] = tags | ||
return nil | ||
} | ||
|
||
switch arr := eventTags.(type) { | ||
switch arr := oldTags.(type) { | ||
case []string: | ||
ms[TagsKey] = append(arr, tags...) | ||
d[k] = append(arr, tags...) | ||
case []interface{}: | ||
for _, tag := range tags { | ||
arr = append(arr, tag) | ||
} | ||
ms[TagsKey] = arr | ||
d[k] = arr | ||
default: | ||
return errors.Errorf("expected string array by type is %T", eventTags) | ||
return errors.Errorf("expected string array by type is %T", oldTags) | ||
|
||
} | ||
return nil | ||
} | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Could you add a test for the
AddTagsWithKey
method?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.
Done.