New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Keep a copy of triggered event names for better debugging #13594
Conversation
Sometimes you are in a method that can be triggered through many different events and you want to know which event triggered the method or which events happened before this as the event might be triggered by another event etc. Not keeping any params re possible memory issues. Might be even useful to log like the last X occurred events in some places on top of a backtrace or so... (be something maybe for another PR)
Is this needed because we don't have access to the event name in a shared event handler? Like in this example:
? Or are there other reasons (or maybe this isn't a reason)? |
yes for example this. sometimes there might be also APIs that call other APIs that call other APIs and you want to get a trace of how we ended up there to understand what happened. Eg in a |
For the first case, would it be simpler to just have separate event handlers? For the other use case, would a backtrace work too? Eg Think this could be useful for fatal error emails, but if we save our logs (to eg, cloudwatch or on a server), you could simply look up the logs for the request in either case. Eg, we could log in EventDispatcher and the event handlers (or maybe just in EventDispatcher like |
Backtrace wouldn't be too helpful as it contains too much info and is not needed in this case. In my case the event handlers give a very good summary of what happened in the system to lead up to this point. Separate handlers is not really possible in this case. Eg think of |
Couldn't you just have a log in EventDispatcher like:
? You wouldn't need to save and later process the events in memory in this case, you would just need to look at the logs. And you would be able to see what events are triggered (ie EDIT: this just seems like a simpler solution than saving the event names and printing them somewhere else, and would give insight into all requests not just the requests that end up using that specific method. |
In In my case, when something specific happens, I need to log this info to a specific place, eg to Eg it allows me to and I can see the top reasons why some specific error or event occurred, including the last 3 or 5 events that occurred before that. like
|
Could always log as info, default the logger to NullLogger, then supply a special logger through DI that sends it to error_log(). Or something along those lines.
Perhaps it might be a good idea to look into something like cloudwatch/sumologic/etc. To me memory usage isn't really the issue, and I can see that it could be useful, but you can get the same thing from just logging (if you can get the request ID for the request you are looking for more info for, then grep for those logs then grep for the event log message, you'd get the same info). This just seems like unneeded code. |
Could also wrap EventDispatcher through DI so this code isn't in core. |
I'll just close the PR. Getting bit too complicated. I'll log the messages in my plugin without any extra info. |
Sometimes you are in a method that can be triggered through many different events and you want to know which event triggered the method or which events happened before this as the event might be triggered by another event etc. Not keeping any params re possible memory issues.
Might be even useful to log like the last X occurred events in some places on top of a backtrace or so... (be something maybe for another PR). Refs DEV-1456