Remove multi globalTraceIds in context carrier.
This commit is contained in:
parent
79a45823b6
commit
07ae13a650
10
README.md
10
README.md
|
|
@ -19,16 +19,6 @@ Sky Walking | [中文](https://github.com/wu-sheng/sky-walking/wiki/sky-walking-
|
|||
* High performance streaming analysis.
|
||||
* The UI released on [wu-sheng/sky-walking-ui](https://github.com/wu-sheng/sky-walking-ui)
|
||||
|
||||
___
|
||||
|
||||
<a href="https://github.com/wu-sheng/sky-walking">
|
||||
<img src="https://sky-walking.github.io/page-resources/3.0/oneapm-award.png" alt="OneAPM Open Source Achievement Award" height="110px" align="left" />
|
||||
</a>
|
||||
|
||||
In October 2016, Sky Walking won `OneAPM Open Source Achievement Award`. The award appreciates sky walking for its "*contribution to popularization of APM technology*". <br/><br/><br/>
|
||||
Thanks all users of sky walking project.
|
||||
|
||||
___
|
||||
|
||||
# Contributors
|
||||
_In chronological order_
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
package org.skywalking.apm.agent.core.context;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import org.skywalking.apm.agent.core.context.ids.DistributedTraceId;
|
||||
import org.skywalking.apm.agent.core.context.ids.PropagatedTraceId;
|
||||
|
|
@ -32,7 +31,7 @@ public class ContextCarrier implements Serializable {
|
|||
/**
|
||||
* {@link DistributedTraceId}
|
||||
*/
|
||||
private List<DistributedTraceId> distributedTraceIds;
|
||||
private DistributedTraceId primaryDistributedTraceId;
|
||||
|
||||
/**
|
||||
* Serialize this {@link ContextCarrier} to a {@link String},
|
||||
|
|
@ -48,7 +47,7 @@ public class ContextCarrier implements Serializable {
|
|||
this.getApplicationInstanceId() + "",
|
||||
this.getPeerHost(),
|
||||
this.getEntryOperationName(),
|
||||
this.serializeDistributedTraceIds());
|
||||
this.serializeDistributedTraceId());
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
|
|
@ -69,7 +68,7 @@ public class ContextCarrier implements Serializable {
|
|||
this.applicationInstanceId = Integer.parseInt(parts[2]);
|
||||
this.peerHost = parts[3];
|
||||
this.entryOperationName = parts[4];
|
||||
this.distributedTraceIds = deserializeDistributedTraceIds(parts[5]);
|
||||
this.primaryDistributedTraceId = new PropagatedTraceId(parts[5]);
|
||||
} catch (NumberFormatException e) {
|
||||
|
||||
}
|
||||
|
|
@ -89,7 +88,7 @@ public class ContextCarrier implements Serializable {
|
|||
&& applicationInstanceId != DictionaryUtil.nullValue()
|
||||
&& !StringUtil.isEmpty(peerHost)
|
||||
&& !StringUtil.isEmpty(entryOperationName)
|
||||
&& distributedTraceIds != null;
|
||||
&& primaryDistributedTraceId != null;
|
||||
}
|
||||
|
||||
public String getEntryOperationName() {
|
||||
|
|
@ -140,51 +139,15 @@ public class ContextCarrier implements Serializable {
|
|||
this.peerHost = peerId + "";
|
||||
}
|
||||
|
||||
public List<DistributedTraceId> getDistributedTraceIds() {
|
||||
return distributedTraceIds;
|
||||
public DistributedTraceId getDistributedTraceId() {
|
||||
return primaryDistributedTraceId;
|
||||
}
|
||||
|
||||
public void setDistributedTraceIds(List<DistributedTraceId> distributedTraceIds) {
|
||||
this.distributedTraceIds = distributedTraceIds;
|
||||
this.primaryDistributedTraceId = distributedTraceIds.get(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Serialize {@link #distributedTraceIds} to a string, with ',' split.
|
||||
*
|
||||
* @return string, represents all {@link DistributedTraceId}
|
||||
*/
|
||||
private String serializeDistributedTraceIds() {
|
||||
StringBuilder traceIdString = new StringBuilder();
|
||||
if (distributedTraceIds != null) {
|
||||
boolean first = true;
|
||||
for (DistributedTraceId distributedTraceId : distributedTraceIds) {
|
||||
if (first) {
|
||||
first = false;
|
||||
} else {
|
||||
traceIdString.append(",");
|
||||
}
|
||||
traceIdString.append(distributedTraceId.get());
|
||||
}
|
||||
}
|
||||
return traceIdString.toString();
|
||||
private String serializeDistributedTraceId() {
|
||||
return primaryDistributedTraceId.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Deserialize {@link #distributedTraceIds} from a text, whith
|
||||
*
|
||||
* @param text
|
||||
* @return
|
||||
*/
|
||||
private List<DistributedTraceId> deserializeDistributedTraceIds(String text) {
|
||||
if (StringUtil.isEmpty(text)) {
|
||||
return null;
|
||||
}
|
||||
String[] propagationTraceIdValues = text.split(",");
|
||||
List<DistributedTraceId> traceIds = new LinkedList<DistributedTraceId>();
|
||||
for (String propagationTraceIdValue : propagationTraceIdValues) {
|
||||
traceIds.add(new PropagatedTraceId(propagationTraceIdValue));
|
||||
}
|
||||
return traceIds;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,17 +23,17 @@ public class ContextSnapshot {
|
|||
/**
|
||||
* {@link DistributedTraceId}
|
||||
*/
|
||||
private List<DistributedTraceId> distributedTraceIds;
|
||||
private DistributedTraceId primaryDistributedTraceId;
|
||||
|
||||
ContextSnapshot(String traceSegmentId, int spanId,
|
||||
List<DistributedTraceId> distributedTraceIds) {
|
||||
this.traceSegmentId = traceSegmentId;
|
||||
this.spanId = spanId;
|
||||
this.distributedTraceIds = distributedTraceIds;
|
||||
this.primaryDistributedTraceId = distributedTraceIds.get(0);
|
||||
}
|
||||
|
||||
public List<DistributedTraceId> getDistributedTraceIds() {
|
||||
return distributedTraceIds;
|
||||
public DistributedTraceId getDistributedTraceId() {
|
||||
return primaryDistributedTraceId;
|
||||
}
|
||||
|
||||
public String getTraceSegmentId() {
|
||||
|
|
@ -47,7 +47,6 @@ public class ContextSnapshot {
|
|||
public boolean isValid() {
|
||||
return traceSegmentId != null
|
||||
&& spanId > -1
|
||||
&& distributedTraceIds != null
|
||||
&& distributedTraceIds.size() > 0;
|
||||
&& primaryDistributedTraceId != null;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -121,7 +121,7 @@ public class TracingContext implements AbstractTracerContext {
|
|||
@Override
|
||||
public void extract(ContextCarrier carrier) {
|
||||
this.segment.ref(new TraceSegmentRef(carrier));
|
||||
this.segment.relatedGlobalTraces(carrier.getDistributedTraceIds());
|
||||
this.segment.relatedGlobalTraces(carrier.getDistributedTraceId());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -147,7 +147,7 @@ public class TracingContext implements AbstractTracerContext {
|
|||
@Override
|
||||
public void continued(ContextSnapshot snapshot) {
|
||||
this.segment.ref(new TraceSegmentRef(snapshot));
|
||||
this.segment.relatedGlobalTraces(snapshot.getDistributedTraceIds());
|
||||
this.segment.relatedGlobalTraces(snapshot.getDistributedTraceId());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -93,16 +93,9 @@ public class TraceSegment {
|
|||
|
||||
/**
|
||||
* Establish the line between this segment and all relative global trace ids.
|
||||
*
|
||||
* @param distributedTraceIds multi global trace ids. @see {@link DistributedTraceId}
|
||||
*/
|
||||
public void relatedGlobalTraces(List<DistributedTraceId> distributedTraceIds) {
|
||||
if (distributedTraceIds == null || distributedTraceIds.size() == 0) {
|
||||
return;
|
||||
}
|
||||
for (DistributedTraceId distributedTraceId : distributedTraceIds) {
|
||||
relatedGlobalTraces.append(distributedTraceId);
|
||||
}
|
||||
public void relatedGlobalTraces(DistributedTraceId distributedTraceId) {
|
||||
relatedGlobalTraces.append(distributedTraceId);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Reference in New Issue