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

[question] Intercept enter and exit of an action #433

Closed danielmartins closed 5 years ago

danielmartins commented 5 years ago

Hi,

First, thanks to this amazing piece of work. :+1:

Just a question.

Is there a clean way to intercept the enter and exits of actions ?

What I'm trying to do is at some actions I want to generate events like (add some logic like interact with redis or compute some metrics like time elapsed and etc)

itamarst commented 5 years ago

Hi,

I'm currently on vacation, will be back and have more time next week, but:

  1. You can add a custom destination to get notified of start/end (https://eliot.readthedocs.io/en/stable/outputting/output.html)
  2. Your destination would need to match up start/end messages to calculate elapsed time, and pass the newly modified end message to another destination (the JSON output one, say).

That second bit should perhaps be an Eliot feature...

danielmartins commented 5 years ago

Added custom destination worked to me.

Thank you!

Enjoy you vacation.

Again, thanks for share this work, it's very, very useful. I'm using it in a context of serverless(function) computing.