-
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
Do not update event in parallel #1428
Conversation
buf.Write(tmp) | ||
|
||
buf.WriteString(`,"beat":`) | ||
buf.Write(beat) |
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.
Shouldn't this also be passed through json.Marshal
or otherwise escaped? We have to be careful with JSON injection if we're doing this by hand.
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.
json.Marshal is done line 62. Didn't want to marshal over and over again
@@ -285,6 +295,49 @@ func (p *protocol) serializeDataFrame( | |||
return nil | |||
} | |||
|
|||
func serializeEvent(event common.MapStr, beat []byte) ([]byte, error) { |
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.
Some unit tests for this function would be good.
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.
it's tested (block-box testing sendEvents), as we've got some logstash unit tests forwarding events via sendEvents with server part decoding json messages for validation.
This looks to me like a good solution for the bug we have now, I guess long term we'll have a proper Event type and we can add locking or immutability to it, right? |
LGTM. Can you add a changelog item? |
That's exactly what I have had in mind when doing the fix. |
b266a37
to
35163ae
Compare
logstash output used to add metadata to an event. With potentially having
multiple outputs configured this is some bad practice. Instead the logstash
output plugin will add '@metadata' to the event when encoding and only if
'@metadata' is not already present in event
Resolves #1410