elastic / elastic/logstash

write developers doc or blog about Event initialization in codecs/input plugins

Open
#3,150 0 comments 0 reactions 1 assignee Claimed by @colinsurprenant View on GitHub
developer docs
Dominant language
Java
Stars
14.9k
Forks
3.5k
Avg merge
19h 14m
Merged PRs (30d)
63

Description

I want to document for developers the different strategies when initializing/building a new `LogStash::Event`. This usually happens in a codec `decode` method but codec-less input plugins can also do that.

There are basically 2 ways:
- using the event field-reference syntax, for example:

``` ruby
event = LogStash::Event.new
event["[foo][bar]"] = "baz"
```
- using a hash

``` ruby
data = {
"foo" => {
"bar" => "baz"
}
}
event = LogStash::Event(data)
```

A quick benchmark for this shows that using a hash is more than twice as fast as using the field-reference syntax which is really meant for event manipulation from the logstash config.

The reason for this is that there is extra logic required to parse the field reference string as opposed to directly manipulating a `Hash`.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.