Instrumenting same wrapper classes of JDBC and DBCP may lead to duplicated metric counts.

book

Article ID: 124981

calendar_today

Updated On:

Products

CA Application Performance Management Agent (APM / Wily / Introscope) INTROSCOPE

Issue/Introduction

The value of SQL count duplicates when instrumenting DBCP with standard Java using Java application.

Environment

Release:


Component:

Resolution

APM agent instruments JDBC driver classes to get the metric information(like OracleConnection, OracleStatement and OracleResultSet).
DBCP uses wrapper classes on top of core JDBC classes like DelegatingStatement, DelegatingConnection, and DelegatingResultSet.
So, when instrumenting with DBCP, the number of metrics may be duplicated.

For this reason, when instrumenting DBCP please add the following SkipClass to sqlagent.pbd.
-------------------------------------------------------------------
SkipClass: org.apache.commons.dbcp.DelegatingConnection
SkipClass: org.apache.commons.dbcp.DelegatingResultSet
SkipClass: org.apache.commons.dbcp.DelegatingStatement
SkipClass: org.apache.commons.dbcp.DelegatingCallableStatement
SkipClass: org.apache.commons.dbcp.DelegatingPreparedStatement
SkipClass: org.apache.commons.dbcp2.DelegatingConnection
SkipClass: org.apache.commons.dbcp2.DelegatingResultSet
SkipClass: org.apache.commons.dbcp2.DelegatingStatement
SkipClass: org.apache.commons.dbcp2.DelegatingCallableStatement
SkipClass: org.apache.commons.dbcp2.DelegatingPreparedStatement 
-------------------------------------------------------------------
#Above classes are DBCP third-party classes. these classes are wrapper classes on actual SQL Connection, Statement and Resultset classes(JDBC driver specific).

Agent won't miss any metrics since agent instruments actual JDBC classes to get the metrics.

Additional Information

Comparison example between JDBC and DBCP.
JDBC:
oracle.jdbc.OracleConnection (implements java.sql.Connection)
oracle.jdbc.OracleResultSet (implements java.sql.ResultSet)
oracle.jdbc.OracleStatement (implements java.sql.Statement)
oracle.jdbc.OracleCallableStatement (also extends java.sql.CallableStatement)
    #OracleCallableStatement is the Subinterfaces of OracleStatement.
oracle.jdbc.OraclePreparedStatement (also extends java.sql.PreparedStatement)
    #OraclePreparedStatement is the Subinterfaces of OracleStatement.

DBCP:
org.apache.commons.dbcp.DelegatingConnection (implements java.sql.Connection)
org.apache.commons.dbcp.DelegatingResultSet (implements java.sql.ResultSet)
org.apache.commons.dbcp.DelegatingStatement (implements java.sql.Statement)
org.apache.commons.dbcp.DelegatingCallableStatement(implements java.sql.CallableStatement)
    #DelegatingCallableStatement is the Subinterfaces of DelegatingStatement.
org.apache.commons.dbcp.DelegatingPreparedStatement(implements java.sql.PreparedStatement)
    #DelegatingPreparedStatement is the Subinterfaces of DelegatingStatement.