Skip to content
This repository has been archived by the owner on Feb 20, 2023. It is now read-only.

Commit

Permalink
Allow monitoring of DruidDataSource
Browse files Browse the repository at this point in the history
By using P6DataSource without using byte code manipulation

(closes #201)
  • Loading branch information
Felix Barnsteiner committed Sep 22, 2016
1 parent ad27a95 commit db47d0a
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
3 changes: 2 additions & 1 deletion stagemonitor-jdbc/build.gradle
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
dependencies {
compile project(":stagemonitor-requestmonitor")
compile 'p6spy:p6spy:3.0.0-alpha-1'
compile 'p6spy:p6spy:3.0.0-rc2'

testCompile 'org.apache.tomcat:tomcat-jdbc:8.5.0'
testCompile 'org.hsqldb:hsqldb:2.3.3'
testCompile 'com.mchange:c3p0:0.9.5.2'
testCompile 'com.zaxxer:HikariCP:2.4.6'
testCompile 'org.apache.commons:commons-dbcp2:2.1.1'
testCompile 'commons-dbcp:commons-dbcp:1.4'
testCompile 'com.alibaba:druid:1.0.26'
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
org.stagemonitor.jdbc.StagemonitorJdbcEventListener
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
package org.stagemonitor.jdbc;

import com.alibaba.druid.pool.DruidDataSource;
import com.codahale.metrics.MetricFilter;
import com.codahale.metrics.Timer;
import com.mchange.v2.c3p0.ComboPooledDataSource;
import com.p6spy.engine.spy.P6DataSource;
import com.zaxxer.hikari.HikariDataSource;

import org.apache.tomcat.jdbc.pool.PoolProperties;
Expand Down Expand Up @@ -73,7 +75,12 @@ public static Iterable<Object[]> data() throws Exception {
dbcp2.setDriverClassName(DRIVER_CLASS_NAME);
dbcp2.setUrl(URL);

return Arrays.asList(new Object[][]{{tomcatDataSource}, {comboPooledDataSource}, {hikariDataSource}, {dbcp}, {dbcp2}});
DruidDataSource druidDataSource = new DruidDataSource();
druidDataSource.setDriverClassName(DRIVER_CLASS_NAME);
druidDataSource.setUrl(URL);
druidDataSource.setTestWhileIdle(false);

return Arrays.asList(new Object[][]{{tomcatDataSource}, {comboPooledDataSource}, {hikariDataSource}, {dbcp}, {dbcp2}, {new P6DataSource(druidDataSource)}});
}

public ConnectionMonitoringTransformerTest(DataSource dataSource) {
Expand Down Expand Up @@ -107,6 +114,10 @@ public static void cleanUp() {

@Test
public void monitorGetConnection() throws Exception {
if (dataSource instanceof P6DataSource) {
// connection monitoring is not available
return;
}
requestMonitor
.monitor(new MonitoredMethodRequest(configuration, "monitorGetConnectionUsernamePassword()", new MonitoredMethodRequest.MethodExecution() {
@Override
Expand Down

0 comments on commit db47d0a

Please sign in to comment.