It should be possible to hook into the library to run some code before or after processors. One nice way to do it would be similar to python decorators, by essentially wrapping the processor in a new function.
Sample Usage
def my_hook(processor: Processor):
start = time.time_ns()
processor() # The hook needs to run the processor
end = time.time_ns()
print(f"The processor {processor.name} took {end - start}ns to run")
Use-Cases
- Collect metrics
- Monitoring for failures
- Standardized logging
- Observability (opentelemetry)
- Escape hatch to support extending event-processor in otherwise unsupported ways
- Dynamically decide to abort calling a processor
- etc.
Caveats
- How are processor dependencies resolved with this system? Should we use
functools.partial to make sure the hooks don't need to deal with them?
- Does this really fit into the current project architecture? Would re-architecting the project be beneficial to other features as well?
It should be possible to hook into the library to run some code before or after processors. One nice way to do it would be similar to python decorators, by essentially wrapping the processor in a new function.
Sample Usage
Use-Cases
Caveats
functools.partialto make sure the hooks don't need to deal with them?