I want to basically add a Request ID to my Yii application so that I can track requests that come from other services and figure out errors that are linked across them.
I want to add an x-request-id header, either extracting it from the incoming requests, or generating a new one if the request did not include one. Then, I want to print this in case of any errors. I see that the error messages in the /runtime/logs/app-errors.log contain some fields like action, action-path, message, so this seems like a good place to put my request-id.
Now, I am basically a newcomer and I don't really know how to assemble the pieces to do this. I could just research all the Yii documentation but it make take a week, only to learn that the solution is just 10 lines of code at the right place.
So, my question for someone more familiar with Yii would be: What would be the outline of such a task? I see something called Behaviours, would these be what I need? I could try to figure out the details myself, but I am not sure what exactly to touch here.
Sorry if my question is too vague!