use of com.navercorp.pinpoint.bootstrap.instrument.transformer.TransformCallback 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.transformer.TransformCallback 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);
}
use of com.navercorp.pinpoint.bootstrap.instrument.transformer.TransformCallback 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);
}
use of com.navercorp.pinpoint.bootstrap.instrument.transformer.TransformCallback in project pinpoint by naver.
the class ThriftPlugin method addTTransportEditor.
// Common - transports
private void addTTransportEditor(String tTransportFqcn) {
final String targetClassName = tTransportFqcn;
transformTemplate.transform(targetClassName, new TransformCallback() {
@Override
public byte[] doInTransform(Instrumentor instrumentor, ClassLoader loader, String className, Class<?> classBeingRedefined, ProtectionDomain protectionDomain, byte[] classfileBuffer) throws InstrumentException {
final InstrumentClass target = instrumentor.getInstrumentClass(loader, className, classfileBuffer);
target.addField(ThriftConstants.FIELD_ACCESSOR_SOCKET);
return target.toBytecode();
}
});
}
use of com.navercorp.pinpoint.bootstrap.instrument.transformer.TransformCallback in project pinpoint by naver.
the class ThriftPlugin method addTProtocolInterceptors.
private void addTProtocolInterceptors(ThriftPluginConfig config, String tProtocolClassName) {
final boolean traceThriftClient = config.traceThriftClient();
final boolean traceThriftProcessor = config.traceThriftProcessor();
final String targetClassName = tProtocolClassName;
transformTemplate.transform(targetClassName, new TransformCallback() {
@Override
public byte[] doInTransform(Instrumentor instrumentor, ClassLoader loader, String className, Class<?> classBeingRedefined, ProtectionDomain protectionDomain, byte[] classfileBuffer) throws InstrumentException {
final InstrumentClass target = instrumentor.getInstrumentClass(loader, className, classfileBuffer);
// client
if (traceThriftClient) {
// TProtocol.writeFieldStop()
final InstrumentMethod writeFieldStop = target.getDeclaredMethod("writeFieldStop");
if (writeFieldStop != null) {
String interceptor = "com.navercorp.pinpoint.plugin.thrift.interceptor.tprotocol.client.TProtocolWriteFieldStopInterceptor";
writeFieldStop.addInterceptor(interceptor);
}
}
// processor
if (traceThriftProcessor) {
target.addField(ThriftConstants.FIELD_ACCESSOR_SERVER_MARKER_FLAG);
// TProtocol.readFieldBegin()
final InstrumentMethod readFieldBegin = target.getDeclaredMethod("readFieldBegin");
if (readFieldBegin != null) {
String interceptor = "com.navercorp.pinpoint.plugin.thrift.interceptor.tprotocol.server.TProtocolReadFieldBeginInterceptor";
readFieldBegin.addInterceptor(interceptor);
}
// TProtocol.readBool, TProtocol.readBinary, TProtocol.readI16, TProtocol.readI64
final List<InstrumentMethod> readTTypes = target.getDeclaredMethods(MethodFilters.name("readBool", "readBinary", "readI16", "readI64"));
if (readTTypes != null) {
String tTypeCommonInterceptor = "com.navercorp.pinpoint.plugin.thrift.interceptor.tprotocol.server.TProtocolReadTTypeInterceptor";
for (InstrumentMethod readTType : readTTypes) {
if (readTType != null) {
readTType.addInterceptor(tTypeCommonInterceptor);
}
}
}
// TProtocol.readMessageEnd()
final InstrumentMethod readMessageEnd = target.getDeclaredMethod("readMessageEnd");
if (readMessageEnd != null) {
String interceptor = "com.navercorp.pinpoint.plugin.thrift.interceptor.tprotocol.server.TProtocolReadMessageEndInterceptor";
readMessageEnd.addInterceptor(interceptor);
}
// for async processors
target.addField(ThriftConstants.FIELD_ACCESSOR_ASYNC_MARKER_FLAG);
// TProtocol.readMessageBegin()
final InstrumentMethod readMessageBegin = target.getDeclaredMethod("readMessageBegin");
if (readMessageBegin != null) {
String interceptor = "com.navercorp.pinpoint.plugin.thrift.interceptor.tprotocol.server.TProtocolReadMessageBeginInterceptor";
readMessageBegin.addInterceptor(interceptor);
}
}
return target.toBytecode();
}
});
}
Aggregations