EventHandler
db-ally provides an EventHandler abstract class that can be used to log the runs of db-ally to any external systems.
Lifecycle
Every run of db-ally will trigger any instance of EventHandler that was registered using dbally.use_event_handler method in following manner:
EventHandler.request_startis called with RequestStart, it can return a context object that will be passed to next calls.- For each event that occurs during the run,
EventHandler.event_startis called with an Event and the context object returned byEventHandler.request_start. It can return context for the event_end method. - When the event ends
EventHandler.event_endis called with an Event and the context object returned byEventHandler.event_start. - On the end of the run
EventHandler.request_endis called with RequestEnd and the context object returned byEventHandler.request_start.
dbally.audit.event_handlers.EventHandler
Bases: Generic[RequestCtx, EventCtx], ABC
Base event handler interface.
request_start
abstractmethod
async
Log the start of the request.
| PARAMETER | DESCRIPTION |
|---|---|
user_request |
TYPE:
|
| PARAMETER | DESCRIPTION |
|---|---|
user_request |
The start of the request.
TYPE:
|
event_start
abstractmethod
async
Log the start of the event.
| PARAMETER | DESCRIPTION |
|---|---|
event |
TYPE:
|
request_context |
TYPE:
|
| PARAMETER | DESCRIPTION |
|---|---|
event |
Event to be logged.
TYPE:
|
request_context |
Optional context passed from request_start method
TYPE:
|
Source code in src/dbally/audit/event_handlers/base.py
event_end
abstractmethod
async
Log the end of the event.
| PARAMETER | DESCRIPTION |
|---|---|
event |
TYPE:
|
request_context |
TYPE:
|
event_context |
TYPE:
|
| PARAMETER | DESCRIPTION |
|---|---|
event |
Event to be logged.
TYPE:
|
request_context |
Optional context passed from request_start method
TYPE:
|
event_context |
Optional context passed from event_start method
TYPE:
|
Source code in src/dbally/audit/event_handlers/base.py
request_end
abstractmethod
async
Log the end of the request.
| PARAMETER | DESCRIPTION |
|---|---|
output |
TYPE:
|
request_context |
TYPE:
|
| PARAMETER | DESCRIPTION |
|---|---|
output |
The output of the request.
TYPE:
|
request_context |
Optional context passed from request_start method
TYPE:
|