Support basic events for connection and commands.
Is your feature request related to a problem? Please describe. I would like to instrument my application. It uses redis and predis heavily with cache, mutexes and pub/sub. I would like to add instrumentation like new relic or sentry traces. I would like to know how long it takes to connect and to send specific commands. To achieve this it would be great if I could add psr compatible event dispatcher to predis. Then, when specific events occur I could add instrumentation in the event handler.
Describe the solution you'd like
- add new client option: 'event_dispatcher'
- add a call to event_dispatcher::dispatch() to connect/disconnect
- add a call to event_dispatcher::dispatch() to __call before and after executing a command to handle most of the commands
- add a call to event_dispatcher::dispatch() executeCommand, transaction, pipeline and onErrorResponse to handle rest of the commands.
Describe alternatives you've considered Manually wrapping every command but that would be cumbersome and would take a lot of time.
I would be willing to try to implement this if the team is open for this.
Source: predis/predis