elastic / logstash

Logstash - transport and process your logs, events, or other data
https://www.elastic.co/products/logstash
Other
113 stars 3.51k forks source link

[Plugin design] Streamline event submission by an input plugin #2447

Open wiibaa opened 9 years ago

wiibaa commented 9 years ago

Currently all input plugins contains more or less the following lines

event["host"] = @host # from Socket.gethostname
decorate(event)
[...]   
queue << event

decorate is handling the add_field/add_tag and with #2390 it could use sprintf syntax and already manipulate event fields set by the input plugin, so it should be enforced that decorate() is called after the event is filled by the specific input.

The idea would be to DRY this into inputs/base.rb, it would avoid plugin implementor to forget or misplace the call to decorate()

Thoughts ?

Here is the list of inputs not complying with the proposed rule

jsvd commented 8 years ago

the only way I see this done is by changing the api to add events to the queue (usually queue << event) to a method like publish(event) that does:

def publish(event)
  decorate(event)
  @queue << event
end

that said we're planning some changes on the pipeline and queue persistence which will likely change this behaviour. So until then let's keep this open but table this.