Skip to content
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

Make @metadata accessible via beat.Event accessor methods #10761

Merged

Conversation

andrewkroh
Copy link
Member

@andrewkroh andrewkroh commented Feb 14, 2019

This implements a TODO from the beat.Event struct that makes it possible to put/get/delete
@metadata values via the accessor methods.

This implements a TODO from the beat.Event struct that makes it possible to put/get/delete
@metadata values via the accessor methods.
@andrewkroh andrewkroh force-pushed the feature/libbeat/beat-event-metadata branch from 3454bb8 to dc5a091 Compare February 20, 2019 14:21
@andrewkroh andrewkroh requested review from ph and kvch February 20, 2019 15:14
return e.Fields.Delete(key)
}

func metadataKey(key string) (string, bool) {
if !strings.HasPrefix(key, "@metadata") {
Copy link
Contributor

@kvch kvch Feb 20, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am wondering if it would be safer to check for "@metadata."? What if an event includes the key "@metadata2.keyname and wants to delete @metadata2? If I understand correctly so far, it means that Meta gets deleted.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added a test case to show that Delete(@metadataSpecial) doesn't cause Meta to be deleted.

The reason it checks for @metadata is to allow for operations like Put(@metadata, map[string]interface{}{x: y}) and Get(@metadata). When it finds that @metadata as the prefix it then checks to see if the next character is a . so in effect it is checking for @metadata..

@andrewkroh andrewkroh merged commit 2b7d9fe into elastic:master Feb 20, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants