Adding monitoring hooks to the event loop

Using sys.audit to raise the event is probably best. Those are also intended to work like what you suggest, and are already used for collecting execution statistics (though not widely yet… I think DataDog uses/intends to use them).

1 Like