Open colinsurprenant opened 5 years ago
I have no vested interest in keeping jrjackson in Logstash.
If there is a way to package the ObjectMapper code such that plugins can use it then I'm all for removing JrJackson.
@guyboertje since ObjectMappers
is in logstash-core and plugins depends on logstash-core, it will be "packaged" by default. In the end, this change should only be an implementation change of LogStash::Json.dump
. I believe we'd still leverage JrJackson for deserialization. In that respect, any other direct use of JrJackson (or even JSON#parse/dump
) in plugins should still work (while not desirable, but that's another subject).
My question here is more about the potential benefits/problems in going forward with such a strategy.
Some plugins use the regular JSON gem just because the author didn't know that they can use anything else. Some plugins use JSON for testing. Some plugins serialize into JSON for network transmission (http filter) others deserialize JSON but not necessarily as an Event representation. We should consider the implications of people creating Ruby filter code that uses JSON de/ser.
When we introduced LogStash::Json
we went through all plugins to simply change the JSON
usage to LogStash::Json
. Ideally we should continue fixing plugin which still uses JSON
. There is no need nor benefits in using JSON
, that was the whole point of introducing LogStash::Json
; to have a single JSON serializer/deserializer throughout the whole logstash ecosystem. The idea here is that the LogStash::Json
implementation can be changed and all will benefit. My suggestion here is to consider changing that implementation to use the ObjectMappers
strategy instead of JrJackson if it proves to be more efficient.
Hello, i suppose this changes may be beneficial for #13253 is there any update on the matter?
We currently use 2 different ways to do JSON serialization:
LogStash::Json.dump
ObjectMappers
forEvent.toJson()
We've witnessed problems where both methods resulted in different behaviours for example with this known bignum problem #10720
I suggest we unify the way we do serialization. From the Event POV we rely on the internal Ruby/Java type mapping and our use of Jackson leverages the "Java" types view over the data. But from a Ruby plugin POV, serializing a Ruby object goes through JrJackson own type converters.
We should probably run some benchmarks over both methods and pick one. I am uder the impression that our
ObjectMappers
methods is problably more efficient.