[강운덕] [LUCYSUS-1744] exception발생시의 데이터인 exceptionId, exceptionMessage를 한번에 묶어서 span, spanEvent에 저장하도록 개선.

git-svn-id: http://svn.bds.nhncorp.com/pe/hippo-tomcat-profiler/trunk@2535 84d0f5b1-2673-498c-a247-62c4ff18d310
This commit is contained in:
Woonduk Kang
2013-10-16 10:46:48 +00:00
parent 92051897b3
commit ace4256baa
9 changed files with 33 additions and 21 deletions
@@ -114,6 +114,7 @@ public class DefaultAsyncTrace implements AsyncTrace {
if (result instanceof Throwable) {
Throwable th = (Throwable) result;
String drop = StringUtils.drop(th.getMessage());
recordAttribute(AnnotationKey.EXCEPTION, drop);
// TODO 비동기 api일 경우, span에 exception을 마크하기가 까다로움
@@ -225,10 +225,9 @@ public final class DefaultTrace implements Trace {
if (result instanceof Throwable) {
final Throwable th = (Throwable) result;
final String drop = StringUtils.drop(th.getMessage(), 256);
// this.currentStackFrame.setExceptionId();
recordAttribute(AnnotationKey.EXCEPTION, drop);
recordAttribute(AnnotationKey.EXCEPTION_CLASS, th.getClass().getName());
// exception class가 proxy라서 class Name이 불규칙하면 문제가 발생할수 있다.
final int exceptionId = traceContext.cacheString(th.getClass().getName());
this.currentStackFrame.setExceptionInfo(exceptionId, drop);
final Span span = getCallStack().getSpan();
if (!span.isSetErrCode()) {
@@ -68,8 +68,8 @@ public class RootStackFrame implements StackFrame {
}
@Override
public void setExceptionId(int id) {
this.span.setExceptionId(id);
public void setExceptionInfo(int exceptionId, String exceptionMessage) {
this.span.setExceptionInfo(exceptionId, exceptionMessage);
}
@Override
@@ -2,6 +2,7 @@ package com.nhn.pinpoint.profiler.context;
import com.nhn.pinpoint.profiler.AgentInformation;
import com.nhn.pinpoint.profiler.DefaultAgent;
import com.nhn.pinpoint.thrift.dto.TIntStringValue;
import com.nhn.pinpoint.thrift.dto.TSpan;
/**
@@ -60,14 +61,12 @@ public class Span extends TSpan implements Thriftable {
this.addToAnnotations(annotation);
}
@Override
public void setExceptionId(int exceptionId) {
super.setExceptionId(exceptionId);
}
@Override
public int getExceptionId() {
return super.getExceptionId();
public void setExceptionInfo(int exceptionClassId, String exceptionMessage) {
final TIntStringValue exceptionInfo = new TIntStringValue(exceptionClassId);
if (exceptionMessage != null && !exceptionMessage.isEmpty()) {
exceptionInfo.setStringValue(exceptionMessage);
}
super.setExceptionInfo(exceptionInfo);
}
public boolean isSetErrCode() {
@@ -2,6 +2,7 @@ package com.nhn.pinpoint.profiler.context;
import com.nhn.pinpoint.profiler.DefaultAgent;
import com.nhn.pinpoint.thrift.dto.TAgentKey;
import com.nhn.pinpoint.thrift.dto.TIntStringValue;
import com.nhn.pinpoint.thrift.dto.TSpanEvent;
/**
@@ -28,6 +29,14 @@ public class SpanEvent extends TSpanEvent implements Thriftable {
this.addToAnnotations(annotation);
}
public void setExceptionInfo(int exceptionClassId, String exceptionMessage) {
final TIntStringValue exceptionInfo = new TIntStringValue(exceptionClassId);
if (exceptionMessage != null && !exceptionMessage.isEmpty()) {
exceptionInfo.setStringValue(exceptionMessage);
}
super.setExceptionInfo(exceptionInfo);
}
public void markStartTime() {
// spanEvent.setStartElapsed((int) (startTime - parentSpanStartTime));
@@ -68,8 +68,8 @@ public class SpanEventStackFrame implements StackFrame {
}
@Override
public void setExceptionId(int id) {
// this.spanEvent.setExceptionId(id);
public void setExceptionInfo(int exceptionId, String exceptionMessage) {
this.spanEvent.setExceptionInfo(exceptionId, exceptionMessage);
}
@Override
@@ -23,7 +23,7 @@ public interface StackFrame {
void setApiId(int apiId);
void setExceptionId(int id);
void setExceptionInfo(int exceptionId, String exceptionMessage);
void setServiceType(short serviceType);
@@ -26,6 +26,7 @@ import com.nhn.pinpoint.profiler.util.MetaObject;
/**
*
*/
@Deprecated
public class BaseOperationTransitionStateInterceptor implements SimpleAroundInterceptor, ByteCodeMethodDescriptorSupport, TraceContextSupport {
private final PLogger logger = PLoggerFactory.getLogger(this.getClass());
@@ -70,7 +70,7 @@ public class FutureGetInterceptor implements SimpleAroundInterceptor, ByteCodeMe
// trace.recordAttribute(AnnotationKey.ARCUS_COMMAND, annotation);
// find the target node
Operation op = (Operation) getOperation.invoke(target);
final Operation op = (Operation) getOperation.invoke(target);
if (op != null) {
MemcachedNode handlingNode = op.getHandlingNode();
SocketAddress socketAddress = handlingNode.getSocketAddress();
@@ -92,10 +92,13 @@ public class FutureGetInterceptor implements SimpleAroundInterceptor, ByteCodeMe
trace.recordServiceType(ServiceType.MEMCACHED_FUTURE_GET);
}
trace.recordException(op.getException());
if (op.isCancelled()) {
trace.recordAttribute(AnnotationKey.EXCEPTION, "cancelled by user");
if (op != null) {
trace.recordException(op.getException());
}
// cancel일때 exception은 안던지는 것인가?
// if (op.isCancelled()) {
// trace.recordAttribute(AnnotationKey.EXCEPTION, "cancelled by user");
// }
trace.markAfterTime();
} finally {