logstash icon indicating copy to clipboard operation
logstash copied to clipboard

Invalid documentation on event.set() in Event API

Open monoidic opened this issue 2 years ago • 0 comments

Tell us about the issue

Description:
While the documentation for the Event API seems to claim that event.set(key, value) returns the event, allowing for chainable calls like event.set(key1, value1).set(key2, value2).set(key3, value3), in reality, the value of the field which was set is returned (i.e value for event.set(key, value)). Excerpt from the documentation:

Returns: The current Event after the mutation, which can be used for chainable calls.

This is also evident from the code, with the method argument value being unmodified and returned in the only return statement:

https://github.com/elastic/logstash/blob/68c753439dd9c365fd8fba56f972b8c907bdd1e8/logstash-core/src/main/java/org/logstash/ext/JrubyEventExtLibrary.java#L117-L128

URL: https://www.elastic.co/guide/en/logstash/current/event-api.html

Anything else?

monoidic avatar Jun 01 '22 08:06 monoidic