Adding code to elasticsearch source

Hi, Iam new to elasticsearch source code. My idea is to add a log with timestamp to a log index, whenever a query fired and update it with end timestamp, when the query delivers results. So that i can run a search on log index and find all the currently running queries on elasticsearch. Where can i add this functionality in elasticsearch source. Can anyone please guide me through this.