elastic / ecs-logging-python

https://pypi.org/project/ecs-logging
Apache License 2.0
69 stars 26 forks source link

Using orjson for serialization #112

Closed mj0nez closed 5 months ago

mj0nez commented 6 months ago

Hi,

While reading Structlog’s performance guide, I wondered how to integrate orjson with ecs_logging.StructlogFormatter. From what I gathered, the standard library’s json module is used in _utils.json_dumps to provide encoding for both formatters. Would you consider a configurable serializer for this project, to gain some performance? I assume the integration would be pretty straightforward, besides some minor changes in json_dumps and a new optional argument for the formatters’ initializers. If you agree, I would be happy to contribute. :)

xrmx commented 6 months ago

This may be interesting but before making overriding the json serializer a first class citizen I would make it possible for users to provide custom classes inherited from ours. So after making to possible to pass another serializer to json_dumps I'll just move the json_dumps call in StructlogFormatter.__call__ to an internal helper that may be overridden.

thijsmie commented 5 months ago

Hi @xrmx, is there a timeline for the next release? This and another small feature are on my wish list for sure!

xrmx commented 5 months ago

@thijsmie there's no timeline, but we'll cut a new release eventually in the near future