mirror of
https://github.com/wahyd4/pinpoint.git
synced 2026-08-16 16:28:48 +10:00
[강운덕] [LUCYSUS-1744] rpc client쪽의 interceptor에서 rpcName 저장부분 제거.
git-svn-id: http://svn.bds.nhncorp.com/pe/hippo-tomcat-profiler/trunk@1325 84d0f5b1-2673-498c-a247-62c4ff18d310
This commit is contained in:
@@ -17,7 +17,7 @@ public interface InstrumentClass {
|
||||
|
||||
int addInterceptor(String methodName, String[] args, Interceptor interceptor) throws InstrumentException, NotFoundInstrumentException;
|
||||
|
||||
int addInterceptorFromContextClassLoader(String methodName, String[] args, Interceptor interceptor) throws InstrumentException, NotFoundInstrumentException;
|
||||
int addInterceptorCallByContextClassLoader(String methodName, String[] args, Interceptor interceptor) throws InstrumentException, NotFoundInstrumentException;
|
||||
|
||||
int addInterceptor(String methodName, String[] args, Interceptor interceptor, Type type) throws InstrumentException, NotFoundInstrumentException;
|
||||
|
||||
|
||||
@@ -123,7 +123,7 @@ public class JavaAssistClass implements InstrumentClass {
|
||||
|
||||
|
||||
@Override
|
||||
public int addInterceptorFromContextClassLoader(String methodName, String[] args, Interceptor interceptor) throws InstrumentException, NotFoundInstrumentException {
|
||||
public int addInterceptorCallByContextClassLoader(String methodName, String[] args, Interceptor interceptor) throws InstrumentException, NotFoundInstrumentException {
|
||||
if (interceptor == null) {
|
||||
throw new IllegalArgumentException("interceptor is null");
|
||||
}
|
||||
|
||||
@@ -11,8 +11,8 @@ import com.profiler.modifier.arcus.BaseOperationModifier;
|
||||
import com.profiler.modifier.arcus.CacheManagerModifier;
|
||||
import com.profiler.modifier.arcus.MemcachedClientModifier;
|
||||
import com.profiler.modifier.bloc.handler.HTTPHandlerModifier;
|
||||
import com.profiler.modifier.connector.HTTPClientModifier;
|
||||
import com.profiler.modifier.connector.HttpURLConnectionModifier;
|
||||
import com.profiler.modifier.connector.httpclient4.HttpClient4Modifier;
|
||||
import com.profiler.modifier.connector.jdkhttpconnector.HttpURLConnectionModifier;
|
||||
import com.profiler.modifier.db.cubrid.CubridPreparedStatementModifier;
|
||||
import com.profiler.modifier.db.cubrid.CubridResultSetModifier;
|
||||
import com.profiler.modifier.db.cubrid.CubridStatementModifier;
|
||||
@@ -77,8 +77,8 @@ public class DefaultModifierRegistry implements ModifierRegistry {
|
||||
FilterModifier filterModifier = new FilterModifier(byteCodeInstrumentor, agent);
|
||||
addModifier(filterModifier);
|
||||
|
||||
HTTPClientModifier httpClientModifier = new HTTPClientModifier(byteCodeInstrumentor, agent);
|
||||
addModifier(httpClientModifier);
|
||||
HttpClient4Modifier httpClient4Modifier = new HttpClient4Modifier(byteCodeInstrumentor, agent);
|
||||
addModifier(httpClient4Modifier);
|
||||
|
||||
MemcachedClientModifier memcachedClientModifier = new MemcachedClientModifier(byteCodeInstrumentor, agent);
|
||||
addModifier(memcachedClientModifier);
|
||||
|
||||
+8
-8
@@ -1,4 +1,4 @@
|
||||
package com.profiler.modifier.connector;
|
||||
package com.profiler.modifier.connector.httpclient4;
|
||||
|
||||
import java.security.ProtectionDomain;
|
||||
import java.util.logging.Level;
|
||||
@@ -12,11 +12,11 @@ import com.profiler.interceptor.bci.InstrumentException;
|
||||
import com.profiler.modifier.AbstractModifier;
|
||||
|
||||
/**
|
||||
* Apache httpclient modifier
|
||||
* Apache httpclient4 modifier
|
||||
* <p/>
|
||||
* <p/>
|
||||
* <pre>
|
||||
* http://grepcode.com/file/repo1.maven.org/maven2/org.apache.httpcomponents/httpclient/4.0.3/org/apache/http/impl/client/AbstractHttpClient.java#AbstractHttpClient.execute%28org.apache.http.HttpHost%2Corg.apache.http.HttpRequest%2Corg.apache.http.client.ResponseHandler%2Corg.apache.http.protocol.HttpContext%29
|
||||
* http://grepcode.com/file/repo1.maven.org/maven2/org.apache.httpcomponents/httpclient4/4.0.3/org/apache/http/impl/client/AbstractHttpClient.java#AbstractHttpClient.execute%28org.apache.http.HttpHost%2Corg.apache.http.HttpRequest%2Corg.apache.http.client.ResponseHandler%2Corg.apache.http.protocol.HttpContext%29
|
||||
*
|
||||
* Hooking
|
||||
* org.apache.http.impl.client.AbstractHttpClient.
|
||||
@@ -30,11 +30,11 @@ import com.profiler.modifier.AbstractModifier;
|
||||
*
|
||||
* @author netspider
|
||||
*/
|
||||
public class HTTPClientModifier extends AbstractModifier {
|
||||
public class HttpClient4Modifier extends AbstractModifier {
|
||||
|
||||
private final Logger logger = Logger.getLogger(HTTPClientModifier.class.getName());
|
||||
private final Logger logger = Logger.getLogger(HttpClient4Modifier.class.getName());
|
||||
|
||||
public HTTPClientModifier(ByteCodeInstrumentor byteCodeInstrumentor, Agent agent) {
|
||||
public HttpClient4Modifier(ByteCodeInstrumentor byteCodeInstrumentor, Agent agent) {
|
||||
super(byteCodeInstrumentor, agent);
|
||||
}
|
||||
|
||||
@@ -50,10 +50,10 @@ public class HTTPClientModifier extends AbstractModifier {
|
||||
byteCodeInstrumentor.checkLibrary(classLoader, javassistClassName);
|
||||
try {
|
||||
InstrumentClass aClass = byteCodeInstrumentor.getClass(javassistClassName);
|
||||
Interceptor interceptor = byteCodeInstrumentor.newInterceptor(classLoader, protectedDomain, "com.profiler.modifier.connector.interceptors.ExecuteMethodInterceptor");
|
||||
Interceptor interceptor = byteCodeInstrumentor.newInterceptor(classLoader, protectedDomain, "com.profiler.modifier.connector.httpclient4.interceptor.ExecuteMethodInterceptor");
|
||||
aClass.addInterceptor("execute", new String[]{"org.apache.http.HttpHost", "org.apache.http.HttpRequest", "org.apache.http.client.ResponseHandler", "org.apache.http.protocol.HttpContext"}, interceptor);
|
||||
|
||||
Interceptor interceptor2 = byteCodeInstrumentor.newInterceptor(classLoader, protectedDomain, "com.profiler.modifier.connector.interceptors.Execute2MethodInterceptor");
|
||||
Interceptor interceptor2 = byteCodeInstrumentor.newInterceptor(classLoader, protectedDomain, "com.profiler.modifier.connector.httpclient4.interceptor.Execute2MethodInterceptor");
|
||||
aClass.addInterceptor("execute", new String[]{"org.apache.http.client.methods.HttpUriRequest"}, interceptor2);
|
||||
|
||||
return aClass.toBytecode();
|
||||
+1
-2
@@ -1,4 +1,4 @@
|
||||
package com.profiler.modifier.connector.interceptors;
|
||||
package com.profiler.modifier.connector.httpclient4.interceptor;
|
||||
|
||||
import java.net.URI;
|
||||
import java.util.logging.Logger;
|
||||
@@ -62,7 +62,6 @@ public class Execute2MethodInterceptor implements StaticAroundInterceptor, ByteC
|
||||
HttpHost host = extractHost(request.getURI());
|
||||
|
||||
trace.recordServiceType(ServiceType.HTTP_CLIENT);
|
||||
trace.recordRpcName("CLIENT");
|
||||
|
||||
int port = host.getPort();
|
||||
trace.recordEndPoint(host.getHostName() + ((port > 0) ? ":" + port : ""));
|
||||
+1
-2
@@ -1,4 +1,4 @@
|
||||
package com.profiler.modifier.connector.interceptors;
|
||||
package com.profiler.modifier.connector.httpclient4.interceptor;
|
||||
|
||||
import java.util.logging.Logger;
|
||||
|
||||
@@ -63,7 +63,6 @@ public class ExecuteMethodInterceptor implements StaticAroundInterceptor, ByteCo
|
||||
request.addHeader(Header.HTTP_FLAGS.toString(), String.valueOf(nextId.getFlags()));
|
||||
|
||||
trace.recordServiceType(ServiceType.HTTP_CLIENT);
|
||||
trace.recordRpcName("CLIENT");
|
||||
|
||||
int port = host.getPort();
|
||||
trace.recordEndPoint(host.getHostName() + ((port > 0) ? ":" + port : ""));
|
||||
+5
-4
@@ -1,4 +1,4 @@
|
||||
package com.profiler.modifier.connector;
|
||||
package com.profiler.modifier.connector.jdkhttpconnector;
|
||||
|
||||
import java.security.ProtectionDomain;
|
||||
import java.util.logging.Level;
|
||||
@@ -9,7 +9,8 @@ import com.profiler.interceptor.bci.ByteCodeInstrumentor;
|
||||
import com.profiler.interceptor.bci.InstrumentClass;
|
||||
import com.profiler.interceptor.bci.InstrumentException;
|
||||
import com.profiler.modifier.AbstractModifier;
|
||||
import com.profiler.modifier.connector.interceptors.ConnectMethodInterceptor;
|
||||
import com.profiler.modifier.connector.httpclient4.HttpClient4Modifier;
|
||||
import com.profiler.modifier.connector.jdkhttpconnector.interceptor.ConnectMethodInterceptor;
|
||||
|
||||
/**
|
||||
* TODO classloader문제 있음.
|
||||
@@ -18,7 +19,7 @@ import com.profiler.modifier.connector.interceptors.ConnectMethodInterceptor;
|
||||
*/
|
||||
public class HttpURLConnectionModifier extends AbstractModifier {
|
||||
|
||||
private final Logger logger = Logger.getLogger(HTTPClientModifier.class.getName());
|
||||
private final Logger logger = Logger.getLogger(HttpClient4Modifier.class.getName());
|
||||
|
||||
public HttpURLConnectionModifier(ByteCodeInstrumentor byteCodeInstrumentor, Agent agent) {
|
||||
super(byteCodeInstrumentor, agent);
|
||||
@@ -37,7 +38,7 @@ public class HttpURLConnectionModifier extends AbstractModifier {
|
||||
try {
|
||||
InstrumentClass aClass = byteCodeInstrumentor.getClass(javassistClassName);
|
||||
ConnectMethodInterceptor connectMethodInterceptor = new ConnectMethodInterceptor();
|
||||
aClass.addInterceptorFromContextClassLoader("connect", null, connectMethodInterceptor);
|
||||
aClass.addInterceptorCallByContextClassLoader("connect", null, connectMethodInterceptor);
|
||||
|
||||
return aClass.toBytecode();
|
||||
} catch (InstrumentException e) {
|
||||
+1
-2
@@ -1,4 +1,4 @@
|
||||
package com.profiler.modifier.connector.interceptors;
|
||||
package com.profiler.modifier.connector.jdkhttpconnector.interceptor;
|
||||
|
||||
import java.net.HttpURLConnection;
|
||||
import java.util.logging.Logger;
|
||||
@@ -52,7 +52,6 @@ public class ConnectMethodInterceptor implements StaticAroundInterceptor, ByteCo
|
||||
request.setRequestProperty(Header.HTTP_FLAGS.toString(), String.valueOf(nextId.getFlags()));
|
||||
|
||||
trace.recordServiceType(ServiceType.JDK_HTTPURLCONNECTOR);
|
||||
trace.recordRpcName("CLIENT");
|
||||
|
||||
String host = request.getURL().getHost();
|
||||
int port = request.getURL().getPort();
|
||||
@@ -47,7 +47,7 @@ public class JavaAssistClassTest {
|
||||
TestBeforeInterceptor interceptor = new TestBeforeInterceptor();
|
||||
String methodName = "callA";
|
||||
|
||||
aClass.addInterceptorFromContextClassLoader(methodName, null, interceptor);
|
||||
aClass.addInterceptorCallByContextClassLoader(methodName, null, interceptor);
|
||||
|
||||
Object testObject = aClass.toClass().newInstance();
|
||||
Method callA = testObject.getClass().getMethod(methodName);
|
||||
@@ -63,7 +63,7 @@ public class JavaAssistClassTest {
|
||||
|
||||
@Test
|
||||
public void testAddAfterInterceptor() throws Exception {
|
||||
// TODO aClass.addInterceptorFromContextClassLoader 코드의 테스트 케이스도 추가해야함.
|
||||
// TODO aClass.addInterceptorCallByContextClassLoader 코드의 테스트 케이스도 추가해야함.
|
||||
|
||||
ByteCodeInstrumentor javaAssistByteCodeInstrumentor = new JavaAssistByteCodeInstrumentor();
|
||||
InstrumentClass aClass = javaAssistByteCodeInstrumentor.getClass("com.profiler.interceptor.bci.TestObject2");
|
||||
|
||||
Reference in New Issue
Block a user