soulgalore / jdbcmetrics

Get information from your JDBC driver.
39 stars 12 forks source link

Support multiple datasources #27

Open larrys opened 10 years ago

larrys commented 10 years ago

I have multiple datasources configured like so (in Tomcat)

<Resource
  name="jdbc/oneDS"
  auth="Container"
  type="javax.sql.DataSource"
  username="one"
  password="password"
  driverClassName="com.soulgalore.jdbcmetrics.Driver"
  url="jdbc:jdbcmetrics?driver=oracle.jdbc.OracleDriver:oracle:thin:@CONNECTSTRING"
  maxActive="20"
  maxIdle="4"
  maxWait="60000"
  validationQuery="select 1 from dual"
  connectionProperties="SetBigStringTryClob=true"
  removeAbandoned="true"
  removeAbandonedTimeout="300"
  logAbandoned="true"
/>

<Resource
  name="jdbc/twoDS"
  auth="Container"
  type="javax.sql.DataSource"
  username="two"
  password="password"
  driverClassName="com.soulgalore.jdbcmetrics.Driver"
  url="jdbc:jdbcmetrics?driver=oracle.jdbc.OracleDriver:oracle:thin:@CONNECTSTRING"
  maxActive="20"
  maxIdle="4"
  maxWait="60000"
  validationQuery="select 1 from dual"
  connectionProperties="SetBigStringTryClob=true"
  removeAbandoned="true"
  removeAbandonedTimeout="300"
  logAbandoned="true"
/>

How would I segregate the two datasources? Currently they both will show up in the same.

soulgalore commented 10 years ago

Guess we need to do some changes, @mlundberg any input?

larrys commented 10 years ago

If I were to suggest a method, with my way of configuring it, the DriverManager method according to the docs, another parameter in the jdbcmetrics part of the JDBC url might be the best, much like driver parameter. This way it is not specific to any implementation, such as configuring it for Tomcat, like my example.

For the DataSource method, calculating it based off the name of the datasource might be one way to go. Or make it another (optional) parameter in configuring it.

mlundberg commented 10 years ago

Yes, this is a great idea, and a must have I think. I will start looking at it. @soulgalore do you think we should keep a total counter, the one we are using now and add the others (or just separate them)? Another approach would be to configure which counters the datasources should add to? In that way you could group datasource counters how you want.

soulgalore commented 10 years ago

@larrys thanks for the input!

@mlundberg want to keep the config to the minimum or how do you think? I think the ones we have now is still valid, to get information for a whole application and to see how one page/URL is doing. Or how do you see it?

larrys commented 10 years ago

I could go either way on the total counter, since with graphite (which is what I'm using), you can easily aggregate the combination of metrics you want. Of course, having total counter would be better for those who lack the ability to easily aggregate the data. As long as the config for it is not too cumbersome, but flexible enough to suite needs of the users.