I would like to be able to collect metrics from DataSource pools used in Tomcat via JMX, and I think I have a reasonably good idea of how to do it but I want to get feedback on the idea first.
The first step would be to add some additional metrics gathering in o.a.c.pool. The o.a.c.pool.impl.*Pool classes already expose numIdle and numActive, and I would propose three additional items: peakActive - the peak number of objects borrowed from the pool. Made available through getPeakActive(). totalBorrowed - a counter for how many objects have been borrowed over the life of the pool. Made available through getTotalBorrowed(). totalReturned - a counter for how many objects have been returned over the life of the pool. Made available through getTotalReturned(). Once these values and accessor methods are added to the various *Pool classes, wrapper methods can be added to BasicDataSource to retrieve the underlying values. Thats the easy part... My next concern is how best to make these values available via JMX. Would it be a good idea to create a new DataSource class in o.a.c.dbcp, say InstrumentedBasicDataSource, that implemented the appropriate MBean interface? I'm not sure that implementing an MBean interface in BasicDataSource would be the right thing to do - there is no guarantee that a JMX server instance will be available. This would also require a new DataSourceFactory class and force Tomcat users to specify a different factory in their DataSource configs. My other thought is that maybe the MBean interface should be implemented in Tomcat somehow when the DataSource is created. I'm not sure that's the right thing either (and it would probably be more complicated to do). I'm still thinking this through, but any feedback or ideas would be appreciated... -chris --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
