use of com.navercorp.pinpoint.bootstrap.instrument.InstrumentClass in project pinpoint by naver.
the class HttpClientPlugin method addHttpRequestClass.
private void addHttpRequestClass(final HttpClientPluginConfig config) {
transformTemplate.transform("com.google.api.client.http.HttpRequest", 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);
InstrumentMethod execute = target.getDeclaredMethod("execute");
if (execute != null) {
execute.addInterceptor("com.navercorp.pinpoint.plugin.google.httpclient.interceptor.HttpRequestExecuteMethodInterceptor");
}
if (config.isAsync()) {
InstrumentMethod executeAsync = target.getDeclaredMethod("executeAsync", "java.util.concurrent.Executor");
if (executeAsync != null) {
executeAsync.addInterceptor("com.navercorp.pinpoint.plugin.google.httpclient.interceptor.HttpRequestExecuteAsyncMethodInterceptor");
}
for (InstrumentClass nestedClass : target.getNestedClasses(ClassFilters.chain(ClassFilters.enclosingMethod("executeAsync", "java.util.concurrent.Executor"), ClassFilters.interfaze("java.util.concurrent.Callable")))) {
logger.debug("Find nested class {}", target.getName());
instrumentor.transform(loader, nestedClass.getName(), 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(AsyncTraceIdAccessor.class.getName());
InstrumentMethod constructor = target.getConstructor("com.google.api.client.http.HttpRequest");
if (constructor != null) {
logger.debug("Add constuctor interceptor for nested class {}", target.getName());
constructor.addInterceptor("com.navercorp.pinpoint.plugin.google.httpclient.interceptor.HttpRequestExecuteAsyncMethodInnerClassConstructorInterceptor");
}
InstrumentMethod m = target.getDeclaredMethod("call");
if (m != null) {
logger.debug("Add method interceptor for nested class {}.{}", target.getName(), m.getName());
m.addInterceptor("com.navercorp.pinpoint.plugin.google.httpclient.interceptor.HttpRequestExecuteAsyncMethodInnerClassCallMethodInterceptor");
}
return target.toBytecode();
}
});
}
}
return target.toBytecode();
}
});
}
use of com.navercorp.pinpoint.bootstrap.instrument.InstrumentClass 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);
}
use of com.navercorp.pinpoint.bootstrap.instrument.InstrumentClass 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);
}
use of com.navercorp.pinpoint.bootstrap.instrument.InstrumentClass 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);
}
use of com.navercorp.pinpoint.bootstrap.instrument.InstrumentClass 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);
}
Aggregations