use of com.navercorp.pinpoint.bootstrap.instrument.InstrumentClass in project pinpoint by naver.
the class OraclePlugin method addCallableStatementTransformer.
private void addCallableStatementTransformer() {
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 (className.equals(CLASS_CALLABLE_STATEMENT)) {
if (instrumentor.exist(loader, CLASS_CALLABLE_STATEMENT_WRAPPER)) {
return null;
}
}
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");
target.addScopedInterceptor("com.navercorp.pinpoint.bootstrap.plugin.jdbc.interceptor.CallableStatementRegisterOutParameterInterceptor", OracleConstants.ORACLE_SCOPE);
return target.toBytecode();
}
};
transformTemplate.transform(CLASS_CALLABLE_STATEMENT, transformer);
transformTemplate.transform(CLASS_CALLABLE_STATEMENT_WRAPPER, transformer);
}
use of com.navercorp.pinpoint.bootstrap.instrument.InstrumentClass in project pinpoint by naver.
the class MariaDBPlugin method addCallableStatementTransformer.
private void addCallableStatementTransformer() {
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");
target.addScopedInterceptor("com.navercorp.pinpoint.bootstrap.plugin.jdbc.interceptor.CallableStatementRegisterOutParameterInterceptor", MariaDBConstants.MARIADB_SCOPE);
return target.toBytecode();
}
};
transformTemplate.transform("org.mariadb.jdbc.AbstractCallableProcedureStatement", transformer);
transformTemplate.transform("org.mariadb.jdbc.AbstractCallableFunctionStatement", transformer);
}
use of com.navercorp.pinpoint.bootstrap.instrument.InstrumentClass 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);
}
use of com.navercorp.pinpoint.bootstrap.instrument.InstrumentClass in project pinpoint by naver.
the class JavassistClassTest method testDeclaredMethods.
@Test
public void testDeclaredMethods() throws InstrumentException {
InstrumentEngine engine = newJavassistEngine();
InstrumentContext instrumentContext = mock(InstrumentContext.class);
String testObjectName = "com.navercorp.pinpoint.test.javasssit.mock.TestObject";
byte[] testObjectByteCode = readByteCode(testObjectName);
InstrumentClass testObject = engine.getClass(instrumentContext, null, testObjectName, testObjectByteCode);
Assert.assertEquals(testObject.getName(), testObjectName);
int findMethodCount = 0;
for (InstrumentMethod methodInfo : testObject.getDeclaredMethods()) {
if (!methodInfo.getName().equals("callA")) {
continue;
}
String[] parameterTypes = methodInfo.getParameterTypes();
if (parameterTypes == null || parameterTypes.length == 0) {
findMethodCount++;
}
}
Assert.assertEquals(findMethodCount, 1);
}
use of com.navercorp.pinpoint.bootstrap.instrument.InstrumentClass in project pinpoint by naver.
the class JavassistClassTest method hasEnclodingMethod.
@Test
public void hasEnclodingMethod() throws Exception {
InstrumentEngine engine = newJavassistEngine();
InstrumentContext instrumentContext = mock(InstrumentContext.class);
String testObjectName = "com.navercorp.pinpoint.test.javasssit.mock.TestObjectNestedClass";
byte[] testObjectByteCode = readByteCode(testObjectName);
InstrumentClass testObject = engine.getClass(instrumentContext, null, testObjectName, testObjectByteCode);
Assert.assertEquals(testObject.getName(), testObjectName);
assertEquals(1, testObject.getNestedClasses(ClassFilters.enclosingMethod("enclosingMethod", "java.lang.String", "int")).size());
assertEquals(0, testObject.getNestedClasses(ClassFilters.enclosingMethod("enclosingMethod", "int")).size());
}
Aggregations