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

Do not update event in parallel #1428

Merged
merged 1 commit into from
Apr 20, 2016
Merged

Conversation

urso
Copy link

@urso urso commented Apr 19, 2016

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

buf.Write(tmp)

buf.WriteString(`,"beat":`)
buf.Write(beat)
Copy link
Contributor

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.

Copy link
Author

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

@tsg tsg added needs_backport PR is waiting to be backported to other branches. v1.2.2 labels Apr 20, 2016
@@ -285,6 +295,49 @@ func (p *protocol) serializeDataFrame(
return nil
}

func serializeEvent(event common.MapStr, beat []byte) ([]byte, error) {
Copy link
Contributor

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.

Copy link
Author

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.

@tsg
Copy link
Contributor

tsg commented Apr 20, 2016

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?

@tsg
Copy link
Contributor

tsg commented Apr 20, 2016

LGTM. Can you add a changelog item?

@urso
Copy link
Author

urso commented Apr 20, 2016

I guess long term we'll have a proper Event type and we can add locking or immutability to it, right?

That's exactly what I have had in mind when doing the fix.

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
@tsg tsg merged commit 4e2223e into elastic:master Apr 20, 2016
@tsg tsg removed the needs_backport PR is waiting to be backported to other branches. label May 9, 2016
@urso urso deleted the fix/1410-race-json-nil branch May 30, 2016 12:06
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