mirror of
https://github.com/wahyd4/pinpoint.git
synced 2026-08-21 02:35:53 +10:00
[강운덕] [LUCYSUS-1744]Event는 범위가 너무 넓어서 SpanEvent로 변경함.
git-svn-id: http://svn.bds.nhncorp.com/pe/hippo-tomcat-profiler/trunk@1276 84d0f5b1-2673-498c-a247-62c4ff18d310
This commit is contained in:
@@ -28,13 +28,13 @@ public class AsyncTrace {
|
||||
private final AtomicInteger state = new AtomicInteger(STATE_INIT);
|
||||
|
||||
private int asyncId = NON_REGIST;
|
||||
private SubSpan subSpan;
|
||||
private SpanEvent spanEvent;
|
||||
|
||||
private Storage storage;
|
||||
private TimerTask timeoutTask;
|
||||
|
||||
public AsyncTrace(SubSpan subspan) {
|
||||
this.subSpan = subspan;
|
||||
public AsyncTrace(SpanEvent spanEvent) {
|
||||
this.spanEvent = spanEvent;
|
||||
}
|
||||
|
||||
public void setStorage(Storage storage) {
|
||||
@@ -53,8 +53,8 @@ public class AsyncTrace {
|
||||
return asyncId;
|
||||
}
|
||||
|
||||
public SubSpan getSubSpan() {
|
||||
return subSpan;
|
||||
public SpanEvent getSpanEvent() {
|
||||
return spanEvent;
|
||||
}
|
||||
|
||||
private Object attachObject;
|
||||
@@ -71,15 +71,15 @@ public class AsyncTrace {
|
||||
}
|
||||
|
||||
public void markBeforeTime() {
|
||||
subSpan.setStartTime(System.currentTimeMillis());
|
||||
spanEvent.setStartTime(System.currentTimeMillis());
|
||||
}
|
||||
|
||||
public long getBeforeTime() {
|
||||
return subSpan.getStartTime();
|
||||
return spanEvent.getStartTime();
|
||||
}
|
||||
|
||||
public void traceBlockEnd() {
|
||||
logSpan(this.subSpan);
|
||||
logSpan(this.spanEvent);
|
||||
// clearReference();
|
||||
}
|
||||
|
||||
@@ -88,7 +88,7 @@ public class AsyncTrace {
|
||||
}
|
||||
|
||||
public void markAfterTime() {
|
||||
subSpan.setEndTime(System.currentTimeMillis());
|
||||
spanEvent.setEndTime(System.currentTimeMillis());
|
||||
}
|
||||
|
||||
|
||||
@@ -97,44 +97,44 @@ public class AsyncTrace {
|
||||
}
|
||||
|
||||
public void recordAttibute(final AnnotationKey key, final Object value) {
|
||||
subSpan.addAnnotation(new Annotation(key, value));
|
||||
spanEvent.addAnnotation(new Annotation(key, value));
|
||||
}
|
||||
|
||||
public void recordServiceType(final ServiceType serviceType) {
|
||||
this.subSpan.setServiceType(serviceType);
|
||||
this.spanEvent.setServiceType(serviceType);
|
||||
}
|
||||
|
||||
public void recordServiceName(final String serviceName) {
|
||||
this.subSpan.setServiceName(serviceName);
|
||||
this.spanEvent.setServiceName(serviceName);
|
||||
}
|
||||
|
||||
public void recordRpcName(final String rpcName) {
|
||||
this.subSpan.setRpc(rpcName);
|
||||
this.spanEvent.setRpc(rpcName);
|
||||
|
||||
}
|
||||
|
||||
|
||||
public void recordDestinationId(String destinationId) {
|
||||
this.subSpan.setDestionationId(destinationId);
|
||||
this.spanEvent.setDestionationId(destinationId);
|
||||
}
|
||||
|
||||
// TODO: final String... endPoint로 받으면 합치는데 비용이 들어가 그냥 한번에 받는게 나을것 같음.
|
||||
public void recordEndPoint(final String endPoint) {
|
||||
this.subSpan.setEndPoint(endPoint);
|
||||
this.spanEvent.setEndPoint(endPoint);
|
||||
}
|
||||
|
||||
private void annotate(final AnnotationKey key) {
|
||||
this.subSpan.addAnnotation(new Annotation(key));
|
||||
this.spanEvent.addAnnotation(new Annotation(key));
|
||||
|
||||
}
|
||||
|
||||
void logSpan(SubSpan subSpan) {
|
||||
void logSpan(SpanEvent spanEvent) {
|
||||
try {
|
||||
if (isDebug) {
|
||||
Thread thread = Thread.currentThread();
|
||||
logger.info("[WRITE SubSPAN]" + subSpan + " CurrentThreadID=" + thread.getId() + ",\n\t CurrentThreadName=" + thread.getName());
|
||||
logger.info("[WRITE SpanEvent]" + spanEvent + " CurrentThreadID=" + thread.getId() + ",\n\t CurrentThreadName=" + thread.getName());
|
||||
}
|
||||
this.storage.store(subSpan);
|
||||
this.storage.store(spanEvent);
|
||||
} catch (Exception e) {
|
||||
logger.log(Level.SEVERE, e.getMessage(), e);
|
||||
}
|
||||
@@ -146,7 +146,7 @@ public class AsyncTrace {
|
||||
|
||||
public void timeout() {
|
||||
if (state.compareAndSet(STATE_INIT, STATE_TIMEOUT)) {
|
||||
// TODO timeout subspan log 던지기.
|
||||
// TODO timeout spanEvent log 던지기.
|
||||
// 뭘 어떤 내용을 던져야 되는지 아직 모르겠음????
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,8 +26,8 @@ public class BypassStorage implements Storage {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void store(SubSpan subSpan) {
|
||||
dataSender.send(subSpan);
|
||||
public void store(SpanEvent spanEvent) {
|
||||
dataSender.send(spanEvent);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -2,7 +2,6 @@ package com.profiler.context;
|
||||
|
||||
import com.profiler.Agent;
|
||||
import com.profiler.common.ServiceType;
|
||||
import com.profiler.common.dto.thrift.Event;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -26,7 +25,7 @@ public class Span implements Thriftable {
|
||||
|
||||
private final List<Annotation> annotations = new ArrayList<Annotation>(5);
|
||||
|
||||
private List<SubSpan> subSpanList;
|
||||
private List<SpanEvent> spanEventList;
|
||||
|
||||
public Span(TraceID traceId) {
|
||||
this.traceID = traceId;
|
||||
@@ -92,12 +91,12 @@ public class Span implements Thriftable {
|
||||
this.serviceType = serviceType;
|
||||
}
|
||||
|
||||
public List<SubSpan> getSubSpanList() {
|
||||
return subSpanList;
|
||||
public List<SpanEvent> getSpanEventList() {
|
||||
return spanEventList;
|
||||
}
|
||||
|
||||
public void setSubSpanList(List<SubSpan> subSpanList) {
|
||||
this.subSpanList = subSpanList;
|
||||
public void setSpanEventList(List<SpanEvent> spanEventList) {
|
||||
this.spanEventList = spanEventList;
|
||||
}
|
||||
|
||||
public int getException() {
|
||||
@@ -173,15 +172,15 @@ public class Span implements Thriftable {
|
||||
|
||||
span.setFlag(traceID.getFlags());
|
||||
|
||||
List<SubSpan> subSpanList = this.getSubSpanList();
|
||||
if (subSpanList != null && subSpanList.size() != 0) {
|
||||
List<SpanEvent> spanEventList = this.getSpanEventList();
|
||||
if (spanEventList != null && spanEventList.size() != 0) {
|
||||
|
||||
List<Event> tSubSpanList = new ArrayList<Event>(subSpanList.size());
|
||||
for (SubSpan subSpan : subSpanList) {
|
||||
Event tSubSpan = subSpan.toThrift(true);
|
||||
tSubSpanList.add(tSubSpan);
|
||||
List<com.profiler.common.dto.thrift.SpanEvent> tSpanEventList = new ArrayList<com.profiler.common.dto.thrift.SpanEvent>(spanEventList.size());
|
||||
for (SpanEvent spanEvent : spanEventList) {
|
||||
com.profiler.common.dto.thrift.SpanEvent tSpanEvent = spanEvent.toThrift(true);
|
||||
tSpanEventList.add(tSpanEvent);
|
||||
}
|
||||
span.setSubSpanList(tSubSpanList);
|
||||
span.setSpanEventList(tSpanEventList);
|
||||
}
|
||||
|
||||
return span;
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package com.profiler.context;
|
||||
|
||||
import com.profiler.Agent;
|
||||
import com.profiler.common.dto.thrift.Event;
|
||||
import org.apache.thrift.TBase;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -13,17 +12,17 @@ import java.util.UUID;
|
||||
*/
|
||||
public class SpanChunk implements Thriftable {
|
||||
|
||||
private List<SubSpan> subSpanList = new ArrayList<SubSpan>();
|
||||
private List<SpanEvent> spanEventList = new ArrayList<SpanEvent>();
|
||||
|
||||
public SpanChunk(List<SubSpan> subSpanList) {
|
||||
this.subSpanList = subSpanList;
|
||||
public SpanChunk(List<SpanEvent> spanEventList) {
|
||||
this.spanEventList = spanEventList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TBase toThrift() {
|
||||
com.profiler.common.dto.thrift.SpanChunk tSpanChunk = new com.profiler.common.dto.thrift.SpanChunk();
|
||||
// TODO 반드시 1개 이상이라는 조건을 충족해야 된다.
|
||||
SubSpan first = subSpanList.get(0);
|
||||
SpanEvent first = spanEventList.get(0);
|
||||
Span parentSpan = first.getParentSpan();
|
||||
tSpanChunk.setAgentId(Agent.getInstance().getAgentId());
|
||||
tSpanChunk.setAgentIdentifier(Agent.getInstance().getIdentifier());
|
||||
@@ -33,51 +32,51 @@ public class SpanChunk implements Thriftable {
|
||||
tSpanChunk.setLeastTraceId(id.getLeastSignificantBits());
|
||||
tSpanChunk.setSpanId(parentSpan.getTraceID().getSpanId());
|
||||
|
||||
List<Event> tSubSpan = createSubSpan(subSpanList);
|
||||
List<com.profiler.common.dto.thrift.SpanEvent> tSpanEvent = createSpanEvent(spanEventList);
|
||||
|
||||
tSpanChunk.setSubSpanList(tSubSpan);
|
||||
tSpanChunk.setSpanEventList(tSpanEvent);
|
||||
|
||||
return tSpanChunk;
|
||||
}
|
||||
|
||||
private List<Event> createSubSpan(List<SubSpan> subSpanList) {
|
||||
List<Event> result = new ArrayList<Event>(subSpanList.size());
|
||||
for (SubSpan subSpan : subSpanList) {
|
||||
Event tSubSpan = new Event();
|
||||
private List<com.profiler.common.dto.thrift.SpanEvent> createSpanEvent(List<SpanEvent> spanEventList) {
|
||||
List<com.profiler.common.dto.thrift.SpanEvent> result = new ArrayList<com.profiler.common.dto.thrift.SpanEvent>(spanEventList.size());
|
||||
for (SpanEvent spanEvent : spanEventList) {
|
||||
com.profiler.common.dto.thrift.SpanEvent tSpanEvent = new com.profiler.common.dto.thrift.SpanEvent();
|
||||
|
||||
tSubSpan.setAgentId(Agent.getInstance().getAgentId());
|
||||
tSubSpan.setAgentIdentifier(Agent.getInstance().getIdentifier());
|
||||
tSpanEvent.setAgentId(Agent.getInstance().getAgentId());
|
||||
tSpanEvent.setAgentIdentifier(Agent.getInstance().getIdentifier());
|
||||
|
||||
long parentSpanStartTime = subSpan.getParentSpan().getStartTime();
|
||||
tSubSpan.setStartElapsed((int) (subSpan.getStartTime() - parentSpanStartTime));
|
||||
tSubSpan.setEndElapsed((int) (subSpan.getEndTime() - subSpan.getStartTime()));
|
||||
long parentSpanStartTime = spanEvent.getParentSpan().getStartTime();
|
||||
tSpanEvent.setStartElapsed((int) (spanEvent.getStartTime() - parentSpanStartTime));
|
||||
tSpanEvent.setEndElapsed((int) (spanEvent.getEndTime() - spanEvent.getStartTime()));
|
||||
|
||||
tSubSpan.setSequence(subSpan.getSequence());
|
||||
tSpanEvent.setSequence(spanEvent.getSequence());
|
||||
|
||||
tSubSpan.setRpc(subSpan.getRpc());
|
||||
// tSubSpan.setServiceName(subSpan.getServiceName());
|
||||
tSubSpan.setServiceType(subSpan.getServiceType().getCode());
|
||||
tSubSpan.setDestinationId(subSpan.getDestionationId());
|
||||
tSpanEvent.setRpc(spanEvent.getRpc());
|
||||
// tSpanEvent.setServiceName(spanEvent.getServiceName());
|
||||
tSpanEvent.setServiceType(spanEvent.getServiceType().getCode());
|
||||
tSpanEvent.setDestinationId(spanEvent.getDestionationId());
|
||||
|
||||
tSubSpan.setEndPoint(subSpan.getEndPoint());
|
||||
tSubSpan.setDestinationId(subSpan.getDestionationId());
|
||||
tSpanEvent.setEndPoint(spanEvent.getEndPoint());
|
||||
tSpanEvent.setDestinationId(spanEvent.getDestionationId());
|
||||
|
||||
// 여기서 데이터 인코딩을 하자.
|
||||
List<com.profiler.common.dto.thrift.Annotation> annotationList = new ArrayList<com.profiler.common.dto.thrift.Annotation>(subSpan.getAnnotationSize());
|
||||
for (Annotation a : subSpan.getAnnotations()) {
|
||||
List<com.profiler.common.dto.thrift.Annotation> annotationList = new ArrayList<com.profiler.common.dto.thrift.Annotation>(spanEvent.getAnnotationSize());
|
||||
for (Annotation a : spanEvent.getAnnotations()) {
|
||||
annotationList.add(a.toThrift());
|
||||
}
|
||||
|
||||
if (subSpan.getDepth() != -1) {
|
||||
tSubSpan.setDepth(subSpan.getDepth());
|
||||
if (spanEvent.getDepth() != -1) {
|
||||
tSpanEvent.setDepth(spanEvent.getDepth());
|
||||
}
|
||||
|
||||
if (subSpan.getNextSpanId() != -1) {
|
||||
tSubSpan.setNextSpanId(subSpan.getNextSpanId());
|
||||
if (spanEvent.getNextSpanId() != -1) {
|
||||
tSpanEvent.setNextSpanId(spanEvent.getNextSpanId());
|
||||
}
|
||||
|
||||
tSubSpan.setAnnotations(annotationList);
|
||||
result.add(tSubSpan);
|
||||
tSpanEvent.setAnnotations(annotationList);
|
||||
result.add(tSpanEvent);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
+22
-23
@@ -5,14 +5,13 @@ import java.util.List;
|
||||
|
||||
import com.profiler.Agent;
|
||||
import com.profiler.common.ServiceType;
|
||||
import com.profiler.common.dto.thrift.Event;
|
||||
|
||||
/**
|
||||
* Span represent RPC
|
||||
*
|
||||
* @author netspider
|
||||
*/
|
||||
public class SubSpan implements Thriftable {
|
||||
public class SpanEvent implements Thriftable {
|
||||
|
||||
private final Span parentSpan;
|
||||
|
||||
@@ -34,7 +33,7 @@ public class SubSpan implements Thriftable {
|
||||
private int nextSpanId = -1;
|
||||
private int depth = -1;
|
||||
|
||||
public SubSpan(Span parentSpan) {
|
||||
public SpanEvent(Span parentSpan) {
|
||||
this.parentSpan = parentSpan;
|
||||
}
|
||||
|
||||
@@ -170,55 +169,55 @@ public class SubSpan implements Thriftable {
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
public Event toThrift() {
|
||||
public com.profiler.common.dto.thrift.SpanEvent toThrift() {
|
||||
return toThrift(false);
|
||||
}
|
||||
|
||||
public Event toThrift(boolean child) {
|
||||
Event subSpan = new Event();
|
||||
public com.profiler.common.dto.thrift.SpanEvent toThrift(boolean child) {
|
||||
com.profiler.common.dto.thrift.SpanEvent spanEvent = new com.profiler.common.dto.thrift.SpanEvent();
|
||||
|
||||
long parentSpanStartTime = parentSpan.getStartTime();
|
||||
subSpan.setStartElapsed((int) (startTime - parentSpanStartTime));
|
||||
subSpan.setEndElapsed((int) (endTime - startTime));
|
||||
spanEvent.setStartElapsed((int) (startTime - parentSpanStartTime));
|
||||
spanEvent.setEndElapsed((int) (endTime - startTime));
|
||||
|
||||
subSpan.setSequence(sequence);
|
||||
spanEvent.setSequence(sequence);
|
||||
// 다른 span의 sub로 들어가지 않을 경우
|
||||
if (!child) {
|
||||
subSpan.setAgentId(Agent.getInstance().getAgentId());
|
||||
subSpan.setAgentIdentifier(Agent.getInstance().getIdentifier());
|
||||
spanEvent.setAgentId(Agent.getInstance().getAgentId());
|
||||
spanEvent.setAgentIdentifier(Agent.getInstance().getIdentifier());
|
||||
|
||||
TraceID parentSpanTraceID = parentSpan.getTraceID();
|
||||
subSpan.setMostTraceId(parentSpanTraceID.getId().getMostSignificantBits());
|
||||
subSpan.setLeastTraceId(parentSpanTraceID.getId().getLeastSignificantBits());
|
||||
subSpan.setSpanId(parentSpanTraceID.getSpanId());
|
||||
spanEvent.setMostTraceId(parentSpanTraceID.getId().getMostSignificantBits());
|
||||
spanEvent.setLeastTraceId(parentSpanTraceID.getId().getLeastSignificantBits());
|
||||
spanEvent.setSpanId(parentSpanTraceID.getSpanId());
|
||||
}
|
||||
|
||||
subSpan.setRpc(rpc);
|
||||
subSpan.setServiceName(serviceName);
|
||||
spanEvent.setRpc(rpc);
|
||||
spanEvent.setServiceName(serviceName);
|
||||
|
||||
if (serviceType != null) {
|
||||
subSpan.setServiceType(serviceType.getCode());
|
||||
spanEvent.setServiceType(serviceType.getCode());
|
||||
}
|
||||
|
||||
subSpan.setEndPoint(endPoint);
|
||||
subSpan.setDestinationId(this.destionationId);
|
||||
spanEvent.setEndPoint(endPoint);
|
||||
spanEvent.setDestinationId(this.destionationId);
|
||||
|
||||
// 여기서 데이터 인코딩을 하자.
|
||||
List<com.profiler.common.dto.thrift.Annotation> annotationList = new ArrayList<com.profiler.common.dto.thrift.Annotation>(annotations.size());
|
||||
for (Annotation a : annotations) {
|
||||
annotationList.add(a.toThrift());
|
||||
}
|
||||
subSpan.setAnnotations(annotationList);
|
||||
spanEvent.setAnnotations(annotationList);
|
||||
|
||||
if (depth != -1) {
|
||||
subSpan.setDepth(depth);
|
||||
spanEvent.setDepth(depth);
|
||||
}
|
||||
|
||||
if (nextSpanId != -1) {
|
||||
subSpan.setNextSpanId(nextSpanId);
|
||||
spanEvent.setNextSpanId(nextSpanId);
|
||||
}
|
||||
|
||||
return subSpan;
|
||||
return spanEvent;
|
||||
}
|
||||
|
||||
public void setDestinationAddress() {
|
||||
@@ -12,14 +12,14 @@ public interface Storage {
|
||||
DataSender getDataSender();
|
||||
|
||||
/**
|
||||
* store(Event subSpan)와 store(Span span)간 동기화가 구현되어 있어야 한다.
|
||||
* store(SpanEvent spanEvent)와 store(Span span)간 동기화가 구현되어 있어야 한다.
|
||||
*
|
||||
* @param subSpan
|
||||
* @param spanEvent
|
||||
*/
|
||||
void store(SubSpan subSpan);
|
||||
void store(SpanEvent spanEvent);
|
||||
|
||||
/**
|
||||
* store(Event subSpan)와 store(Span span)간 동기화가 구현되어 있어야 한다.
|
||||
* store(SpanEvent spanEvent)와 store(Span span)간 동기화가 구현되어 있어야 한다.
|
||||
*
|
||||
* @param span
|
||||
*/
|
||||
|
||||
@@ -4,11 +4,11 @@ package com.profiler.context;
|
||||
*
|
||||
*/
|
||||
public class SubStackFrame implements StackFrame {
|
||||
private SubSpan subSpan;
|
||||
private SpanEvent spanEvent;
|
||||
private int stackId;
|
||||
|
||||
public SubStackFrame(SubSpan subSpan) {
|
||||
this.subSpan = subSpan;
|
||||
public SubStackFrame(SpanEvent spanEvent) {
|
||||
this.spanEvent = spanEvent;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -23,30 +23,30 @@ public class SubStackFrame implements StackFrame {
|
||||
|
||||
@Override
|
||||
public void markBeforeTime() {
|
||||
subSpan.setStartTime(System.currentTimeMillis());
|
||||
spanEvent.setStartTime(System.currentTimeMillis());
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getBeforeTime() {
|
||||
return subSpan.getStartTime();
|
||||
return spanEvent.getStartTime();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void markAfterTime() {
|
||||
subSpan.setEndTime(System.currentTimeMillis());
|
||||
spanEvent.setEndTime(System.currentTimeMillis());
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getAfterTime() {
|
||||
return subSpan.getEndTime();
|
||||
return spanEvent.getEndTime();
|
||||
}
|
||||
|
||||
public void setSequence(short sequence) {
|
||||
subSpan.setSequence(sequence);
|
||||
spanEvent.setSequence(sequence);
|
||||
}
|
||||
|
||||
public SubSpan getSubSpan() {
|
||||
return subSpan;
|
||||
public SpanEvent getSpanEvent() {
|
||||
return spanEvent;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -19,7 +19,7 @@ public class TimeBaseStorage implements Storage {
|
||||
private long limitTime = 1000;
|
||||
private int bufferSize = 20;
|
||||
|
||||
private List<SubSpan> storage = new ArrayList<SubSpan>(bufferSize + RESERVE_BUFFER_SIZE);
|
||||
private List<SpanEvent> storage = new ArrayList<SpanEvent>(bufferSize + RESERVE_BUFFER_SIZE);
|
||||
private DataSender dataSender;
|
||||
|
||||
public TimeBaseStorage() {
|
||||
@@ -48,26 +48,26 @@ public class TimeBaseStorage implements Storage {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void store(SubSpan subSpan) {
|
||||
public void store(SpanEvent spanEvent) {
|
||||
// flush유무 확인
|
||||
if (!limit) {
|
||||
// 절대 시간만 체크한다. 1초 이내 라서 절대 데이터를 flush하지 않는다.
|
||||
synchronized (this) {
|
||||
addSubSpan(subSpan);
|
||||
addSpanEvent(spanEvent);
|
||||
}
|
||||
limit = checkLimit(subSpan);
|
||||
limit = checkLimit(spanEvent);
|
||||
} else {
|
||||
// 1초가 지났다면.
|
||||
// 데이터가 flushCount이상일 경우 먼저 flush한다.
|
||||
List<SubSpan> flushData = null;
|
||||
List<SpanEvent> flushData = null;
|
||||
synchronized (this) {
|
||||
if (!addSubSpan(subSpan)) {
|
||||
dataSender.send(subSpan);
|
||||
if (!addSpanEvent(spanEvent)) {
|
||||
dataSender.send(spanEvent);
|
||||
return;
|
||||
}
|
||||
if (storage.size() >= bufferSize) {
|
||||
flushData = storage;
|
||||
storage = new ArrayList<SubSpan>(bufferSize + RESERVE_BUFFER_SIZE);
|
||||
storage = new ArrayList<SpanEvent>(bufferSize + RESERVE_BUFFER_SIZE);
|
||||
}
|
||||
}
|
||||
if (flushData != null) {
|
||||
@@ -76,19 +76,19 @@ public class TimeBaseStorage implements Storage {
|
||||
}
|
||||
}
|
||||
|
||||
private boolean addSubSpan(SubSpan subSpan) {
|
||||
private boolean addSpanEvent(SpanEvent spanEvent) {
|
||||
if (storage == null) {
|
||||
Logger logger = Logger.getLogger(this.getClass().getName());
|
||||
logger.fine("storage is null. direct send");
|
||||
// 이미 span이 와서 flush된 상황임.
|
||||
return false;
|
||||
}
|
||||
storage.add(subSpan);
|
||||
storage.add(spanEvent);
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean checkLimit(SubSpan subSpan) {
|
||||
return checkLimit(subSpan.getParentSpan());
|
||||
private boolean checkLimit(SpanEvent spanEvent) {
|
||||
return checkLimit(spanEvent.getParentSpan());
|
||||
}
|
||||
|
||||
private boolean checkLimit(Span span) {
|
||||
@@ -120,13 +120,13 @@ public class TimeBaseStorage implements Storage {
|
||||
}
|
||||
|
||||
private void flushAll(Span span) {
|
||||
List<SubSpan> subSpanList;
|
||||
List<SpanEvent> spanEventList;
|
||||
synchronized (this) {
|
||||
subSpanList = storage;
|
||||
spanEventList = storage;
|
||||
this.storage = null;
|
||||
}
|
||||
if (subSpanList != null && subSpanList.size() != 0) {
|
||||
span.setSubSpanList(subSpanList);
|
||||
if (spanEventList != null && spanEventList.size() != 0) {
|
||||
span.setSpanEventList(spanEventList);
|
||||
}
|
||||
dataSender.send(span);
|
||||
}
|
||||
|
||||
@@ -69,17 +69,17 @@ public final class Trace {
|
||||
|
||||
public AsyncTrace createAsyncTrace() {
|
||||
// 경우에 따라 별도 timeout 처리가 있어야 될수도 있음.
|
||||
SubSpan subSpan = new SubSpan(callStack.getSpan());
|
||||
subSpan.setSequence(getSequence());
|
||||
AsyncTrace asyncTrace = new AsyncTrace(subSpan);
|
||||
SpanEvent spanEvent = new SpanEvent(callStack.getSpan());
|
||||
spanEvent.setSequence(getSequence());
|
||||
AsyncTrace asyncTrace = new AsyncTrace(spanEvent);
|
||||
// asyncTrace.setDataSender(this.getDataSender());
|
||||
asyncTrace.setStorage(this.storage);
|
||||
return asyncTrace;
|
||||
}
|
||||
|
||||
private StackFrame createSubStackFrame(int stackId) {
|
||||
SubSpan subSpan = new SubSpan(callStack.getSpan());
|
||||
SubStackFrame stackFrame = new SubStackFrame(subSpan);
|
||||
SpanEvent spanEvent = new SpanEvent(callStack.getSpan());
|
||||
SubStackFrame stackFrame = new SubStackFrame(spanEvent);
|
||||
stackFrame.setStackFrameId(stackId);
|
||||
stackFrame.setSequence(getSequence());
|
||||
return stackFrame;
|
||||
@@ -124,8 +124,8 @@ public final class Trace {
|
||||
|
||||
if (latestStackIndex != currentStackIndex) {
|
||||
latestStackIndex = currentStackIndex;
|
||||
SubSpan span = ((SubStackFrame) stackFrame).getSubSpan();
|
||||
span.setDepth(latestStackIndex);
|
||||
SpanEvent spanEvent = ((SubStackFrame) stackFrame).getSpanEvent();
|
||||
spanEvent.setDepth(latestStackIndex);
|
||||
}
|
||||
|
||||
callStack.setStackFrame(stackFrame);
|
||||
@@ -152,7 +152,7 @@ public final class Trace {
|
||||
if (currentStackFrame instanceof RootStackFrame) {
|
||||
logSpan(((RootStackFrame) currentStackFrame).getSpan());
|
||||
} else {
|
||||
logSpan(((SubStackFrame) currentStackFrame).getSubSpan());
|
||||
logSpan(((SubStackFrame) currentStackFrame).getSpanEvent());
|
||||
}
|
||||
callStack.pop();
|
||||
}
|
||||
@@ -178,12 +178,12 @@ public final class Trace {
|
||||
tracingEnabled = false;
|
||||
}
|
||||
|
||||
void logSpan(SubSpan subSpan) {
|
||||
void logSpan(SpanEvent spanEvent) {
|
||||
if (isDebug) {
|
||||
Thread th = Thread.currentThread();
|
||||
logger.fine("[WRITE SubSPAN]" + subSpan + ", Thread ID=" + th.getId() + " Name=" + th.getName());
|
||||
logger.fine("[WRITE SpanEvent]" + spanEvent + ", Thread ID=" + th.getId() + " Name=" + th.getName());
|
||||
}
|
||||
this.storage.store(subSpan);
|
||||
this.storage.store(spanEvent);
|
||||
}
|
||||
|
||||
void logSpan(Span span) {
|
||||
@@ -271,8 +271,8 @@ public final class Trace {
|
||||
Span span = ((RootStackFrame) currentStackFrame).getSpan();
|
||||
span.addAnnotation(new Annotation(key, value));
|
||||
} else {
|
||||
SubSpan span = ((SubStackFrame) currentStackFrame).getSubSpan();
|
||||
span.addAnnotation(new Annotation(key, value));
|
||||
SpanEvent spanEvent = ((SubStackFrame) currentStackFrame).getSpanEvent();
|
||||
spanEvent.addAnnotation(new Annotation(key, value));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -285,8 +285,8 @@ public final class Trace {
|
||||
Span span = ((RootStackFrame) currentStackFrame).getSpan();
|
||||
span.setServiceType(serviceType);
|
||||
} else {
|
||||
SubSpan span = ((SubStackFrame) currentStackFrame).getSubSpan();
|
||||
span.setServiceType(serviceType);
|
||||
SpanEvent spanEvent = ((SubStackFrame) currentStackFrame).getSpanEvent();
|
||||
spanEvent.setServiceType(serviceType);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -297,8 +297,8 @@ public final class Trace {
|
||||
Span span = ((RootStackFrame) currentStackFrame).getSpan();
|
||||
span.setServiceName(serviceName);
|
||||
} else {
|
||||
SubSpan span = ((SubStackFrame) currentStackFrame).getSubSpan();
|
||||
span.setServiceName(serviceName);
|
||||
SpanEvent spanEvent = ((SubStackFrame) currentStackFrame).getSpanEvent();
|
||||
spanEvent.setServiceName(serviceName);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -310,8 +310,8 @@ public final class Trace {
|
||||
Span span = ((RootStackFrame) currentStackFrame).getSpan();
|
||||
span.setRpc(rpc);
|
||||
} else {
|
||||
SubSpan span = ((SubStackFrame) currentStackFrame).getSubSpan();
|
||||
span.setRpc(rpc);
|
||||
SpanEvent spanEvent = ((SubStackFrame) currentStackFrame).getSpanEvent();
|
||||
spanEvent.setRpc(rpc);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -320,8 +320,8 @@ public final class Trace {
|
||||
// TODO API 단일화 필요.
|
||||
StackFrame currentStackFrame = getCurrentStackFrame();
|
||||
if (currentStackFrame instanceof SubStackFrame) {
|
||||
SubSpan subSpan = ((SubStackFrame) currentStackFrame).getSubSpan();
|
||||
subSpan.setDestionationId(destinationId);
|
||||
SpanEvent spanEvent = ((SubStackFrame) currentStackFrame).getSpanEvent();
|
||||
spanEvent.setDestionationId(destinationId);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -329,8 +329,8 @@ public final class Trace {
|
||||
// TODO API 단일화 필요.
|
||||
StackFrame currentStackFrame = getCurrentStackFrame();
|
||||
if (currentStackFrame instanceof SubStackFrame) {
|
||||
SubSpan subSpan = ((SubStackFrame) currentStackFrame).getSubSpan();
|
||||
subSpan.setDestinationAddress();
|
||||
SpanEvent spanEvent = ((SubStackFrame) currentStackFrame).getSpanEvent();
|
||||
spanEvent.setDestinationAddress();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -345,8 +345,8 @@ public final class Trace {
|
||||
Span span = ((RootStackFrame) currentStackFrame).getSpan();
|
||||
span.setEndPoint(endPoint);
|
||||
} else {
|
||||
SubSpan span = ((SubStackFrame) currentStackFrame).getSubSpan();
|
||||
span.setEndPoint(endPoint);
|
||||
SpanEvent spanEvent = ((SubStackFrame) currentStackFrame).getSpanEvent();
|
||||
spanEvent.setEndPoint(endPoint);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -366,8 +366,8 @@ public final class Trace {
|
||||
if (currentStackFrame instanceof RootStackFrame) {
|
||||
logger.log(Level.WARNING, "OMG. Something's going wrong. Current stackframe is root Span. nextSpanId={}", spanId);
|
||||
} else {
|
||||
SubSpan span = ((SubStackFrame) currentStackFrame).getSubSpan();
|
||||
span.setNextSpanId(spanId);
|
||||
SpanEvent spanEvent = ((SubStackFrame) currentStackFrame).getSpanEvent();
|
||||
spanEvent.setNextSpanId(spanId);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -377,8 +377,8 @@ public final class Trace {
|
||||
Span span = ((RootStackFrame) currentStackFrame).getSpan();
|
||||
span.addAnnotation(new Annotation(key));
|
||||
} else {
|
||||
SubSpan span = ((SubStackFrame) currentStackFrame).getSubSpan();
|
||||
span.addAnnotation(new Annotation(key));
|
||||
SpanEvent spanEvent = ((SubStackFrame) currentStackFrame).getSpanEvent();
|
||||
spanEvent.addAnnotation(new Annotation(key));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user