itamarst / eliot

Eliot: the logging system that tells you *why* it happened
https://eliot.readthedocs.io
Apache License 2.0
1.1k stars 66 forks source link

New message writing API, designed for performance #407

Closed itamarst closed 4 years ago

itamarst commented 5 years ago

The current abstraction is Action creates a Message, and the Message generates the dict to pass to the destination.

This adds a bunch of overhead (e.g. the Message has code to look up the current Action even when it was created by the Action!) and in general it's not clear that having a first-class Message abstraction is useful. E.g. only Message.bind() makes having a class at all relevant, and it's not clear anyone uses that.

So:

  1. Prototype and benchmark adding .log() method as an alternative (there would also be a standalone logging function similar to what Message.log does where it doesn't have to be in Action context, for use in e.g. logging bridges or other code where there isn't necessarily current action).
  2. If it's faster, implement and deprecate Message class.
itamarst commented 5 years ago

API would look like:

with start_action(action_type="myaction") as ctx:
    ctx.log(message_type="mymessage")

Experiment in the relevant branch suggests this is indeed faster.

itamarst commented 4 years ago

Remaining work: