Search in sources :

Example 26 with Instrumentor

use of com.navercorp.pinpoint.bootstrap.instrument.Instrumentor in project pinpoint by naver.

the class MySqlPlugin method addStatementTransformer.

private void addStatementTransformer() {
    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);
            if (!target.isInterceptable()) {
                return null;
            }
            target.addField("com.navercorp.pinpoint.bootstrap.plugin.jdbc.DatabaseInfoAccessor");
            target.addScopedInterceptor("com.navercorp.pinpoint.bootstrap.plugin.jdbc.interceptor.StatementExecuteQueryInterceptor", MySqlConstants.MYSQL_SCOPE);
            target.addScopedInterceptor("com.navercorp.pinpoint.bootstrap.plugin.jdbc.interceptor.StatementExecuteUpdateInterceptor", MySqlConstants.MYSQL_SCOPE);
            return target.toBytecode();
        }
    };
    transformTemplate.transform("com.mysql.jdbc.Statement", transformer);
    transformTemplate.transform("com.mysql.jdbc.StatementImpl", transformer);
}
Also used : ProtectionDomain(java.security.ProtectionDomain) Instrumentor(com.navercorp.pinpoint.bootstrap.instrument.Instrumentor) InstrumentClass(com.navercorp.pinpoint.bootstrap.instrument.InstrumentClass) TransformCallback(com.navercorp.pinpoint.bootstrap.instrument.transformer.TransformCallback) InstrumentClass(com.navercorp.pinpoint.bootstrap.instrument.InstrumentClass)

Example 27 with Instrumentor

use of com.navercorp.pinpoint.bootstrap.instrument.Instrumentor in project pinpoint by naver.

the class MySqlPlugin method addConnectionTransformer.

private void addConnectionTransformer(final MySqlConfig 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);
            if (!target.isInterceptable()) {
                return null;
            }
            target.addField("com.navercorp.pinpoint.bootstrap.plugin.jdbc.DatabaseInfoAccessor");
            target.addInterceptor("com.navercorp.pinpoint.plugin.jdbc.mysql.interceptor.MySQLConnectionCreateInterceptor");
            target.addScopedInterceptor("com.navercorp.pinpoint.bootstrap.plugin.jdbc.interceptor.ConnectionCloseInterceptor", MySqlConstants.MYSQL_SCOPE);
            target.addScopedInterceptor("com.navercorp.pinpoint.bootstrap.plugin.jdbc.interceptor.StatementCreateInterceptor", MySqlConstants.MYSQL_SCOPE);
            target.addScopedInterceptor("com.navercorp.pinpoint.bootstrap.plugin.jdbc.interceptor.PreparedStatementCreateInterceptor", MySqlConstants.MYSQL_SCOPE);
            if (config.isProfileSetAutoCommit()) {
                target.addScopedInterceptor("com.navercorp.pinpoint.bootstrap.plugin.jdbc.interceptor.TransactionSetAutoCommitInterceptor", MySqlConstants.MYSQL_SCOPE);
            }
            if (config.isProfileCommit()) {
                target.addScopedInterceptor("com.navercorp.pinpoint.bootstrap.plugin.jdbc.interceptor.TransactionCommitInterceptor", MySqlConstants.MYSQL_SCOPE);
            }
            if (config.isProfileRollback()) {
                target.addScopedInterceptor("com.navercorp.pinpoint.bootstrap.plugin.jdbc.interceptor.TransactionRollbackInterceptor", MySqlConstants.MYSQL_SCOPE);
            }
            return target.toBytecode();
        }
    };
    transformTemplate.transform("com.mysql.jdbc.Connection", transformer);
    transformTemplate.transform("com.mysql.jdbc.ConnectionImpl", transformer);
}
Also used : ProtectionDomain(java.security.ProtectionDomain) Instrumentor(com.navercorp.pinpoint.bootstrap.instrument.Instrumentor) InstrumentClass(com.navercorp.pinpoint.bootstrap.instrument.InstrumentClass) TransformCallback(com.navercorp.pinpoint.bootstrap.instrument.transformer.TransformCallback) InstrumentClass(com.navercorp.pinpoint.bootstrap.instrument.InstrumentClass)

Example 28 with Instrumentor

use of com.navercorp.pinpoint.bootstrap.instrument.Instrumentor in project pinpoint by naver.

the class MariaDBPlugin method addConnectionTransformer.

private void addConnectionTransformer(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);
            if (!target.isInterceptable()) {
                return null;
            }
            target.addField("com.navercorp.pinpoint.bootstrap.plugin.jdbc.DatabaseInfoAccessor");
            target.addScopedInterceptor("com.navercorp.pinpoint.bootstrap.plugin.jdbc.interceptor.ConnectionCloseInterceptor", MariaDBConstants.MARIADB_SCOPE);
            target.addScopedInterceptor("com.navercorp.pinpoint.bootstrap.plugin.jdbc.interceptor.StatementCreateInterceptor", MariaDBConstants.MARIADB_SCOPE);
            target.addScopedInterceptor("com.navercorp.pinpoint.bootstrap.plugin.jdbc.interceptor.PreparedStatementCreateInterceptor", MariaDBConstants.MARIADB_SCOPE);
            if (config.isProfileSetAutoCommit()) {
                target.addScopedInterceptor("com.navercorp.pinpoint.bootstrap.plugin.jdbc.interceptor.TransactionSetAutoCommitInterceptor", MariaDBConstants.MARIADB_SCOPE);
            }
            if (config.isProfileCommit()) {
                target.addScopedInterceptor("com.navercorp.pinpoint.bootstrap.plugin.jdbc.interceptor.TransactionCommitInterceptor", MariaDBConstants.MARIADB_SCOPE);
            }
            if (config.isProfileRollback()) {
                target.addScopedInterceptor("com.navercorp.pinpoint.bootstrap.plugin.jdbc.interceptor.TransactionRollbackInterceptor", MariaDBConstants.MARIADB_SCOPE);
            }
            return target.toBytecode();
        }
    };
    transformTemplate.transform("org.mariadb.jdbc.MariaDbConnection", transformer);
}
Also used : ProtectionDomain(java.security.ProtectionDomain) Instrumentor(com.navercorp.pinpoint.bootstrap.instrument.Instrumentor) InstrumentClass(com.navercorp.pinpoint.bootstrap.instrument.InstrumentClass) TransformCallback(com.navercorp.pinpoint.bootstrap.instrument.transformer.TransformCallback) InstrumentClass(com.navercorp.pinpoint.bootstrap.instrument.InstrumentClass)

Example 29 with Instrumentor

use of com.navercorp.pinpoint.bootstrap.instrument.Instrumentor in project pinpoint by naver.

the class MariaDBPlugin method addPreparedStatementTransformer.

private void addPreparedStatementTransformer(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");
            int maxBindValueSize = config.getMaxSqlBindValueSize();
            target.addScopedInterceptor("com.navercorp.pinpoint.bootstrap.plugin.jdbc.interceptor.PreparedStatementExecuteQueryInterceptor", va(maxBindValueSize), MariaDBConstants.MARIADB_SCOPE);
            return target.toBytecode();
        }
    };
    transformTemplate.transform("org.mariadb.jdbc.MariaDbServerPreparedStatement", transformer);
    transformTemplate.transform("org.mariadb.jdbc.MariaDbClientPreparedStatement", transformer);
}
Also used : ProtectionDomain(java.security.ProtectionDomain) Instrumentor(com.navercorp.pinpoint.bootstrap.instrument.Instrumentor) InstrumentClass(com.navercorp.pinpoint.bootstrap.instrument.InstrumentClass) TransformCallback(com.navercorp.pinpoint.bootstrap.instrument.transformer.TransformCallback) InstrumentClass(com.navercorp.pinpoint.bootstrap.instrument.InstrumentClass)

Example 30 with Instrumentor

use of com.navercorp.pinpoint.bootstrap.instrument.Instrumentor in project pinpoint by naver.

the class MariaDBPlugin method addStatementTransformer.

private void addStatementTransformer() {
    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);
            if (!target.isInterceptable()) {
                return null;
            }
            target.addField("com.navercorp.pinpoint.bootstrap.plugin.jdbc.DatabaseInfoAccessor");
            target.addScopedInterceptor("com.navercorp.pinpoint.bootstrap.plugin.jdbc.interceptor.StatementExecuteQueryInterceptor", MariaDBConstants.MARIADB_SCOPE);
            target.addScopedInterceptor("com.navercorp.pinpoint.bootstrap.plugin.jdbc.interceptor.StatementExecuteUpdateInterceptor", MariaDBConstants.MARIADB_SCOPE);
            return target.toBytecode();
        }
    };
    transformTemplate.transform("org.mariadb.jdbc.MariaDbStatement", transformer);
}
Also used : ProtectionDomain(java.security.ProtectionDomain) Instrumentor(com.navercorp.pinpoint.bootstrap.instrument.Instrumentor) InstrumentClass(com.navercorp.pinpoint.bootstrap.instrument.InstrumentClass) TransformCallback(com.navercorp.pinpoint.bootstrap.instrument.transformer.TransformCallback) InstrumentClass(com.navercorp.pinpoint.bootstrap.instrument.InstrumentClass)

Aggregations

InstrumentClass (com.navercorp.pinpoint.bootstrap.instrument.InstrumentClass)44 Instrumentor (com.navercorp.pinpoint.bootstrap.instrument.Instrumentor)44 ProtectionDomain (java.security.ProtectionDomain)44 TransformCallback (com.navercorp.pinpoint.bootstrap.instrument.transformer.TransformCallback)42 InstrumentException (com.navercorp.pinpoint.bootstrap.instrument.InstrumentException)28 InstrumentMethod (com.navercorp.pinpoint.bootstrap.instrument.InstrumentMethod)20 TestClassLoader (com.navercorp.pinpoint.test.classloader.TestClassLoader)5 Method (java.lang.reflect.Method)5 Test (org.junit.Test)5 JavassistClassTest (com.navercorp.pinpoint.test.javasssit.JavassistClassTest)3 ProfilerConfig (com.navercorp.pinpoint.bootstrap.config.ProfilerConfig)2 MethodFilter (com.navercorp.pinpoint.bootstrap.instrument.MethodFilter)2 Interceptor (com.navercorp.pinpoint.bootstrap.interceptor.Interceptor)2 ObjectFactory (com.navercorp.pinpoint.bootstrap.plugin.ObjectFactory)2 PreparedStatementBindingMethodFilter (com.navercorp.pinpoint.bootstrap.plugin.jdbc.PreparedStatementBindingMethodFilter)2 List (java.util.List)2 AsyncTraceIdAccessor (com.navercorp.pinpoint.bootstrap.async.AsyncTraceIdAccessor)1 DatabaseInfo (com.navercorp.pinpoint.bootstrap.context.DatabaseInfo)1 UnKnownDatabaseInfo (com.navercorp.pinpoint.bootstrap.plugin.jdbc.UnKnownDatabaseInfo)1 HystrixCommandTransformer (com.navercorp.pinpoint.plugin.hystrix.transformer.HystrixCommandTransformer)1