ecs-logging-python icon indicating copy to clipboard operation
ecs-logging-python copied to clipboard

Using orjson for serialization

Open mj0nez opened this issue 1 year ago • 1 comments

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. :)

mj0nez avatar May 09 '24 13:05 mj0nez

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.

xrmx avatar May 10 '24 08:05 xrmx

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

thijsmie avatar Jun 11 '24 07:06 thijsmie

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

xrmx avatar Jun 13 '24 08:06 xrmx