Giter Site home page Giter Site logo

itamarst / eliot Goto Github PK

View Code? Open in Web Editor NEW
1.1K 39.0 66.0 1.97 MB

Eliot: the logging system that tells you *why* it happened

Home Page: https://eliot.readthedocs.io

License: Apache License 2.0

Python 96.94% HTML 1.68% JavaScript 1.38% Emacs Lisp 0.01%
python logging logging-library tracing causality causality-analysis causation twisted journald elasticsearch

eliot's Introduction

Eliot: Logging that tells you why it happened

Python's built-in logging and other similar systems output a stream of factoids: they're interesting, but you can't really tell what's going on.

  • Why is your application slow?
  • What caused this code path to be chosen?
  • Why did this error happen?

Standard logging can't answer these questions.

But with a better model you could understand what and why things happened in your application. You could pinpoint performance bottlenecks, you could understand what happened when, who called what.

That is what Eliot does. eliot is a Python logging system that outputs causal chains of actions: actions can spawn other actions, and eventually they either succeed or fail. The resulting logs tell you the story of what your software did: what happened, and what caused it.

Eliot supports a range of use cases and 3rd party libraries:

Eliot is only used to generate your logs; you will might need tools like Logstash and ElasticSearch to aggregate and store logs if you are using multiple processes across multiple machines.

Eliot supports Python 3.8-3.12, as well as PyPy3. It is maintained by Itamar Turner-Trauring, and released under the Apache 2.0 License.

Testimonials

"Eliot has made tracking down causes of failure (in complex external integrations and internal uses) tremendously easier. Our errors are logged to Sentry with the Eliot task UUID. That means we can go from a Sentry notification to a high-level trace of operations—with important metadata at each operation—in a few seconds. We immediately know which user did what in which part of the system."

—Jonathan Jacobs

eliot's People

Contributors

alextatarinov avatar cdunklau avatar danigm avatar exarkun avatar itamarst avatar jml avatar jonathanj avatar kalekundert avatar pythonspeed avatar robhaswell avatar timgates42 avatar tomprince avatar veloutin avatar wallrj avatar wjcferguson avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

eliot's Issues

Add helper for nested actions in Eliot

(Originally from Jean-Paul Calderone).

Here's a pattern I just stumbled back in to:

def receive(self, input):
    """                                                                                                                                       
    Add logging of state transitions to the wrapped state machine.                                                                            

    @see: L{IFiniteStateMachine.receive}                                                                                                      
    """
    def _():
        action = LOG_FSM_TRANSITION(
            self.logger,
            fsm_state=unicode(self.state), fsm_input=unicode(input))
        with action as theAction:
            output = super(_FiniteStateLogger, self).receive(input)
            theAction.addSuccessFields(
                fsm_next_state=unicode(self.state), fsm_output=unicode(output))
        return output
    return self._action.run(_)

(reminds me of Axiom programming).

It would be nice to be able to avoid the nested function when achieving this.

There could be a decorator that runs a whole function in the context of some action (eg @partOfAction(attributeNamingAction) or a context manager with self.actionAttribute.resume():

Error message in assertHasMessage is uninformative

twisted.trial.unittest.FailTest: No messages of type <eliot._validation.MessageType object at 0x2bb2990> isn't actually useful. Should be using the message_type/action_type value instead of class... or maybe define repr on MessageType and ActionType.

README improvements

  • Make clear that Twisted support is available but optional
  • Better explanation of what it does.
  • Note additional features.

Get incident identifier from current Eliot logging context

(Originally from Jean-Paul Calderone).

When a user triggers something interesting getting logged, we may want to be able to find that interesting thing easily later. One approach is to given the user a token that they can give back to us to find the relevent log area. Call this an "incident identifier".

It's possible to construct one of these for an eliot action but only by using private attributes.

Make unit testing validate *all* log messages

Right now it only validates some messages, those whose Logger gets overridden.

So, change testing infrastructure to work via adding a destination, rather than monkeypatching a MemoryLogger.

Add explicit way to finish an Action

This allows code that wants to catch exceptions itself, for example, to end an action without having to do wierd stuff.

The context manager in Action should check on exit whether action is already finished, and only do so itself if it's not already finished.

LoggedMessage.ofType doesn't work with LoggedAction.children

(Originally by Tom Prince).

I naively tried to do

action = LoggedAction.ofType(....)
message = LoggedMessage.ofType(action.children, SOME_MESSAGE)[0]

which blows up. This seems like a reasonable thing to want to do, and there doesn't seem to be a way of doing this. (Although perhaps not with exactly the code I wrote).

Don't force tai64n in message output

tai64n is nice and fast, but maybe not be to the liking of all users. We shouldn't require it, just like we shouldn't require JSON.

In particular, just include seconds since epoch (see comments) since that is the information, and the destinations can encode as they wish. Also will need to change eliot.filter to not assume anything special about timestamp field, since it's not guaranteed to be in any particular format anymore.

Python 3.4 support

Mostly just adding to README and tox setup and making sure everything works.

Default values for Eliot types

If we supported default values for Fields in eliot, one could omit fields that were just going to get default values.

We might also be able to get rid of Field.forTypes, replacing it with Field.forTypes, since optional None value seems to be the main use case.

Get rid of extra fields in Action failure case

Failures can happen for a wide variety of reasons in different places in the code; it's unreasonable to expect a consistent set of result fields. Users can always report more data with extra messages.

API for validating dict fields

Currently there is explicit support for having fields whose values are dicts. But that only validates that the field is a dict. It doesn't make any assertion about the contents of that dict.

There are libraries for this so maybe just link in docs.

Release 0.4.0

  1. Update version number.
  2. Change README to remove warning.
  3. Upload to PyPI.
  4. Update Read The Docs.

Abstraction for inspecting (and possibly creating) Eliot task levels

Eliot has a concept of task levels, e.g. "1/2/1/". Right now they are created, and in eliot.testing parsed, as strings. It might be nice to have an abstraction for dealing with them (the parsing code is ugly) and perhaps for generating them as well. The latter may have a performance impact, though.

Let a single Message Field be serialized into multiple fields

(Originally requested by Jean-Paul Calderone).

For example, I want to log a BucketWeight instance. This knows the name of the bucket to which it pertains as well as some other information. I want to write:

LOG_WEIGHT_UPDATE(weight=self)

But I can't write a serializer that will add a "bucket" key to the top-level serialized json blob. To accomplish that I have to write:

LOG_WEIGHT_UPDATE(bucket=self.bucket, weight=self)

I want a bucket top-level key because that's a very common way to filter log events. I want the serializer to do it because it's a pain to have to manually break out one of the fields.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.