mirror of
https://github.com/wahyd4/pinpoint.git
synced 2026-08-22 19:27:13 +10:00
[강운덕] [LUCYSUS-1744] Span 데이터 구조를 api 호출 방식으로 변경하기 위해서 start end time위주로 변경함.
git-svn-id: http://svn.bds.nhncorp.com/pe/hippo-tomcat-profiler/trunk@874 84d0f5b1-2673-498c-a247-62c4ff18d310
This commit is contained in:
@@ -1,10 +1,7 @@
|
||||
package com.profiler.context;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.TimerTask;
|
||||
|
||||
import com.profiler.Agent;
|
||||
|
||||
@@ -16,7 +13,10 @@ import com.profiler.Agent;
|
||||
public class Span {
|
||||
|
||||
private final TraceID traceID;
|
||||
private final long createTime;
|
||||
|
||||
private long startTime;
|
||||
|
||||
private long endTime;
|
||||
|
||||
private String serviceName;
|
||||
private String name;
|
||||
@@ -25,23 +25,18 @@ public class Span {
|
||||
|
||||
private final List<HippoAnnotation> annotations = new ArrayList<HippoAnnotation>(5);
|
||||
|
||||
private long rpcStartTime;
|
||||
private long rpcEndTime;
|
||||
|
||||
public Span(TraceID traceId, String name, String endPoint) {
|
||||
this.traceID = traceId;
|
||||
this.name = name;
|
||||
this.endPoint = endPoint;
|
||||
this.createTime = System.currentTimeMillis();
|
||||
}
|
||||
|
||||
public TraceID getTraceID() {
|
||||
return traceID;
|
||||
}
|
||||
|
||||
|
||||
public boolean addAnnotation(HippoAnnotation annotation) {
|
||||
if (annotation.getKey().equals(Annotation.ClientSend.getCode()) || annotation.getKey().equals(Annotation.ServerRecv.getCode())) {
|
||||
rpcStartTime = annotation.getTimestamp();
|
||||
}
|
||||
if (annotation.getKey().equals(Annotation.ClientRecv.getCode()) || annotation.getKey().equals(Annotation.ServerSend.getCode())) {
|
||||
rpcEndTime = annotation.getTimestamp();
|
||||
}
|
||||
return annotations.add(annotation);
|
||||
}
|
||||
|
||||
@@ -82,25 +77,29 @@ public class Span {
|
||||
this.isTerminal = isTerminal;
|
||||
}
|
||||
|
||||
public long getRpcStartTime() {
|
||||
return rpcStartTime;
|
||||
public void setStartTime(long startTime) {
|
||||
this.startTime = startTime;
|
||||
}
|
||||
|
||||
public long getRpcEndTime() {
|
||||
return rpcEndTime;
|
||||
public long getStartTime() {
|
||||
return startTime;
|
||||
}
|
||||
|
||||
public long getCreateTime() {
|
||||
return createTime;
|
||||
public void setEndTime(long endTime) {
|
||||
this.endTime = endTime;
|
||||
}
|
||||
|
||||
public long getEndTime() {
|
||||
return endTime;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
sb.append("{");
|
||||
sb.append("\n\t TraceID = ").append(traceID);
|
||||
sb.append(",\n\t CreateTime = ").append(createTime);
|
||||
sb.append(",\n\t StartTime = ").append(startTime);
|
||||
sb.append(",\n\t EndTime = ").append(endTime);
|
||||
sb.append(",\n\t Name = ").append(name);
|
||||
sb.append(",\n\t ServiceName = ").append(serviceName);
|
||||
sb.append(",\n\t EndPoint = ").append(endPoint);
|
||||
@@ -120,7 +119,9 @@ public class Span {
|
||||
com.profiler.common.dto.thrift.Span span = new com.profiler.common.dto.thrift.Span();
|
||||
|
||||
span.setAgentId(Agent.getInstance().getAgentId());
|
||||
span.setTimestamp(createTime);
|
||||
span.setTimestamp(startTime);
|
||||
// TODO api를 생성하고 여기를 고치자.
|
||||
//span.setEndTime(startTime);
|
||||
span.setMostTraceId(traceID.getId().getMostSignificantBits());
|
||||
span.setLeastTraceId(traceID.getId().getLeastSignificantBits());
|
||||
span.setName(name);
|
||||
@@ -130,8 +131,7 @@ public class Span {
|
||||
span.setEndPoint(endPoint);
|
||||
span.setTerminal(isTerminal);
|
||||
|
||||
// TODO: set duration.
|
||||
|
||||
// 여기서 데이터 인코딩을 하자.
|
||||
List<com.profiler.common.dto.thrift.Annotation> annotationList = new ArrayList<com.profiler.common.dto.thrift.Annotation>(annotations.size());
|
||||
for (HippoAnnotation a : annotations) {
|
||||
annotationList.add(a.toThrift());
|
||||
|
||||
Reference in New Issue
Block a user