mirror of
https://github.com/wahyd4/pinpoint.git
synced 2026-08-17 08:46:22 +10:00
[유치수] [NOBTS] refactor
git-svn-id: http://svn.bds.nhncorp.com/pe/hippo-tomcat-profiler/trunk@582 84d0f5b1-2673-498c-a247-62c4ff18d310
This commit is contained in:
@@ -35,8 +35,16 @@ public class StopWatch {
|
||||
// TODO application 에러로 전달되는경우가 있어서 일단 0으로
|
||||
return -1;
|
||||
} else {
|
||||
if (map.containsKey(id)) {
|
||||
return System.nanoTime() - map.get(id);
|
||||
Long startTime = map.get(id);
|
||||
|
||||
map.remove(id);
|
||||
// TODO: if using thread pool, this is unnecessary.
|
||||
// if (map.size() == 0) {
|
||||
// local.remove();
|
||||
// }
|
||||
|
||||
if (startTime != null) {
|
||||
return System.nanoTime() - startTime;
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -43,10 +43,10 @@ public final class Trace {
|
||||
}
|
||||
|
||||
public static boolean removeTraceId() {
|
||||
TraceID traceID = traceIdLocal.get();
|
||||
if (traceID != null) {
|
||||
TraceID traceId = traceIdLocal.get();
|
||||
if (traceId != null) {
|
||||
traceIdLocal.remove();
|
||||
spanMap.remove(traceID);
|
||||
spanMap.remove(traceId);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@@ -77,6 +77,18 @@ public final class Trace {
|
||||
public static void setTraceId(TraceID traceId) {
|
||||
if (getCurrentTraceId() != null) {
|
||||
logger.log(Level.WARNING, "TraceID is already exists. But overwritten.");
|
||||
|
||||
//TODO: remove this, just for debugging.
|
||||
System.out.println("###############################################################################################################");
|
||||
System.out.println("# [DEBUG MSG] TraceID is overwritten.");
|
||||
System.out.println("# Before : " + getCurrentTraceId());
|
||||
System.out.println("# After : " + traceId);
|
||||
System.out.println("###############################################################################################################");
|
||||
try {
|
||||
throw new RuntimeException("TraceID overwritten.");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
Trace.traceIdLocal.set(traceId);
|
||||
}
|
||||
@@ -84,7 +96,7 @@ public final class Trace {
|
||||
private static void mutate(TraceID traceId, SpanUpdater spanUpdater) {
|
||||
Span span = spanMap.update(traceId, spanUpdater);
|
||||
|
||||
if (span.isExistsAnnotationType("CR") || span.isExistsAnnotationType("SS")) {
|
||||
if (span.isExistsAnnotationType(Annotation.ClientRecv.getCode()) || span.isExistsAnnotationType(Annotation.ServerSend.getCode())) {
|
||||
spanMap.remove(traceId);
|
||||
logSpan(span);
|
||||
}
|
||||
@@ -93,15 +105,15 @@ public final class Trace {
|
||||
static void logSpan(Span span) {
|
||||
try {
|
||||
// TODO: send span to the server.
|
||||
System.out.println("\n\n[WRITE SPAN] hashCode=" + span.hashCode() + ", Value=" + span + ", SpanMap.size=" + spanMap.size() + ", CurrentThreadID=" + Thread.currentThread().getId() + "\n\n");
|
||||
System.out.println("\n\n[WRITE SPAN] hashCode=" + span.hashCode() + ", Value=" + span + ", SpanMap.size=" + spanMap.size() + ", CurrentThreadID=" + Thread.currentThread().getId() + ", CurrentThreadName=" + Thread.currentThread().getName() +"\n\n");
|
||||
|
||||
// TODO: remove this, just for debugging
|
||||
if(spanMap.size() > 0) {
|
||||
System.out.println("###############################################################");
|
||||
System.out.println("# WARNING SpanMap size > 0 check spanMap. #");
|
||||
System.out.println("###############################################################");
|
||||
if (spanMap.size() > 0) {
|
||||
System.out.println("##################################################################");
|
||||
System.out.println("# [DEBUG MSG] WARNING SpanMap size > 0 check spanMap. #");
|
||||
System.out.println("##################################################################");
|
||||
}
|
||||
|
||||
|
||||
DataSender.getInstance().addDataToSend(span.toThrift());
|
||||
|
||||
span.cancelTimer();
|
||||
|
||||
@@ -29,6 +29,10 @@ public class InvokeMethodInterceptor implements StaticAroundInterceptor {
|
||||
if (traceId != null) {
|
||||
Trace.setTraceId(traceId);
|
||||
} else {
|
||||
System.out.println(requestURL);
|
||||
System.out.println(clientIP);
|
||||
System.out.println(parameters);
|
||||
|
||||
Trace.setTraceId(TraceID.newTraceId());
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user