Search in sources :

Example 1 with PreparedStatementBindingMethodFilter

use of com.navercorp.pinpoint.bootstrap.plugin.jdbc.PreparedStatementBindingMethodFilter in project pinpoint by naver.

the class MariaDBPlugin method addPreparedStatementBindVariableTransformer.

private void addPreparedStatementBindVariableTransformer(final MariaDBConfig config) {
    TransformCallback transformer = new TransformCallback() {

        @Override
        public byte[] doInTransform(Instrumentor instrumentor, ClassLoader loader, String className, Class<?> classBeingRedefined, ProtectionDomain protectionDomain, byte[] classfileBuffer) throws InstrumentException {
            InstrumentClass target = instrumentor.getInstrumentClass(loader, className, classfileBuffer);
            target.addField("com.navercorp.pinpoint.bootstrap.plugin.jdbc.DatabaseInfoAccessor");
            target.addField("com.navercorp.pinpoint.bootstrap.plugin.jdbc.ParsingResultAccessor");
            target.addField("com.navercorp.pinpoint.bootstrap.plugin.jdbc.BindValueAccessor");
            if (config.isTraceSqlBindValue()) {
                final PreparedStatementBindingMethodFilter excludes = PreparedStatementBindingMethodFilter.excludes("setRowId", "setNClob", "setSQLXML");
                target.addScopedInterceptor(excludes, "com.navercorp.pinpoint.bootstrap.plugin.jdbc.interceptor.PreparedStatementBindVariableInterceptor", MariaDBConstants.MARIADB_SCOPE, ExecutionPolicy.BOUNDARY);
            }
            return target.toBytecode();
        }
    };
    transformTemplate.transform("org.mariadb.jdbc.AbstractMariaDbPrepareStatement", transformer);
    // Class renamed in 1.5.6 - https://github.com/MariaDB/mariadb-connector-j/commit/16c8313960cf4fbc6b2b83136504d1ba9e662919
    transformTemplate.transform("org.mariadb.jdbc.AbstractPrepareStatement", transformer);
}
Also used : ProtectionDomain(java.security.ProtectionDomain) Instrumentor(com.navercorp.pinpoint.bootstrap.instrument.Instrumentor) PreparedStatementBindingMethodFilter(com.navercorp.pinpoint.bootstrap.plugin.jdbc.PreparedStatementBindingMethodFilter) InstrumentClass(com.navercorp.pinpoint.bootstrap.instrument.InstrumentClass) TransformCallback(com.navercorp.pinpoint.bootstrap.instrument.transformer.TransformCallback) InstrumentClass(com.navercorp.pinpoint.bootstrap.instrument.InstrumentClass)

Example 2 with PreparedStatementBindingMethodFilter

use of com.navercorp.pinpoint.bootstrap.plugin.jdbc.PreparedStatementBindingMethodFilter in project pinpoint by naver.

the class PostgreSqlPlugin method addPreparedStatementTransformer.

private void addPreparedStatementTransformer(final PostgreSqlConfig config) {
    transformTemplate.transform("org.postgresql.jdbc2.AbstractJdbc2Statement", new TransformCallback() {

        @Override
        public byte[] doInTransform(Instrumentor instrumentor, ClassLoader loader, String className, Class<?> classBeingRedefined, ProtectionDomain protectionDomain, byte[] classfileBuffer) throws InstrumentException {
            InstrumentClass target = instrumentor.getInstrumentClass(loader, className, classfileBuffer);
            target.addField("com.navercorp.pinpoint.bootstrap.plugin.jdbc.DatabaseInfoAccessor");
            target.addField("com.navercorp.pinpoint.bootstrap.plugin.jdbc.ParsingResultAccessor");
            target.addField("com.navercorp.pinpoint.bootstrap.plugin.jdbc.BindValueAccessor");
            int maxBindValueSize = config.getMaxSqlBindValueSize();
            target.addScopedInterceptor("com.navercorp.pinpoint.bootstrap.plugin.jdbc.interceptor.PreparedStatementExecuteQueryInterceptor", va(maxBindValueSize), PostgreSqlConstants.POSTGRESQL_SCOPE);
            return target.toBytecode();
        }
    });
    transformTemplate.transform("org.postgresql.jdbc3.AbstractJdbc3Statement", new TransformCallback() {

        @Override
        public byte[] doInTransform(Instrumentor instrumentor, ClassLoader loader, String className, Class<?> classBeingRedefined, ProtectionDomain protectionDomain, byte[] classfileBuffer) throws InstrumentException {
            InstrumentClass target = instrumentor.getInstrumentClass(loader, className, classfileBuffer);
            target.addField("com.navercorp.pinpoint.bootstrap.plugin.jdbc.DatabaseInfoAccessor");
            target.addField("com.navercorp.pinpoint.bootstrap.plugin.jdbc.ParsingResultAccessor");
            target.addField("com.navercorp.pinpoint.bootstrap.plugin.jdbc.BindValueAccessor");
            final PreparedStatementBindingMethodFilter excludes = PreparedStatementBindingMethodFilter.excludes("setRowId", "setNClob", "setSQLXML");
            target.addScopedInterceptor(excludes, "com.navercorp.pinpoint.bootstrap.plugin.jdbc.interceptor.PreparedStatementBindVariableInterceptor", PostgreSqlConstants.POSTGRESQL_SCOPE, ExecutionPolicy.BOUNDARY);
            target.addScopedInterceptor("com.navercorp.pinpoint.bootstrap.plugin.jdbc.interceptor.StatementExecuteQueryInterceptor", PostgreSqlConstants.POSTGRESQL_SCOPE);
            target.addScopedInterceptor("com.navercorp.pinpoint.bootstrap.plugin.jdbc.interceptor.StatementExecuteUpdateInterceptor", PostgreSqlConstants.POSTGRESQL_SCOPE);
            return target.toBytecode();
        }
    });
}
Also used : ProtectionDomain(java.security.ProtectionDomain) InstrumentException(com.navercorp.pinpoint.bootstrap.instrument.InstrumentException) Instrumentor(com.navercorp.pinpoint.bootstrap.instrument.Instrumentor) PreparedStatementBindingMethodFilter(com.navercorp.pinpoint.bootstrap.plugin.jdbc.PreparedStatementBindingMethodFilter) TransformCallback(com.navercorp.pinpoint.bootstrap.instrument.transformer.TransformCallback) InstrumentClass(com.navercorp.pinpoint.bootstrap.instrument.InstrumentClass)

Aggregations

InstrumentClass (com.navercorp.pinpoint.bootstrap.instrument.InstrumentClass)2 Instrumentor (com.navercorp.pinpoint.bootstrap.instrument.Instrumentor)2 TransformCallback (com.navercorp.pinpoint.bootstrap.instrument.transformer.TransformCallback)2 PreparedStatementBindingMethodFilter (com.navercorp.pinpoint.bootstrap.plugin.jdbc.PreparedStatementBindingMethodFilter)2 ProtectionDomain (java.security.ProtectionDomain)2 InstrumentException (com.navercorp.pinpoint.bootstrap.instrument.InstrumentException)1