[강운덕] [LUCYSUS-1744] 메소드호출비용이 좀더 적은 SimpleXXXinterceptor가 추가됨. method의 info를 추가적으로 넘겨주지 않아. interceptor의 호출 비용을 줄일수 있음.

- 추후 interceptor의 캐스팅 비용을 줄일 방안을 추가적으로 강구해야 함.

git-svn-id: http://svn.bds.nhncorp.com/pe/hippo-tomcat-profiler/trunk@1592 84d0f5b1-2673-498c-a247-62c4ff18d310
This commit is contained in:
Woonduk Kang
2013-04-30 07:01:41 +00:00
parent 530245442e
commit 9ecd12eaec
30 changed files with 292 additions and 177 deletions
@@ -270,9 +270,32 @@ public final class DefaultTrace implements Trace {
return parsingResult;
}
// 재발할 경우 좀더 정확한 원인분석을 위해 과거 NullPointException 발생 로그의 일부를 첨부함.
// 2013-04-30 11:34:58 [DEBUG](db.interceptor.PreparedStatementBindVariableInterceptor) after com.mysql.jdbc.JDBC4PreparedStatement@1f31ad9: /* testquery */ delete from member where id = -1334720425 com.mysql.jdbc.PreparedStatement setInt(int, int) args:(1, -1334720425) result:null
// 2013-04-30 11:34:58 [DEBUG](db.interceptor.PreparedStatementBindVariableInterceptor) after com.mysql.jdbc.JDBC4PreparedStatement@1f31ad9: /* testquery */ delete from member where id = -1334720425 com.mysql.jdbc.PreparedStatement setObject(int, java.lang.Object) args:(1, -1334720425) result:null
// 2013-04-30 11:34:58 [DEBUG](db.interceptor.PreparedStatementExecuteQueryInterceptor) before com.mysql.jdbc.JDBC4PreparedStatement@1f31ad9: /* testquery */ delete from member where id = -1334720425 com.mysql.jdbc.PreparedStatement executeUpdate() args:null
// 2013-04-30 11:34:58 [WARN ](db.interceptor.PreparedStatementExecuteQueryInterceptor)
// java.lang.NullPointerException
// at com.profiler.context.DefaultTrace.recordSqlParsingResult(DefaultTrace.java:275)
// at com.profiler.modifier.db.interceptor.PreparedStatementExecuteQueryInterceptor.before(PreparedStatementExecuteQueryInterceptor.java:64)
// at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java)
// at org.apache.commons.dbcp.DelegatingPreparedStatement.executeUpdate(DelegatingPreparedStatement.java:105)
// at org.apache.commons.dbcp.DelegatingPreparedStatement.executeUpdate(DelegatingPreparedStatement.java:105)
// at org.apache.commons.dbcp.DelegatingPreparedStatement.executeUpdate(DelegatingPreparedStatement.java:105)
// at org.springframework.jdbc.core.JdbcTemplate$2.doInPreparedStatement(JdbcTemplate.java:818)
// at org.springframework.jdbc.core.JdbcTemplate$2.doInPreparedStatement(JdbcTemplate.java:1)
// at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:587)
// at org.springframework.jdbc.core.JdbcTemplate.update(JdbcTemplate.java:812)
@Override
public void recordSqlParsingResult(ParsingResult parsingResult) {
recordAttribute(AnnotationKey.SQL_ID, parsingResult.getSql().hashCode());
if (parsingResult == null) {
// TODO 먼가 여기서 NullPointException이 발생한 Exception 기록이 잇음.
logger.warn("ParsingResult is null");
return;
}
String sql = parsingResult.getSql();
recordAttribute(AnnotationKey.SQL_ID, sql.hashCode());
String output = parsingResult.getOutput();
if (output != null && output.length() != 0) {
recordAttribute(AnnotationKey.SQL_PARAM, output);
@@ -28,7 +28,7 @@ public class SpanEvent implements Thriftable {
private String destionationId;
private List<String> destinationAddress;
private final List<TraceAnnotation> traceAnnotationList = new ArrayList<TraceAnnotation>(5);
private final List<TraceAnnotation> traceAnnotationList = new ArrayList<TraceAnnotation>(4);
private int nextSpanId = -1;
private int depth = -1;
@@ -15,6 +15,9 @@ public class JavaAssistClass implements InstrumentClass {
private JavaAssistByteCodeInstrumentor instrumentor;
private CtClass ctClass;
private static final int STATIC_INTERCEPTOR = 0;
private static final int SIMPLE_INTERCEPTOR = 1;
public JavaAssistClass(JavaAssistByteCodeInstrumentor instrumentor, CtClass ctClass) {
this.instrumentor = instrumentor;
@@ -190,6 +193,12 @@ public class JavaAssistClass implements InstrumentClass {
addStaticBeforeInterceptor(methodName, interceptorId, behavior, useContextClassLoader);
} else if (interceptor instanceof StaticAfterInterceptor) {
addStaticAfterInterceptor(methodName, interceptorId, behavior, useContextClassLoader);
} else if(interceptor instanceof SimpleAroundInterceptor) {
addSimpleAroundInterceptor(methodName, interceptorId, behavior, useContextClassLoader);
} else if(interceptor instanceof SimpleBeforeInterceptor) {
addSimpleBeforeInterceptor(methodName, interceptorId, behavior, useContextClassLoader);
} else if(interceptor instanceof SimpleAfterInterceptor) {
addSimpleAfterInterceptor(methodName, interceptorId, behavior, useContextClassLoader);
} else {
throw new IllegalArgumentException("unsupported");
}
@@ -249,32 +258,73 @@ public class JavaAssistClass implements InstrumentClass {
addStaticAfterInterceptor(methodName, id, method, useContextClassLoader);
}
private void addStaticAfterInterceptor(String methodName, int id, CtBehavior behavior, boolean useContextClassLoader) throws NotFoundException, CannotCompileException {
private void addStaticBeforeInterceptor(String methodName, int id, CtBehavior behavior, boolean useContextClassLoader) throws CannotCompileException, NotFoundException {
addBeforeInterceptor(methodName, id, behavior, useContextClassLoader, STATIC_INTERCEPTOR);
}
String target = getTarget(behavior);
private void addStaticAfterInterceptor(String methodName, int interceptorId, CtBehavior behavior, boolean useContextClassLoader) throws NotFoundException, CannotCompileException {
addAfterInterceptor(methodName, interceptorId, behavior, useContextClassLoader, STATIC_INTERCEPTOR);
}
private void addSimpleAroundInterceptor(String methodName, int interceptorId, CtBehavior behavior, boolean useContextClassLoader) throws NotFoundException, CannotCompileException {
addSimpleBeforeInterceptor(methodName, interceptorId, behavior, useContextClassLoader);
addSimpleAfterInterceptor(methodName, interceptorId, behavior, useContextClassLoader);
}
private void addSimpleBeforeInterceptor(String methodName, int interceptorId, CtBehavior behavior, boolean useContextClassLoader) throws NotFoundException, CannotCompileException {
addBeforeInterceptor(methodName, interceptorId, behavior, useContextClassLoader, SIMPLE_INTERCEPTOR);
}
private void addSimpleAfterInterceptor(String methodName, int interceptorId, CtBehavior behavior, boolean useContextClassLoader) throws NotFoundException, CannotCompileException {
addAfterInterceptor(methodName, interceptorId, behavior, useContextClassLoader, SIMPLE_INTERCEPTOR);
}
private void addAfterInterceptor(String methodName, int id, CtBehavior behavior, boolean useContextClassLoader, int interceptorType) throws NotFoundException, CannotCompileException {
String returnType = getReturnType(behavior);
String parameterTypeString = JavaAssistUtils.getParameterDescription(behavior.getParameterTypes());
String target = getTarget(behavior);
String parameterTypeString = null;
if (interceptorType == STATIC_INTERCEPTOR) {
parameterTypeString = JavaAssistUtils.getParameterDescription(behavior.getParameterTypes());
}
String parameter = getParameter(behavior);
CodeBuilder after = new CodeBuilder();
if (useContextClassLoader) {
after.begin();
beginAddFindInterceptorCode(id, after);
after.format(" java.lang.Class[] methodArgsClassParams = new Class[]{java.lang.Object.class, java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.Object[].class, java.lang.Object.class};");
if (interceptorType == STATIC_INTERCEPTOR) {
after.format(" java.lang.Class[] methodArgsClassParams = new Class[]{java.lang.Object.class, java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.Object[].class, java.lang.Object.class};");
} else {
after.format(" java.lang.Class[] methodArgsClassParams = new Class[]{java.lang.Object.class, java.lang.Object[].class, java.lang.Object.class};");
}
after.format(" java.lang.reflect.Method method = interceptor.getClass().getMethod(\"%1$s\", methodArgsClassParams);", "after");
after.format(" java.lang.Object[] methodParams = new java.lang.Object[] { %1$s, \"%2$s\", \"%3$s\", \"%4$s\", %5$s, %6$s };", target, ctClass.getName(), methodName, parameterTypeString, parameter, returnType);
if (interceptorType == STATIC_INTERCEPTOR) {
after.format(" java.lang.Object[] methodParams = new java.lang.Object[] { %1$s, \"%2$s\", \"%3$s\", \"%4$s\", %5$s, %6$s };", target, ctClass.getName(), methodName, parameterTypeString, parameter, returnType);
} else {
after.format(" java.lang.Object[] methodParams = new java.lang.Object[] { %1$s, %2$s, %3$s };", target, parameter, returnType);
}
after.format(" method.invoke(interceptor, methodParams);");
endAddFindInterceptorCode(after);
after.end();
} else {
after.begin();
after.format(" %1$s interceptor = (%1$s) com.profiler.interceptor.InterceptorRegistry.getInterceptor(%2$d);", StaticAfterInterceptor.class.getName(), id);
after.format(" interceptor.after(%1$s, \"%2$s\", \"%3$s\", \"%4$s\", %5$s, %6$s);", target, ctClass.getName(), methodName, parameterTypeString, parameter, returnType);
if (interceptorType == STATIC_INTERCEPTOR) {
after.format(" %1$s interceptor = (%1$s) com.profiler.interceptor.InterceptorRegistry.getInterceptor(%2$d);", StaticAfterInterceptor.class.getName(), id);
after.format(" interceptor.after(%1$s, \"%2$s\", \"%3$s\", \"%4$s\", %5$s, %6$s);", target, ctClass.getName(), methodName, parameterTypeString, parameter, returnType);
} else {
after.format(" %1$s interceptor = (%1$s) com.profiler.interceptor.InterceptorRegistry.getInterceptor(%2$d);", SimpleAfterInterceptor.class.getName(), id);
after.format(" interceptor.after(%1$s, %2$s, %3$s);", target, parameter, returnType);
}
after.end();
}
String buildAfter = after.toString();
if (logger.isInfoEnabled()) {
logger.info("addStaticAfterInterceptor after behavior:" + behavior.getLongName() + " code:" + buildAfter);
if (logger.isDebugEnabled()) {
logger.debug("addStaticAfterInterceptor after behavior:{} code:{}", behavior.getLongName(), buildAfter);
}
behavior.insertAfter(buildAfter);
@@ -283,23 +333,36 @@ public class JavaAssistClass implements InstrumentClass {
if (useContextClassLoader) {
catchCode.begin();
beginAddFindInterceptorCode(id, catchCode);
catchCode.format(" java.lang.Class[] methodArgsClassParams = new Class[]{java.lang.Object.class, java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.Object[].class, java.lang.Object.class};");
if(interceptorType == STATIC_INTERCEPTOR) {
catchCode.format(" java.lang.Class[] methodArgsClassParams = new Class[]{java.lang.Object.class, java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.Object[].class, java.lang.Object.class};");
} else {
catchCode.format(" java.lang.Class[] methodArgsClassParams = new Class[]{java.lang.Object.class, java.lang.Object[].class, java.lang.Object.class};");
}
catchCode.format(" java.lang.reflect.Method method = interceptor.getClass().getMethod(\"%1$s\", methodArgsClassParams);", "after");
catchCode.format(" java.lang.Object[] methodParams = new java.lang.Object[] { %1$s, \"%2$s\", \"%3$s\", \"%4$s\", %5$s, (java.lang.Object) $e };", target, ctClass.getName(), methodName, parameterTypeString, parameter);
if (interceptorType == STATIC_INTERCEPTOR) {
catchCode.format(" java.lang.Object[] methodParams = new java.lang.Object[] { %1$s, \"%2$s\", \"%3$s\", \"%4$s\", %5$s, (java.lang.Object) $e };", target, ctClass.getName(), methodName, parameterTypeString, parameter);
} else {
catchCode.format(" java.lang.Object[] methodParams = new java.lang.Object[] { %1$s, %2$s, (java.lang.Object) $e };", target, parameter);
}
catchCode.format(" method.invoke(interceptor, methodParams);");
endAddFindInterceptorCode(catchCode);
catchCode.format(" throw $e;");
catchCode.end();
} else {
catchCode.begin();
catchCode.format(" %1$s interceptor = (%1$s) com.profiler.interceptor.InterceptorRegistry.getInterceptor(%2$d);", StaticAfterInterceptor.class.getName(), id);
catchCode.format(" interceptor.after(%1$s, \"%2$s\", \"%3$s\", \"%4$s\", %5$s, $e);", target, ctClass.getName(), methodName, parameterTypeString, parameter);
if (interceptorType == STATIC_INTERCEPTOR) {
catchCode.format(" %1$s interceptor = (%1$s) com.profiler.interceptor.InterceptorRegistry.getInterceptor(%2$d);", StaticAfterInterceptor.class.getName(), id);
catchCode.format(" interceptor.after(%1$s, \"%2$s\", \"%3$s\", \"%4$s\", %5$s, $e);", target, ctClass.getName(), methodName, parameterTypeString, parameter);
} else {
catchCode.format(" %1$s interceptor = (%1$s) com.profiler.interceptor.InterceptorRegistry.getInterceptor(%2$d);", SimpleAfterInterceptor.class.getName(), id);
catchCode.format(" interceptor.after(%1$s, %2$s, $e);", target, parameter);
}
catchCode.append(" throw $e;");
catchCode.end();
}
String buildCatch = catchCode.toString();
if (logger.isInfoEnabled()) {
logger.info("addStaticAfterInterceptor catch behavior:" + behavior.getLongName() + " code:" + buildCatch);
if (logger.isDebugEnabled()) {
logger.debug("addStaticAfterInterceptor catch behavior:{} code:{}", behavior.getLongName(), buildCatch);
}
CtClass th = instrumentor.getClassPool().get("java.lang.Throwable");
behavior.addCatch(buildCatch, th);
@@ -339,10 +402,13 @@ public class JavaAssistClass implements InstrumentClass {
}
private void addStaticBeforeInterceptor(String methodName, int id, CtBehavior behavior, boolean useContextClassLoader) throws CannotCompileException, NotFoundException {
private void addBeforeInterceptor(String methodName, int id, CtBehavior behavior, boolean useContextClassLoader, int interceptorType) throws CannotCompileException, NotFoundException {
String target = getTarget(behavior);
// 인터셉터 호출시 최대한 연산량을 줄이기 위해서 정보는 가능한 정적 데이터로 생성한다.
String parameterDescription = JavaAssistUtils.getParameterDescription(behavior.getParameterTypes());
String parameterDescription = null;
if(interceptorType == STATIC_INTERCEPTOR) {
parameterDescription = JavaAssistUtils.getParameterDescription(behavior.getParameterTypes());
}
String parameter = getParameter(behavior);
CodeBuilder code = new CodeBuilder();
@@ -356,21 +422,34 @@ public class JavaAssistClass implements InstrumentClass {
// beforeMethod.invoke(interceptor, null, null, null, null, null);
//
beginAddFindInterceptorCode(id, code);
code.format(" java.lang.Class[] beforeMethodParams = new Class[]{java.lang.Object.class, java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.Object[].class};");
if(interceptorType == STATIC_INTERCEPTOR) {
code.format(" java.lang.Class[] beforeMethodParams = new Class[]{java.lang.Object.class, java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.Object[].class};");
} else {
code.format(" java.lang.Class[] beforeMethodParams = new Class[]{java.lang.Object.class, java.lang.Object[].class};");
}
code.format(" java.lang.reflect.Method beforeMethod = interceptor.getClass().getMethod(\"%1$s\", beforeMethodParams);", "before");
code.format(" java.lang.Object[] beforeParams = new java.lang.Object[] { %1$s, \"%2$s\", \"%3$s\", \"%4$s\", %5$s };", target, ctClass.getName(), methodName, parameterDescription, parameter);
if(interceptorType == STATIC_INTERCEPTOR) {
code.format(" java.lang.Object[] beforeParams = new java.lang.Object[] { %1$s, \"%2$s\", \"%3$s\", \"%4$s\", %5$s };", target, ctClass.getName(), methodName, parameterDescription, parameter);
} else {
code.format(" java.lang.Object[] beforeParams = new java.lang.Object[] { %1$s, %2$s };", target, parameter);
}
code.format(" beforeMethod.invoke(interceptor, beforeParams);");
code.format("}");
code.end();
} else {
code.begin();
code.format(" %1$s interceptor = (%1$s) com.profiler.interceptor.InterceptorRegistry.getInterceptor(%2$d);", StaticBeforeInterceptor.class.getName(), id);
code.format(" interceptor.before(%1$s, \"%2$s\", \"%3$s\", \"%4$s\", %5$s);", target, ctClass.getName(), methodName, parameterDescription, parameter);
if (interceptorType == STATIC_INTERCEPTOR) {
code.format(" %1$s interceptor = (%1$s) com.profiler.interceptor.InterceptorRegistry.getInterceptor(%2$d);", StaticBeforeInterceptor.class.getName(), id);
code.format(" interceptor.before(%1$s, \"%2$s\", \"%3$s\", \"%4$s\", %5$s);", target, ctClass.getName(), methodName, parameterDescription, parameter);
} else {
code.format(" %1$s interceptor = (%1$s) com.profiler.interceptor.InterceptorRegistry.getInterceptor(%2$d);", SimpleBeforeInterceptor.class.getName(), id);
code.format(" interceptor.before(%1$s, %2$s);", target, parameter);
}
code.end();
}
String buildBefore = code.toString();
if (logger.isInfoEnabled()) {
logger.info("addStaticBeforeInterceptor catch behavior:" + behavior.getLongName() + " code:" + buildBefore);
logger.info("addStaticBeforeInterceptor catch behavior:{} code:{}", behavior.getLongName(), buildBefore);
}
if (behavior instanceof CtConstructor) {
@@ -28,6 +28,14 @@ public class Slf4jLoggerAdapter implements Logger {
logger.debug(sb.toString());
}
@Override
public void beforeInterceptor(Object target, Object[] args) {
StringBuilder sb = new StringBuilder(BUFFER_SIZE);
sb.append("before ");
logMethod(sb, target, args);
logger.debug(sb.toString());
}
@Override
public void afterInterceptor(Object target, String className, String methodName, String parameterDescription, Object[] args, Object result) {
StringBuilder sb = new StringBuilder(BUFFER_SIZE);
@@ -38,6 +46,16 @@ public class Slf4jLoggerAdapter implements Logger {
logger.debug(sb.toString());
}
@Override
public void afterInterceptor(Object target, Object[] args, Object result) {
StringBuilder sb = new StringBuilder(BUFFER_SIZE);
sb.append("after ");
logMethod(sb, target, args);
sb.append(" result:");
sb.append(result);
logger.debug(sb.toString());
}
@Override
public void afterInterceptor(Object target, String className, String methodName, String parameterDescription, Object[] args) {
StringBuilder sb = new StringBuilder(BUFFER_SIZE);
@@ -46,6 +64,14 @@ public class Slf4jLoggerAdapter implements Logger {
logger.debug(sb.toString());
}
@Override
public void afterInterceptor(Object target, Object[] args) {
StringBuilder sb = new StringBuilder(BUFFER_SIZE);
sb.append("after ");
logMethod(sb, target, args);
logger.debug(sb.toString());
}
private static void logMethod(StringBuilder sb, Object target, String className, String methodName, String parameterDescription, Object[] args) {
sb.append(target);
sb.append(' ');
@@ -57,6 +83,13 @@ public class Slf4jLoggerAdapter implements Logger {
appendArray(sb, args);
}
private static void logMethod(StringBuilder sb, Object target, Object[] args) {
sb.append(target);
sb.append(' ');
sb.append(" args:");
appendArray(sb, args);
}
private static void appendArray(StringBuilder sb, Object[] args) {
if (args == null) {
sb.append("null");
@@ -1,5 +1,6 @@
package com.profiler.modifier.arcus.interceptors;
import com.profiler.interceptor.SimpleBeforeInterceptor;
import com.profiler.logging.Logger;
import com.profiler.logging.LoggerFactory;
@@ -15,7 +16,7 @@ import com.profiler.util.MetaObject;
* @author netspider
*
*/
public class AddOpInterceptor implements StaticBeforeInterceptor {
public class AddOpInterceptor implements SimpleBeforeInterceptor {
private final Logger logger = LoggerFactory.getLogger(AddOpInterceptor.class.getName());
private final boolean isDebug = logger.isDebugEnabled();
@@ -26,9 +27,9 @@ public class AddOpInterceptor implements StaticBeforeInterceptor {
private final String MEMCACHED = "MEMCACHED";
@Override
public void before(Object target, String className, String methodName, String parameterDescription, Object[] args) {
public void before(Object target, Object[] args) {
if (isDebug) {
logger.beforeInterceptor(target, className, methodName, parameterDescription, args);
logger.beforeInterceptor(target, args);
}
String serviceCode = getServiceCode.invoke((MemcachedClient) target);
@@ -1,6 +1,7 @@
package com.profiler.modifier.arcus.interceptors;
import com.profiler.context.AsyncTrace;
import com.profiler.interceptor.SimpleBeforeInterceptor;
import com.profiler.logging.Logger;
import com.profiler.context.DefaultAsyncTrace;
@@ -15,7 +16,7 @@ import com.profiler.util.MetaObject;
/**
*
*/
public class BaseOperationCancelInterceptor implements StaticBeforeInterceptor {
public class BaseOperationCancelInterceptor implements SimpleBeforeInterceptor {
private final Logger logger = LoggerFactory.getLogger(BaseOperationCancelInterceptor.class.getName());
private final boolean isDebug = logger.isDebugEnabled();
@@ -23,9 +24,9 @@ public class BaseOperationCancelInterceptor implements StaticBeforeInterceptor {
private MetaObject getAsyncTrace = new MetaObject("__getAsyncTrace");
@Override
public void before(Object target, String className, String methodName, String parameterDescription, Object[] args) {
public void before(Object target, Object[] args) {
if (isDebug) {
logger.beforeInterceptor(target, className, methodName, parameterDescription, args);
logger.beforeInterceptor(target, args);
}
AsyncTrace asyncTrace = (AsyncTrace) getAsyncTrace.invoke(target);
@@ -1,5 +1,6 @@
package com.profiler.modifier.arcus.interceptors;
import com.profiler.interceptor.SimpleAfterInterceptor;
import com.profiler.logging.Logger;
import com.profiler.context.AsyncTrace;
@@ -15,7 +16,7 @@ import com.profiler.util.TimeObject;
/**
*
*/
public class BaseOperationConstructInterceptor implements StaticAfterInterceptor, TraceContextSupport {
public class BaseOperationConstructInterceptor implements SimpleAfterInterceptor, TraceContextSupport {
private final Logger logger = LoggerFactory.getLogger(BaseOperationConstructInterceptor.class.getName());
private final boolean isDebug = logger.isDebugEnabled();
@@ -24,9 +25,9 @@ public class BaseOperationConstructInterceptor implements StaticAfterInterceptor
private TraceContext traceContext;
@Override
public void after(Object target, String className, String methodName, String parameterDescription, Object[] args, Object result) {
public void after(Object target, Object[] args, Object result) {
if (isDebug) {
logger.afterInterceptor(target, className, methodName, parameterDescription, args, result);
logger.afterInterceptor(target, args, result);
}
Trace trace = traceContext.currentTraceObject();
@@ -5,14 +5,12 @@ import java.net.SocketAddress;
import java.nio.ByteBuffer;
import java.nio.charset.Charset;
import com.profiler.interceptor.*;
import com.profiler.logging.Logger;
import com.profiler.common.AnnotationKey;
import com.profiler.context.AsyncTrace;
import com.profiler.context.TraceContext;
import com.profiler.interceptor.ByteCodeMethodDescriptorSupport;
import com.profiler.interceptor.MethodDescriptor;
import com.profiler.interceptor.TraceContextSupport;
import com.profiler.logging.LoggerFactory;
import com.profiler.logging.LoggingUtils;
import com.profiler.util.TimeObject;
@@ -21,13 +19,12 @@ import net.spy.memcached.ops.OperationState;
import net.spy.memcached.protocol.BaseOperationImpl;
import com.profiler.common.ServiceType;
import com.profiler.interceptor.StaticBeforeInterceptor;
import com.profiler.util.MetaObject;
/**
*
*/
public class BaseOperationTransitionStateInterceptor implements StaticBeforeInterceptor, ByteCodeMethodDescriptorSupport, TraceContextSupport {
public class BaseOperationTransitionStateInterceptor implements SimpleBeforeInterceptor, ByteCodeMethodDescriptorSupport, TraceContextSupport {
private final Logger logger = LoggerFactory.getLogger(BaseOperationTransitionStateInterceptor.class.getName());
private final boolean isDebug = logger.isDebugEnabled();
@@ -41,9 +38,9 @@ public class BaseOperationTransitionStateInterceptor implements StaticBeforeInte
private TraceContext traceContext;
@Override
public void before(Object target, String className, String methodName, String parameterDescription, Object[] args) {
public void before(Object target, Object[] args) {
if (isDebug) {
logger.beforeInterceptor(target, className, methodName, parameterDescription, args);
logger.beforeInterceptor(target, args);
}
AsyncTrace asyncTrace = (AsyncTrace) getAsyncTrace.invoke(target);
@@ -1,5 +1,6 @@
package com.profiler.modifier.arcus.interceptors;
import com.profiler.interceptor.SimpleAfterInterceptor;
import com.profiler.logging.Logger;
import com.profiler.interceptor.StaticAfterInterceptor;
@@ -12,7 +13,7 @@ import com.profiler.util.MetaObject;
* @author netspider
*
*/
public class CacheManagerConstructInterceptor implements StaticAfterInterceptor {
public class CacheManagerConstructInterceptor implements SimpleAfterInterceptor {
private final Logger logger = LoggerFactory.getLogger(CacheManagerConstructInterceptor.class.getName());
private final boolean isDebug = logger.isDebugEnabled();
@@ -20,9 +21,9 @@ public class CacheManagerConstructInterceptor implements StaticAfterInterceptor
private MetaObject<Object> setServiceCode = new MetaObject<Object>("__setServiceCode", String.class);
@Override
public void after(Object target, String className, String methodName, String parameterDescription, Object[] args, Object result) {
public void after(Object target, Object[] args, Object result) {
if (isDebug) {
logger.afterInterceptor(target, className, methodName, parameterDescription, args, result);
logger.afterInterceptor(target, args, result);
}
setServiceCode.invoke(target, (String) args[1]);
@@ -1,5 +1,6 @@
package com.profiler.modifier.arcus.interceptors;
import com.profiler.interceptor.SimpleBeforeInterceptor;
import com.profiler.logging.Logger;
import com.profiler.logging.LoggerFactory;
@@ -15,7 +16,7 @@ import com.profiler.util.MetaObject;
* @author netspider
*
*/
public class SetCacheManagerInterceptor implements StaticBeforeInterceptor {
public class SetCacheManagerInterceptor implements SimpleBeforeInterceptor {
private final Logger logger = LoggerFactory.getLogger(SetCacheManagerInterceptor.class.getName());
private final boolean isDebug = logger.isDebugEnabled();
@@ -24,9 +25,9 @@ public class SetCacheManagerInterceptor implements StaticBeforeInterceptor {
private MetaObject<String> setServiceCode = new MetaObject<String>("__setServiceCode", String.class);
@Override
public void before(Object target, String className, String methodName, String parameterDescription, Object[] args) {
public void before(Object target, Object[] args) {
if (isDebug) {
logger.beforeInterceptor(target, className, methodName, parameterDescription, args);
logger.beforeInterceptor(target, args);
}
CacheManager cm = (CacheManager) args[0];
@@ -2,15 +2,13 @@ package com.profiler.modifier.bloc.handler.interceptors;
import java.util.Enumeration;
import java.util.UUID;
import com.profiler.interceptor.*;
import com.profiler.logging.Logger;
import com.profiler.common.AnnotationKey;
import com.profiler.common.ServiceType;
import com.profiler.context.*;
import com.profiler.interceptor.ByteCodeMethodDescriptorSupport;
import com.profiler.interceptor.MethodDescriptor;
import com.profiler.interceptor.StaticAroundInterceptor;
import com.profiler.interceptor.TraceContextSupport;
import com.profiler.logging.LoggerFactory;
import com.profiler.sampler.util.SamplingFlagUtils;
import com.profiler.util.NumberUtils;
@@ -18,7 +16,7 @@ import com.profiler.util.NumberUtils;
/**
* @author netspider
*/
public class ExecuteMethodInterceptor implements StaticAroundInterceptor, ByteCodeMethodDescriptorSupport, TraceContextSupport {
public class ExecuteMethodInterceptor implements SimpleAroundInterceptor, ByteCodeMethodDescriptorSupport, TraceContextSupport {
private final Logger logger = LoggerFactory.getLogger(ExecuteMethodInterceptor.class.getName());
private final boolean isDebug = logger.isDebugEnabled();
@@ -28,9 +26,9 @@ public class ExecuteMethodInterceptor implements StaticAroundInterceptor, ByteCo
private TraceContext traceContext;
@Override
public void before(Object target, String className, String methodName, String parameterDescription, Object[] args) {
public void before(Object target, Object[] args) {
if (isDebug) {
logger.beforeInterceptor(target, className, methodName, parameterDescription, args);
logger.beforeInterceptor(target, args);
}
try {
@@ -86,9 +84,9 @@ public class ExecuteMethodInterceptor implements StaticAroundInterceptor, ByteCo
@Override
public void after(Object target, String className, String methodName, String parameterDescription, Object[] args, Object result) {
public void after(Object target, Object[] args, Object result) {
if (isDebug) {
logger.afterInterceptor(target, className, methodName, parameterDescription, args, result);
logger.afterInterceptor(target, args, result);
}
// traceContext.getActiveThreadCounter().end();
@@ -1,10 +1,11 @@
package com.profiler.modifier.connector.httpclient4.interceptor;
import java.net.URI;
import com.profiler.interceptor.*;
import com.profiler.logging.Logger;
import com.profiler.context.*;
import com.profiler.interceptor.TraceContextSupport;
import com.profiler.logging.LoggerFactory;
import com.profiler.sampler.util.SamplingFlagUtils;
import org.apache.http.HttpHost;
@@ -12,9 +13,6 @@ import org.apache.http.client.methods.HttpUriRequest;
import com.profiler.common.AnnotationKey;
import com.profiler.common.ServiceType;
import com.profiler.interceptor.ByteCodeMethodDescriptorSupport;
import com.profiler.interceptor.MethodDescriptor;
import com.profiler.interceptor.StaticAroundInterceptor;
/**
* Method interceptor
@@ -26,7 +24,7 @@ import com.profiler.interceptor.StaticAroundInterceptor;
* public final HttpResponse execute(HttpUriRequest request) throws IOException, ClientProtocolException
* </pre>
*/
public class Execute2MethodInterceptor implements StaticAroundInterceptor, ByteCodeMethodDescriptorSupport, TraceContextSupport {
public class Execute2MethodInterceptor implements SimpleAroundInterceptor, ByteCodeMethodDescriptorSupport, TraceContextSupport {
private final Logger logger = LoggerFactory.getLogger(Execute2MethodInterceptor.class.getName());
private final boolean isDebug = logger.isDebugEnabled();
@@ -35,9 +33,9 @@ public class Execute2MethodInterceptor implements StaticAroundInterceptor, ByteC
private TraceContext traceContext;
@Override
public void before(Object target, String className, String methodName, String parameterDescription, Object[] args) {
public void before(Object target, Object[] args) {
if (isDebug) {
logger.beforeInterceptor(target, className, methodName, parameterDescription, args);
logger.beforeInterceptor(target, args);
}
Trace trace = traceContext.currentRawTraceObject();
@@ -81,10 +79,10 @@ public class Execute2MethodInterceptor implements StaticAroundInterceptor, ByteC
}
@Override
public void after(Object target, String className, String methodName, String parameterDescription, Object[] args, Object result) {
public void after(Object target, Object[] args, Object result) {
if (isDebug) {
// result는 로깅하지 않는다.
logger.afterInterceptor(target, className, methodName, parameterDescription, args);
logger.afterInterceptor(target, args);
}
Trace trace = traceContext.currentTraceObject();
@@ -1,19 +1,16 @@
package com.profiler.modifier.connector.httpclient4.interceptor;
import com.profiler.interceptor.*;
import com.profiler.logging.Logger;
import com.profiler.common.AnnotationKey;
import com.profiler.context.*;
import com.profiler.interceptor.TraceContextSupport;
import com.profiler.logging.LoggerFactory;
import com.profiler.sampler.util.SamplingFlagUtils;
import org.apache.http.HttpHost;
import org.apache.http.HttpRequest;
import com.profiler.common.ServiceType;
import com.profiler.interceptor.ByteCodeMethodDescriptorSupport;
import com.profiler.interceptor.MethodDescriptor;
import com.profiler.interceptor.StaticAroundInterceptor;
/**
* Method interceptor
@@ -28,7 +25,7 @@ import com.profiler.interceptor.StaticAroundInterceptor;
* throws IOException, ClientProtocolException {
* </pre>
*/
public class ExecuteMethodInterceptor implements StaticAroundInterceptor, ByteCodeMethodDescriptorSupport, TraceContextSupport {
public class ExecuteMethodInterceptor implements SimpleAroundInterceptor, ByteCodeMethodDescriptorSupport, TraceContextSupport {
private final Logger logger = LoggerFactory.getLogger(ExecuteMethodInterceptor.class.getName());
private final boolean isDebug = logger.isDebugEnabled();
@@ -38,9 +35,9 @@ public class ExecuteMethodInterceptor implements StaticAroundInterceptor, ByteCo
// private int apiId;
@Override
public void before(Object target, String className, String methodName, String parameterDescription, Object[] args) {
public void before(Object target, Object[] args) {
if (isDebug) {
logger.beforeInterceptor(target, className, methodName, parameterDescription, args);
logger.beforeInterceptor(target, args);
}
Trace trace = traceContext.currentRawTraceObject();
if (trace == null) {
@@ -84,10 +81,10 @@ public class ExecuteMethodInterceptor implements StaticAroundInterceptor, ByteCo
}
@Override
public void after(Object target, String className, String methodName, String parameterDescription, Object[] args, Object result) {
public void after(Object target, Object[] args, Object result) {
if (isDebug) {
// result는 로깅하지 않는다.
logger.afterInterceptor(target, className, methodName, parameterDescription, args);
logger.afterInterceptor(target, args);
}
Trace trace = traceContext.currentTraceObject();
@@ -1,15 +1,13 @@
package com.profiler.modifier.connector.jdkhttpconnector.interceptor;
import java.net.HttpURLConnection;
import com.profiler.interceptor.*;
import com.profiler.logging.Logger;
import com.profiler.common.AnnotationKey;
import com.profiler.common.ServiceType;
import com.profiler.context.*;
import com.profiler.interceptor.ByteCodeMethodDescriptorSupport;
import com.profiler.interceptor.MethodDescriptor;
import com.profiler.interceptor.StaticAroundInterceptor;
import com.profiler.interceptor.TraceContextSupport;
import com.profiler.logging.LoggerFactory;
import com.profiler.sampler.util.SamplingFlagUtils;
@@ -17,7 +15,7 @@ import com.profiler.sampler.util.SamplingFlagUtils;
* @author netspider
*
*/
public class ConnectMethodInterceptor implements StaticAroundInterceptor, ByteCodeMethodDescriptorSupport, TraceContextSupport {
public class ConnectMethodInterceptor implements SimpleAroundInterceptor, ByteCodeMethodDescriptorSupport, TraceContextSupport {
private final Logger logger = LoggerFactory.getLogger(ConnectMethodInterceptor.class.getName());
private final boolean isDebug = logger.isDebugEnabled();
@@ -26,9 +24,9 @@ public class ConnectMethodInterceptor implements StaticAroundInterceptor, ByteCo
private TraceContext traceContext;
@Override
public void before(Object target, String className, String methodName, String parameterDescription, Object[] args) {
public void before(Object target, Object[] args) {
if (isDebug) {
logger.beforeInterceptor(target, className, methodName, parameterDescription, args);
logger.beforeInterceptor(target, args);
}
Trace trace = traceContext.currentRawTraceObject();
if (trace == null) {
@@ -71,10 +69,10 @@ public class ConnectMethodInterceptor implements StaticAroundInterceptor, ByteCo
}
@Override
public void after(Object target, String className, String methodName, String parameterDescription, Object[] args, Object result) {
public void after(Object target, Object[] args, Object result) {
if (isDebug) {
// result는 로깅하지 않는다.
logger.afterInterceptor(target, className, methodName, parameterDescription, args);
logger.afterInterceptor(target, args);
}
Trace trace = traceContext.currentTraceObject();
@@ -1,5 +1,6 @@
package com.profiler.modifier.db.interceptor;
import com.profiler.interceptor.SimpleBeforeInterceptor;
import com.profiler.interceptor.StaticBeforeInterceptor;
import com.profiler.interceptor.util.JDBCScope;
import com.profiler.logging.LoggerFactory;
@@ -9,7 +10,7 @@ import com.profiler.util.MetaObject;
import java.sql.Connection;
import com.profiler.logging.Logger;
public class ConnectionCloseInterceptor implements StaticBeforeInterceptor {
public class ConnectionCloseInterceptor implements SimpleBeforeInterceptor {
private final Logger logger = LoggerFactory.getLogger(ConnectionCloseInterceptor.class.getName());
private final boolean isDebug = logger.isDebugEnabled();
@@ -19,9 +20,9 @@ public class ConnectionCloseInterceptor implements StaticBeforeInterceptor {
private final MetaObject setUrl = new MetaObject("__setUrl", Object.class);
@Override
public void before(Object target, String className, String methodName, String parameterDescription, Object[] args) {
public void before(Object target, Object[] args) {
if (isDebug) {
logger.beforeInterceptor(target, className, methodName, parameterDescription, args);
logger.beforeInterceptor(target, args);
}
if (JDBCScope.isInternal()) {
logger.info("internal jdbc scope. skip trace");
@@ -1,5 +1,6 @@
package com.profiler.modifier.db.interceptor;
import com.profiler.interceptor.SimpleAroundInterceptor;
import com.profiler.interceptor.StaticAroundInterceptor;
import com.profiler.logging.LoggerFactory;
import com.profiler.logging.LoggingUtils;
@@ -11,22 +12,22 @@ import com.profiler.logging.Logger;
/**
* Datasource의 get을 추적해야 될것으로 예상됨.
*/
public class DataSourceGetConnectionInterceptor implements StaticAroundInterceptor {
public class DataSourceGetConnectionInterceptor implements SimpleAroundInterceptor {
private final Logger logger = LoggerFactory.getLogger(DataSourceGetConnectionInterceptor.class.getName());
private final boolean isDebug = logger.isDebugEnabled();
@Override
public void before(Object target, String className, String methodName, String parameterDescription, Object[] args) {
public void before(Object target, Object[] args) {
if (isDebug) {
logger.beforeInterceptor(target, className, methodName, parameterDescription, args);
logger.beforeInterceptor(target, args);
}
}
@Override
public void after(Object target, String className, String methodName, String parameterDescription, Object[] args, Object result) {
public void after(Object target, Object[] args, Object result) {
if (isDebug) {
logger.afterInterceptor(target, className, methodName, parameterDescription, args, result);
logger.afterInterceptor(target, args, result);
}
if (!InterceptorUtils.isSuccess(result)) {
@@ -2,10 +2,7 @@ package com.profiler.modifier.db.interceptor;
import com.profiler.context.Trace;
import com.profiler.context.TraceContext;
import com.profiler.interceptor.ByteCodeMethodDescriptorSupport;
import com.profiler.interceptor.MethodDescriptor;
import com.profiler.interceptor.StaticAroundInterceptor;
import com.profiler.interceptor.TraceContextSupport;
import com.profiler.interceptor.*;
import com.profiler.interceptor.util.JDBCScope;
import com.profiler.logging.LoggerFactory;
import com.profiler.logging.LoggingUtils;
@@ -19,7 +16,7 @@ import com.profiler.logging.Logger;
/**
*
*/
public class DriverConnectInterceptor implements StaticAroundInterceptor, ByteCodeMethodDescriptorSupport, TraceContextSupport {
public class DriverConnectInterceptor implements SimpleAroundInterceptor, ByteCodeMethodDescriptorSupport, TraceContextSupport {
private final Logger logger = LoggerFactory.getLogger(DriverConnectInterceptor.class.getName());
private final boolean isDebug = logger.isDebugEnabled();
@@ -32,9 +29,9 @@ public class DriverConnectInterceptor implements StaticAroundInterceptor, ByteCo
private TraceContext traceContext;
@Override
public void before(Object target, String className, String methodName, String parameterDescription, Object[] args) {
public void before(Object target, Object[] args) {
if (isDebug) {
logger.beforeInterceptor(target, className, methodName, parameterDescription, args);
logger.beforeInterceptor(target, args);
logger.debug("JDBCScope push:{}", Thread.currentThread().getName());
}
JDBCScope.push();
@@ -49,9 +46,9 @@ public class DriverConnectInterceptor implements StaticAroundInterceptor, ByteCo
}
@Override
public void after(Object target, String className, String methodName, String parameterDescription, Object[] args, Object result) {
public void after(Object target, Object[] args, Object result) {
if (isDebug) {
logger.afterInterceptor(target, className, methodName, parameterDescription, args, result);
logger.afterInterceptor(target, args, result);
logger.debug("JDBCScope pop:{}", Thread.currentThread().getName());
}
// 여기서는 trace context인지 아닌지 확인하면 안된다. trace 대상 thread가 아닌곳에서 connection이 생성될수 있음.
@@ -14,7 +14,7 @@ import com.profiler.util.MetaObject;
import java.sql.Connection;
import com.profiler.logging.Logger;
public class PreparedStatementCreateInterceptor implements StaticAroundInterceptor, ByteCodeMethodDescriptorSupport, TraceContextSupport {
public class PreparedStatementCreateInterceptor implements SimpleAroundInterceptor, ByteCodeMethodDescriptorSupport, TraceContextSupport {
private final Logger logger = LoggerFactory.getLogger(PreparedStatementCreateInterceptor.class.getName());
private final boolean isDebug = logger.isDebugEnabled();
@@ -30,9 +30,9 @@ public class PreparedStatementCreateInterceptor implements StaticAroundIntercept
private TraceContext traceContext;
@Override
public void before(Object target, String className, String methodName, String parameterDescription, Object[] args) {
public void before(Object target, Object[] args) {
if (isDebug) {
logger.beforeInterceptor(target, className, methodName, parameterDescription, args);
logger.beforeInterceptor(target, args);
}
if (JDBCScope.isInternal()) {
logger.debug("internal jdbc scope. skip trace");
@@ -56,16 +56,16 @@ public class PreparedStatementCreateInterceptor implements StaticAroundIntercept
}
@Override
public void after(Object target, String className, String methodName, String parameterDescription, Object[] args, Object result) {
public void after(Object target, Object[] args, Object result) {
if (isDebug) {
logger.afterInterceptor(target, className, methodName, parameterDescription, args, result);
logger.afterInterceptor(target, args, result);
}
if (JDBCScope.isInternal()) {
logger.debug("internal jdbc scope. skip trace");
return;
}
boolean success = InterceptorUtils.isSuccess(result);
if(success) {
if (success) {
// preparedStatement의 생성이 성공하였을 경우만 PreparedStatement에 databaseInfo를 세팅해야 한다.
DatabaseInfo databaseInfo = (DatabaseInfo) getUrl.invoke(target);
this.setUrl.invoke(result, databaseInfo);
@@ -4,23 +4,21 @@ import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import com.profiler.interceptor.*;
import com.profiler.logging.Logger;
import com.profiler.common.AnnotationKey;
import com.profiler.common.util.ParsingResult;
import com.profiler.context.Trace;
import com.profiler.context.TraceContext;
import com.profiler.interceptor.ByteCodeMethodDescriptorSupport;
import com.profiler.interceptor.MethodDescriptor;
import com.profiler.interceptor.StaticAroundInterceptor;
import com.profiler.interceptor.TraceContextSupport;
import com.profiler.interceptor.util.JDBCScope;
import com.profiler.logging.LoggerFactory;
import com.profiler.logging.LoggingUtils;
import com.profiler.modifier.db.DatabaseInfo;
import com.profiler.util.MetaObject;
public class PreparedStatementExecuteQueryInterceptor implements StaticAroundInterceptor, ByteCodeMethodDescriptorSupport, TraceContextSupport {
public class PreparedStatementExecuteQueryInterceptor implements SimpleAroundInterceptor, ByteCodeMethodDescriptorSupport, TraceContextSupport {
private final Logger logger = LoggerFactory.getLogger(PreparedStatementExecuteQueryInterceptor.class.getName());
private final boolean isDebug = logger.isDebugEnabled();
@@ -35,19 +33,19 @@ public class PreparedStatementExecuteQueryInterceptor implements StaticAroundInt
private TraceContext traceContext;
@Override
public void before(Object target, String className, String methodName, String parameterDescription, Object[] args) {
public void before(Object target, Object[] args) {
if (isDebug) {
logger.beforeInterceptor(target, className, methodName, parameterDescription, args);
logger.beforeInterceptor(target, args);
}
if (JDBCScope.isInternal()) {
logger.debug("internal jdbc scope. skip trace");
return;
}
Trace trace = traceContext.currentTraceObject();
if (trace == null) {
return;
}
trace.traceBlockBegin();
trace.markBeforeTime();
try {
@@ -99,9 +97,9 @@ public class PreparedStatementExecuteQueryInterceptor implements StaticAroundInt
}
@Override
public void after(Object target, String className, String methodName, String parameterDescription, Object[] args, Object result) {
public void after(Object target, Object[] args, Object result) {
if (isDebug) {
logger.afterInterceptor(target, className, methodName, parameterDescription, args, result);
logger.afterInterceptor(target, args, result);
}
if (JDBCScope.isInternal()) {
return;
@@ -2,6 +2,7 @@ package com.profiler.modifier.db.interceptor;
import com.profiler.context.Trace;
import com.profiler.context.TraceContext;
import com.profiler.interceptor.SimpleAfterInterceptor;
import com.profiler.interceptor.StaticAfterInterceptor;
import com.profiler.interceptor.TraceContextSupport;
import com.profiler.interceptor.util.JDBCScope;
@@ -14,7 +15,7 @@ import com.profiler.util.MetaObject;
import java.sql.Connection;
import com.profiler.logging.Logger;
public class StatementCreateInterceptor implements StaticAfterInterceptor, TraceContextSupport {
public class StatementCreateInterceptor implements SimpleAfterInterceptor, TraceContextSupport {
private final Logger logger = LoggerFactory.getLogger(StatementCreateInterceptor.class.getName());
private final boolean isDebug = logger.isDebugEnabled();
@@ -26,9 +27,9 @@ public class StatementCreateInterceptor implements StaticAfterInterceptor, Trace
private TraceContext traceContext;
@Override
public void after(Object target, String className, String methodName, String parameterDescription, Object[] args, Object result) {
public void after(Object target, Object[] args, Object result) {
if (isDebug) {
logger.afterInterceptor(target, className, methodName, parameterDescription, args, result);
logger.afterInterceptor(target, args, result);
}
if (JDBCScope.isInternal()) {
logger.debug("internal jdbc scope. skip trace");
@@ -2,10 +2,7 @@ package com.profiler.modifier.db.interceptor;
import com.profiler.context.Trace;
import com.profiler.context.TraceContext;
import com.profiler.interceptor.ByteCodeMethodDescriptorSupport;
import com.profiler.interceptor.MethodDescriptor;
import com.profiler.interceptor.StaticAroundInterceptor;
import com.profiler.interceptor.TraceContextSupport;
import com.profiler.interceptor.*;
import com.profiler.interceptor.util.JDBCScope;
import com.profiler.logging.LoggerFactory;
import com.profiler.logging.LoggingUtils;
@@ -17,7 +14,7 @@ import com.profiler.logging.Logger;
/**
* @author netspider
*/
public class StatementExecuteQueryInterceptor implements StaticAroundInterceptor, ByteCodeMethodDescriptorSupport, TraceContextSupport {
public class StatementExecuteQueryInterceptor implements SimpleAroundInterceptor, ByteCodeMethodDescriptorSupport, TraceContextSupport {
private final Logger logger = LoggerFactory.getLogger(StatementExecuteQueryInterceptor.class.getName());
private final boolean isDebug = logger.isDebugEnabled();
@@ -27,9 +24,9 @@ public class StatementExecuteQueryInterceptor implements StaticAroundInterceptor
private TraceContext traceContext;
@Override
public void before(Object target, String className, String methodName, String parameterDescription, Object[] args) {
public void before(Object target, Object[] args) {
if (isDebug) {
logger.beforeInterceptor(target, className, methodName, parameterDescription, args);
logger.beforeInterceptor(target, args);
}
if (JDBCScope.isInternal()) {
logger.debug("internal jdbc scope. skip trace");
@@ -64,9 +61,9 @@ public class StatementExecuteQueryInterceptor implements StaticAroundInterceptor
@Override
public void after(Object target, String className, String methodName, String parameterDescription, Object[] args, Object result) {
public void after(Object target, Object[] args, Object result) {
if (isDebug) {
logger.afterInterceptor(target, className, methodName, parameterDescription, args, result);
logger.afterInterceptor(target, args, result);
}
if (JDBCScope.isInternal()) {
return;
@@ -2,10 +2,7 @@ package com.profiler.modifier.db.interceptor;
import com.profiler.context.Trace;
import com.profiler.context.TraceContext;
import com.profiler.interceptor.ByteCodeMethodDescriptorSupport;
import com.profiler.interceptor.MethodDescriptor;
import com.profiler.interceptor.StaticAroundInterceptor;
import com.profiler.interceptor.TraceContextSupport;
import com.profiler.interceptor.*;
import com.profiler.interceptor.util.JDBCScope;
import com.profiler.logging.LoggerFactory;
import com.profiler.logging.LoggingUtils;
@@ -19,7 +16,7 @@ import com.profiler.logging.Logger;
*
* @author netspider
*/
public class StatementExecuteUpdateInterceptor implements StaticAroundInterceptor, ByteCodeMethodDescriptorSupport, TraceContextSupport {
public class StatementExecuteUpdateInterceptor implements SimpleAroundInterceptor, ByteCodeMethodDescriptorSupport, TraceContextSupport {
private final Logger logger = LoggerFactory.getLogger(StatementExecuteUpdateInterceptor.class.getName());
private final boolean isDebug = logger.isDebugEnabled();
@@ -30,9 +27,9 @@ public class StatementExecuteUpdateInterceptor implements StaticAroundIntercepto
private TraceContext traceContext;
@Override
public void before(Object target, String className, String methodName, String parameterDescription, Object[] args) {
public void before(Object target, Object[] args) {
if (isDebug) {
logger.beforeInterceptor(target, className, methodName, parameterDescription, args);
logger.beforeInterceptor(target, args);
}
if (JDBCScope.isInternal()) {
logger.debug("internal jdbc scope. skip trace");
@@ -71,9 +68,9 @@ public class StatementExecuteUpdateInterceptor implements StaticAroundIntercepto
}
@Override
public void after(Object target, String className, String methodName, String parameterDescription, Object[] args, Object result) {
public void after(Object target, Object[] args, Object result) {
if (isDebug) {
logger.afterInterceptor(target, className, methodName, parameterDescription, args, result);
logger.afterInterceptor(target, args, result);
}
if (JDBCScope.isInternal()) {
return;
@@ -7,14 +7,13 @@ import com.profiler.common.ServiceType;
import com.profiler.context.Trace;
import com.profiler.context.TraceContext;
import com.profiler.interceptor.*;
import com.profiler.logging.LoggingUtils;
/**
*
* @author netspider
*
*/
public class MethodInterceptor implements StaticAroundInterceptor, ByteCodeMethodDescriptorSupport, ServiceTypeSupport, TraceContextSupport {
public class MethodInterceptor implements SimpleAroundInterceptor, ByteCodeMethodDescriptorSupport, ServiceTypeSupport, TraceContextSupport {
// method intereptor는 객체의 라이프 사이클을 알수 없이 자주 호출될수 있으므로 그냥 static으로 선언한다.
private static final Logger logger = LoggerFactory.getLogger(MethodInterceptor.class.getName());
private static final boolean isDebug = logger.isDebugEnabled();
@@ -25,9 +24,9 @@ public class MethodInterceptor implements StaticAroundInterceptor, ByteCodeMetho
@Override
public void before(Object target, String className, String methodName, String parameterDescription, Object[] args) {
public void before(Object target, Object[] args) {
if (isDebug) {
logger.beforeInterceptor(target, className, methodName, parameterDescription, args);
logger.beforeInterceptor(target, args);
}
Trace trace = traceContext.currentTraceObject();
@@ -42,9 +41,9 @@ public class MethodInterceptor implements StaticAroundInterceptor, ByteCodeMetho
}
@Override
public void after(Object target, String className, String methodName, String parameterDescription, Object[] args, Object result) {
public void after(Object target, Object[] args, Object result) {
if (isDebug) {
logger.afterInterceptor(target, className, methodName, parameterDescription, args);
logger.afterInterceptor(target, args);
}
Trace trace = traceContext.currentTraceObject();
@@ -2,6 +2,8 @@ package com.profiler.modifier.servlet.interceptors;
import java.util.Enumeration;
import java.util.UUID;
import com.profiler.interceptor.*;
import com.profiler.logging.Logger;
import com.profiler.logging.LoggerFactory;
@@ -10,14 +12,10 @@ import javax.servlet.http.HttpServletRequest;
import com.profiler.common.AnnotationKey;
import com.profiler.common.ServiceType;
import com.profiler.context.*;
import com.profiler.interceptor.ByteCodeMethodDescriptorSupport;
import com.profiler.interceptor.MethodDescriptor;
import com.profiler.interceptor.StaticAroundInterceptor;
import com.profiler.interceptor.TraceContextSupport;
import com.profiler.sampler.util.SamplingFlagUtils;
import com.profiler.util.NumberUtils;
public class HttpServletInterceptor implements StaticAroundInterceptor, ByteCodeMethodDescriptorSupport, TraceContextSupport {
public class HttpServletInterceptor implements SimpleAroundInterceptor, ByteCodeMethodDescriptorSupport, TraceContextSupport {
private final Logger logger = LoggerFactory.getLogger(HttpServletInterceptor.class);
private final boolean isDebug = logger.isDebugEnabled();
@@ -50,9 +48,9 @@ public class HttpServletInterceptor implements StaticAroundInterceptor, ByteCode
at java.lang.Thread.run(Thread.java:680)
*/
@Override
public void before(Object target, String className, String methodName, String parameterDescription, Object[] args) {
public void before(Object target, Object[] args) {
if (isDebug) {
logger.beforeInterceptor(target, className, methodName, parameterDescription, args);
logger.beforeInterceptor(target, args);
}
try {
@@ -101,9 +99,9 @@ public class HttpServletInterceptor implements StaticAroundInterceptor, ByteCode
}
@Override
public void after(Object target, String className, String methodName, String parameterDescription, Object[] args, Object result) {
public void after(Object target, Object[] args, Object result) {
if (isDebug) {
logger.afterInterceptor(target, className, methodName, parameterDescription, args, result);
logger.afterInterceptor(target, args, result);
}
Trace trace = traceContext.currentTraceObject();
@@ -1,18 +1,16 @@
package com.profiler.modifier.tomcat.interceptors;
import com.profiler.interceptor.SimpleBeforeInterceptor;
import com.profiler.logging.Logger;
import com.profiler.logging.LoggerFactory;
import com.profiler.Agent;
import com.profiler.DefaultAgent;
import com.profiler.interceptor.StaticBeforeInterceptor;
import com.profiler.logging.LoggingUtils;
import com.profiler.util.Assert;
/**
*
*/
public class CatalinaAwaitInterceptor implements StaticBeforeInterceptor {
public class CatalinaAwaitInterceptor implements SimpleBeforeInterceptor {
private Logger logger = LoggerFactory.getLogger(this.getClass().getName());
private final boolean isDebug = logger.isDebugEnabled();
@@ -25,9 +23,9 @@ public class CatalinaAwaitInterceptor implements StaticBeforeInterceptor {
}
@Override
public void before(Object target, String className, String methodName, String parameterDescription, Object[] args) {
public void before(Object target, Object[] args) {
if (isDebug) {
logger.beforeInterceptor(target, className, methodName, parameterDescription, args);
logger.beforeInterceptor(target, args);
}
agent.started();
// agent.sendStartupInfo();
@@ -1,8 +1,7 @@
package com.profiler.modifier.tomcat.interceptors;
import com.profiler.Agent;
import com.profiler.interceptor.StaticAfterInterceptor;
import com.profiler.logging.LoggingUtils;
import com.profiler.interceptor.SimpleAfterInterceptor;
import org.apache.catalina.connector.Connector;
import com.profiler.logging.Logger;
@@ -11,7 +10,7 @@ import com.profiler.logging.LoggerFactory;
/**
*
*/
public class ConnectorInitializeInterceptor implements StaticAfterInterceptor {
public class ConnectorInitializeInterceptor implements SimpleAfterInterceptor {
private Logger logger = LoggerFactory.getLogger(this.getClass().getName());
private final boolean isDebug = logger.isDebugEnabled();
@@ -26,9 +25,9 @@ public class ConnectorInitializeInterceptor implements StaticAfterInterceptor {
}
@Override
public void after(Object target, String className, String methodName, String parameterDescription, Object[] args, Object result) {
public void after(Object target, Object[] args, Object result) {
if (isDebug) {
logger.afterInterceptor(target, className, methodName, parameterDescription, args, result);
logger.afterInterceptor(target, args, result);
}
Connector connector = (Connector) target;
agent.addConnector(connector.getProtocol(), connector.getPort());
@@ -2,6 +2,8 @@ package com.profiler.modifier.tomcat.interceptors;
import java.util.Enumeration;
import java.util.UUID;
import com.profiler.interceptor.*;
import com.profiler.logging.Logger;
import com.profiler.logging.LoggerFactory;
@@ -10,15 +12,11 @@ import javax.servlet.http.HttpServletRequest;
import com.profiler.common.AnnotationKey;
import com.profiler.common.ServiceType;
import com.profiler.context.*;
import com.profiler.interceptor.ByteCodeMethodDescriptorSupport;
import com.profiler.interceptor.MethodDescriptor;
import com.profiler.interceptor.StaticAroundInterceptor;
import com.profiler.interceptor.TraceContextSupport;
import com.profiler.sampler.util.SamplingFlagUtils;
import com.profiler.util.NetworkUtils;
import com.profiler.util.NumberUtils;
public class StandardHostValveInvokeInterceptor implements StaticAroundInterceptor, ByteCodeMethodDescriptorSupport, TraceContextSupport {
public class StandardHostValveInvokeInterceptor implements SimpleAroundInterceptor, ByteCodeMethodDescriptorSupport, TraceContextSupport {
private final Logger logger = LoggerFactory.getLogger(StandardHostValveInvokeInterceptor.class.getName());
private final boolean isDebug = logger.isInfoEnabled();
@@ -28,9 +26,9 @@ public class StandardHostValveInvokeInterceptor implements StaticAroundIntercept
private TraceContext traceContext;
@Override
public void before(Object target, String className, String methodName, String parameterDescription, Object[] args) {
public void before(Object target, Object[] args) {
if (isDebug) {
logger.beforeInterceptor(target, className, methodName, parameterDescription, args);
logger.beforeInterceptor(target, args);
}
try {
@@ -108,9 +106,9 @@ public class StandardHostValveInvokeInterceptor implements StaticAroundIntercept
}
@Override
public void after(Object target, String className, String methodName, String parameterDescription, Object[] args, Object result) {
public void after(Object target, Object[] args, Object result) {
if (isDebug) {
logger.afterInterceptor(target, className, methodName, parameterDescription, args, result);
logger.afterInterceptor(target, args, result);
}
// traceContext.getActiveThreadCounter().end();
@@ -1,5 +1,6 @@
package com.profiler.modifier.tomcat.interceptors;
import com.profiler.interceptor.SimpleAfterInterceptor;
import com.profiler.logging.Logger;
import com.profiler.logging.LoggerFactory;
@@ -10,7 +11,7 @@ import com.profiler.logging.LoggingUtils;
/**
*
*/
public class StandardServiceStartInterceptor implements StaticAfterInterceptor {
public class StandardServiceStartInterceptor implements SimpleAfterInterceptor {
private final Logger logger = LoggerFactory.getLogger(StandardServiceStartInterceptor.class.getName());
private final boolean isDebug = logger.isDebugEnabled();
@@ -22,9 +23,9 @@ public class StandardServiceStartInterceptor implements StaticAfterInterceptor {
}
@Override
public void after(Object target, String className, String methodName, String parameterDescription, Object[] args, Object result) {
public void after(Object target, Object[] args, Object result) {
if (isDebug) {
logger.afterInterceptor(target, className, methodName, parameterDescription, args, result);
logger.afterInterceptor(target, args, result);
}
// if (!InterceptorUtils.isSuccess(result)) {
// return;
@@ -1,5 +1,6 @@
package com.profiler.modifier.tomcat.interceptors;
import com.profiler.interceptor.SimpleAfterInterceptor;
import com.profiler.logging.Logger;
import com.profiler.logging.LoggerFactory;
@@ -10,7 +11,7 @@ import com.profiler.logging.LoggingUtils;
/**
*
*/
public class StandardServiceStopInterceptor implements StaticAfterInterceptor {
public class StandardServiceStopInterceptor implements SimpleAfterInterceptor {
private final Logger logger = LoggerFactory.getLogger(StandardServiceStopInterceptor.class.getName());
private final boolean isDebug = logger.isDebugEnabled();
@@ -22,9 +23,9 @@ public class StandardServiceStopInterceptor implements StaticAfterInterceptor {
}
@Override
public void after(Object target, String className, String methodName, String parameterDescription, Object[] args, Object result) {
public void after(Object target, Object[] args, Object result) {
if (isDebug) {
LoggingUtils.logAfter(logger, target, className, methodName, parameterDescription, args, result);
logger.afterInterceptor(target, args, result);
}
// TODO 시작이 실패했을때 stop이 불러 지는가?
// if (!InterceptorUtils.isSuccess(result)) {