mirror of
https://github.com/wahyd4/pinpoint.git
synced 2026-08-16 16:28:48 +10:00
#7 add super class interceptor
This commit is contained in:
+35
@@ -0,0 +1,35 @@
|
||||
package com.nhn.pinpoint.profiler.modifier.redis;
|
||||
|
||||
import java.security.ProtectionDomain;
|
||||
|
||||
import com.nhn.pinpoint.bootstrap.Agent;
|
||||
import com.nhn.pinpoint.bootstrap.interceptor.tracevalue.MapTraceValue;
|
||||
import com.nhn.pinpoint.profiler.interceptor.bci.ByteCodeInstrumentor;
|
||||
import com.nhn.pinpoint.profiler.interceptor.bci.InstrumentClass;
|
||||
import com.nhn.pinpoint.profiler.interceptor.bci.InstrumentException;
|
||||
import com.nhn.pinpoint.profiler.interceptor.bci.NotFoundInstrumentException;
|
||||
|
||||
/**
|
||||
* jedis(redis client) modifier
|
||||
*
|
||||
* @author jaehong.kim
|
||||
*
|
||||
*/
|
||||
public class BinaryJedisModifier extends JedisModifier {
|
||||
|
||||
public BinaryJedisModifier(ByteCodeInstrumentor byteCodeInstrumentor, Agent agent) {
|
||||
super(byteCodeInstrumentor, agent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTargetClass() {
|
||||
return "redis/clients/jedis/BinaryJedis";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void beforeAddInterceptor(ClassLoader classLoader, ProtectionDomain protectedDomain, final InstrumentClass instrumentClass) throws NotFoundInstrumentException, InstrumentException {
|
||||
// trace endPoint.
|
||||
instrumentClass.addTraceValue(MapTraceValue.class);
|
||||
}
|
||||
|
||||
}
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
package com.nhn.pinpoint.profiler.modifier.redis;
|
||||
|
||||
import com.nhn.pinpoint.bootstrap.Agent;
|
||||
import com.nhn.pinpoint.profiler.interceptor.bci.ByteCodeInstrumentor;
|
||||
|
||||
/**
|
||||
* RedisCluster(nBase-ARC client) modifier
|
||||
*
|
||||
* @author jaehong.kim
|
||||
*
|
||||
*/
|
||||
public class BinaryRedisClusterModifier extends RedisClusterModifier {
|
||||
|
||||
public BinaryRedisClusterModifier(ByteCodeInstrumentor byteCodeInstrumentor, Agent agent) {
|
||||
super(byteCodeInstrumentor, agent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTargetClass() {
|
||||
return "com/nhncorp/redis/cluster/BinaryRedisCluster";
|
||||
}
|
||||
}
|
||||
+34
@@ -0,0 +1,34 @@
|
||||
package com.nhn.pinpoint.profiler.modifier.redis;
|
||||
|
||||
import java.security.ProtectionDomain;
|
||||
|
||||
import com.nhn.pinpoint.bootstrap.Agent;
|
||||
import com.nhn.pinpoint.bootstrap.interceptor.tracevalue.MapTraceValue;
|
||||
import com.nhn.pinpoint.profiler.interceptor.bci.ByteCodeInstrumentor;
|
||||
import com.nhn.pinpoint.profiler.interceptor.bci.InstrumentClass;
|
||||
import com.nhn.pinpoint.profiler.interceptor.bci.InstrumentException;
|
||||
import com.nhn.pinpoint.profiler.interceptor.bci.NotFoundInstrumentException;
|
||||
|
||||
/**
|
||||
* RedisCluster(nBase-ARC client) modifier
|
||||
*
|
||||
* @author jaehong.kim
|
||||
*
|
||||
*/
|
||||
public class BinaryTriplesRedisClusterModifier extends RedisClusterModifier {
|
||||
|
||||
public BinaryTriplesRedisClusterModifier(ByteCodeInstrumentor byteCodeInstrumentor, Agent agent) {
|
||||
super(byteCodeInstrumentor, agent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTargetClass() {
|
||||
return "com/nhncorp/redis/cluster/triples/BinaryTriplesRedisCluster";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void beforeAddInterceptor(ClassLoader classLoader, ProtectionDomain protectedDomain, final InstrumentClass instrumentClass) throws NotFoundInstrumentException, InstrumentException {
|
||||
// trace destinationId, endPoint
|
||||
instrumentClass.addTraceValue(MapTraceValue.class);
|
||||
}
|
||||
}
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
package com.nhn.pinpoint.profiler.modifier.redis;
|
||||
|
||||
import com.nhn.pinpoint.bootstrap.Agent;
|
||||
import com.nhn.pinpoint.profiler.interceptor.bci.ByteCodeInstrumentor;
|
||||
|
||||
/**
|
||||
* jedis(redis client) pipeline modifier
|
||||
*
|
||||
* @author jaehong.kim
|
||||
*
|
||||
*/
|
||||
public class JedisMultiKeyPipelineBaseModifier extends JedisPipelineBaseModifier {
|
||||
|
||||
public JedisMultiKeyPipelineBaseModifier(ByteCodeInstrumentor byteCodeInstrumentor, Agent agent) {
|
||||
super(byteCodeInstrumentor, agent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTargetClass() {
|
||||
return "redis/clients/jedis/MultiKeyPipelineBase";
|
||||
}
|
||||
}
|
||||
+75
@@ -0,0 +1,75 @@
|
||||
package com.nhn.pinpoint.profiler.modifier.redis;
|
||||
|
||||
import java.security.ProtectionDomain;
|
||||
import java.util.List;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.nhn.pinpoint.bootstrap.Agent;
|
||||
import com.nhn.pinpoint.bootstrap.interceptor.Interceptor;
|
||||
import com.nhn.pinpoint.profiler.interceptor.bci.ByteCodeInstrumentor;
|
||||
import com.nhn.pinpoint.profiler.interceptor.bci.InstrumentClass;
|
||||
import com.nhn.pinpoint.profiler.interceptor.bci.InstrumentException;
|
||||
import com.nhn.pinpoint.profiler.interceptor.bci.Method;
|
||||
import com.nhn.pinpoint.profiler.interceptor.bci.NotFoundInstrumentException;
|
||||
import com.nhn.pinpoint.profiler.modifier.AbstractModifier;
|
||||
import com.nhn.pinpoint.profiler.modifier.redis.filter.JedisPipelineMethodNames;
|
||||
import com.nhn.pinpoint.profiler.modifier.redis.filter.NameBasedMethodFilter;
|
||||
|
||||
/**
|
||||
* jedis(redis client) pipeline modifier
|
||||
*
|
||||
* @author jaehong.kim
|
||||
*
|
||||
*/
|
||||
public class JedisPipelineBaseModifier extends AbstractModifier {
|
||||
|
||||
protected final Logger logger = LoggerFactory.getLogger(this.getClass());
|
||||
|
||||
public JedisPipelineBaseModifier(ByteCodeInstrumentor byteCodeInstrumentor, Agent agent) {
|
||||
super(byteCodeInstrumentor, agent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTargetClass() {
|
||||
return "redis/clients/jedis/PipelineBase";
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] modify(ClassLoader classLoader, String className, ProtectionDomain protectedDomain, byte[] classFileBuffer) {
|
||||
if (logger.isInfoEnabled()) {
|
||||
logger.info("Modifing. {}", className);
|
||||
}
|
||||
|
||||
byteCodeInstrumentor.checkLibrary(classLoader, className);
|
||||
try {
|
||||
final InstrumentClass instrumentClass = byteCodeInstrumentor.getClass(className);
|
||||
|
||||
beforeAddInterceptor(classLoader, protectedDomain, instrumentClass);
|
||||
|
||||
// method
|
||||
addMethodInterceptor(classLoader, protectedDomain, instrumentClass);
|
||||
|
||||
return instrumentClass.toBytecode();
|
||||
} catch (Exception e) {
|
||||
if (logger.isWarnEnabled()) {
|
||||
logger.warn("Failed to modifier. caused={}", e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
protected void beforeAddInterceptor(ClassLoader classLoader, ProtectionDomain protectedDomain, final InstrumentClass instrumentClass) throws NotFoundInstrumentException, InstrumentException {
|
||||
// nothing
|
||||
}
|
||||
|
||||
protected void addMethodInterceptor(ClassLoader classLoader, ProtectionDomain protectedDomain, final InstrumentClass instrumentClass) throws NotFoundInstrumentException, InstrumentException {
|
||||
final List<Method> declaredMethods = instrumentClass.getDeclaredMethods(new NameBasedMethodFilter(JedisPipelineMethodNames.get()));
|
||||
for (Method method : declaredMethods) {
|
||||
final Interceptor methodInterceptor = byteCodeInstrumentor.newInterceptor(classLoader, protectedDomain, "com.nhn.pinpoint.profiler.modifier.redis.interceptor.JedisPipelineMethodInterceptor");
|
||||
instrumentClass.addInterceptor(method.getMethodName(), method.getMethodParams(), methodInterceptor);
|
||||
}
|
||||
}
|
||||
}
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
package com.nhn.pinpoint.profiler.modifier.redis;
|
||||
|
||||
import com.nhn.pinpoint.bootstrap.Agent;
|
||||
import com.nhn.pinpoint.profiler.interceptor.bci.ByteCodeInstrumentor;
|
||||
|
||||
/**
|
||||
* RedisCluster(nBase-ARC client) modifier
|
||||
*
|
||||
* @author jaehong.kim
|
||||
*
|
||||
*/
|
||||
public class TriplesRedisClusterModifier extends RedisClusterModifier {
|
||||
|
||||
public TriplesRedisClusterModifier(ByteCodeInstrumentor byteCodeInstrumentor, Agent agent) {
|
||||
super(byteCodeInstrumentor, agent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTargetClass() {
|
||||
return "com/nhncorp/redis/cluster/triples/TriplesRedisCluster";
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user