use of com.navercorp.pinpoint.bootstrap.instrument.InstrumentException in project pinpoint by naver.
the class ThriftPlugin method addProcessFunctionEditor.
private void addProcessFunctionEditor() {
final String targetClassName = "org.apache.thrift.ProcessFunction";
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_SERVER_MARKER_FLAG);
// ProcessFunction.process(int, TProtocol, TProtocol, I)
final InstrumentMethod process = target.getDeclaredMethod("process", "int", "org.apache.thrift.protocol.TProtocol", "org.apache.thrift.protocol.TProtocol", "java.lang.Object");
if (process != null) {
String interceptor = "com.navercorp.pinpoint.plugin.thrift.interceptor.server.ProcessFunctionProcessInterceptor";
process.addInterceptor(interceptor);
}
return target.toBytecode();
}
});
}
use of com.navercorp.pinpoint.bootstrap.instrument.InstrumentException in project pinpoint by naver.
the class ThriftPlugin method addTNonblockingSocketEditor.
private void addTNonblockingSocketEditor() {
final String targetClassName = "org.apache.thrift.transport.TNonblockingSocket";
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);
target.addField(ThriftConstants.FIELD_ACCESSOR_SOCKET_ADDRESS);
// TNonblockingSocket(SocketChannel, int, SocketAddress)
final InstrumentMethod constructor = target.getConstructor("java.nio.channels.SocketChannel", "int", "java.net.SocketAddress");
if (constructor != null) {
String interceptor = "com.navercorp.pinpoint.plugin.thrift.interceptor.transport.TNonblockingSocketConstructInterceptor";
constructor.addInterceptor(interceptor);
}
return target.toBytecode();
}
});
}
use of com.navercorp.pinpoint.bootstrap.instrument.InstrumentException in project pinpoint by naver.
the class BeanMethodTransformer method doInTransform.
@Override
public byte[] doInTransform(Instrumentor instrumentor, ClassLoader loader, String className, Class<?> classBeingRedefined, ProtectionDomain protectionDomain, byte[] classfileBuffer) throws InstrumentException {
try {
final InstrumentClass target = instrumentor.getInstrumentClass(loader, className, classfileBuffer);
if (!target.isInterceptable()) {
return null;
}
final List<InstrumentMethod> methodList = target.getDeclaredMethods(METHOD_FILTER);
for (InstrumentMethod method : methodList) {
addInterceptor(method);
}
return target.toBytecode();
} catch (Exception e) {
if (logger.isWarnEnabled()) {
logger.warn("Failed to spring beans modify. Cause:{}", e.getMessage(), e);
}
return null;
}
}
use of com.navercorp.pinpoint.bootstrap.instrument.InstrumentException in project pinpoint by naver.
the class ThriftPlugin method addTTransportEditor.
private void addTTransportEditor(String tTransportClassName, final String tTransportInterceptorFqcn, final String[]... parameterTypeGroups) {
final String targetClassName = tTransportClassName;
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);
for (String[] parameterTypeGroup : parameterTypeGroups) {
final InstrumentMethod constructor = target.getConstructor(parameterTypeGroup);
if (constructor != null) {
constructor.addInterceptor(tTransportInterceptorFqcn);
}
}
return target.toBytecode();
}
});
}
use of com.navercorp.pinpoint.bootstrap.instrument.InstrumentException in project pinpoint by naver.
the class ThriftPlugin method addTBaseAsyncProcessorEditor.
private void addTBaseAsyncProcessorEditor() {
final String targetClassName = "org.apache.thrift.TBaseAsyncProcessor";
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_SERVER_MARKER_FLAG);
target.addField(ThriftConstants.FIELD_ACCESSOR_ASYNC_MARKER_FLAG);
// TBaseAsyncProcessor.process(AbstractNonblockingServer$AsyncFrameBuffer)
final InstrumentMethod process = target.getDeclaredMethod("process", "org.apache.thrift.server.AbstractNonblockingServer$AsyncFrameBuffer");
if (process != null) {
String interceptor = "com.navercorp.pinpoint.plugin.thrift.interceptor.server.async.TBaseAsyncProcessorProcessInterceptor";
process.addInterceptor(interceptor);
}
return target.toBytecode();
}
});
}
Aggregations