Creating a slow operation log for OpenDS
For anyone that has spent much time looking at MySQL performance, you will be familiar with the ‘slow query log’. This basically is a log where queries that took over some amount of time would get recorded. For kicks, I tried implementing a similar hook for OpenDS. My current version is in pretty rough shape (not very efficient or configurable), but seems to work. I started from a copy of the TextAccessLogPublisher.java file and created a new one called TextSlowAccessLogPublisher.java. My logic is basically:
- create a hash table
- emptied out all the log XYZIntermediateMessage and connect/disconnect methods
- when a request comes in, store the text to log in the hash table (keyed off connectionID and opNumber) instead of outputting it (changed the logSearchRequest, logModifyRequest, … methods)
- when a request is finished processing, we check the elapsed time (etime)
- if the elapsed time greater than our or equal to our threshold
- print the request info we stashed in the hash table and delete it
- print the response info
- if the elapsed time is less than our threshold
- delete the request info from the hash table, don’t print anything
- if the elapsed time greater than our or equal to our threshold
There are a few more things I want to do:
- Make the ‘slow operation threshold time’ dynamically changeable (looks like I will need to mess with configuration objects since I want to add an additional parameter not in the standard access log type)
- Add extra information to the output format such as authorization DN (and potentially client connection info if not too hard to retrieve)
- Instead of all the text formatting for every request, just put the Operation object into the hash table, since the majority of operations won’t ever get printed we shouldn’t burn CPU formatting them. The operations would only be formatted to text if the operations end up being slow and printed.
Files
- TextSlowAccessLogPublisher.java (currently quick-n-dirty quality)
- LDIF to enable the slow query log
Tags: opends