@Test public void testCloneInstance() { SofaTracerSpan span = (SofaTracerSpan) this.sofaTracer.buildSpan("testCloneInstance") .start(); span.setParentSofaTracerSpan(this.sofaTracerSpan); SofaTracerSpanContext spanContext = span.getSofaTracerSpanContext(); SofaTracerSpan cloneSpan = span.cloneInstance(); SofaTracerSpanContext cloneSpanContext = cloneSpan.getSofaTracerSpanContext(); assertEquals(spanContext, cloneSpanContext); assertEquals(spanContext.getBizBaggage(), cloneSpanContext.getBizBaggage()); assertEquals(spanContext.isSampled(), cloneSpanContext.isSampled()); assertSame(spanContext.getChildContextIndex(), cloneSpanContext.getChildContextIndex()); assertEquals(span.getTagsWithStr(), cloneSpan.getTagsWithStr()); assertEquals(span.getTagsWithNumber(), cloneSpan.getTagsWithNumber()); assertEquals(span.getTagsWithBool(), cloneSpan.getTagsWithBool()); assertEquals(span.getStartTime(), cloneSpan.getStartTime()); assertEquals(span.getEndTime(), cloneSpan.getEndTime()); assertEquals(span.getLogs(), cloneSpan.getLogs()); assertEquals(span.getLogType(), cloneSpan.getLogType()); assertEquals(span.getOperationName(), cloneSpan.getOperationName()); assertSame(span.getParentSofaTracerSpan(), cloneSpan.getParentSofaTracerSpan()); }
public SofaTracerSpan cloneInstance() { SofaTracerSpanContext spanContext = this.sofaTracerSpanContext.cloneInstance(); Map<String, Object> tags = new HashMap<>(); tags.putAll(this.tagsWithBool); tags.putAll(this.tagsWithStr); tags.putAll(this.tagsWithNumber); SofaTracerSpan cloneSpan = new SofaTracerSpan(this.sofaTracer, this.startTime, this.spanReferences, this.operationName, spanContext, tags); if (this.logs != null && this.logs.size() > 0) { for (LogData logData : this.logs) { cloneSpan.log(logData); } } cloneSpan.setEndTime(this.endTime); cloneSpan.setLogType(this.logType); cloneSpan.setParentSofaTracerSpan(this.parentSofaTracerSpan); return cloneSpan; }
SofaTracerSpan implements Span { public SofaTracerSpan cloneInstance() { SofaTracerSpanContext spanContext = this.sofaTracerSpanContext.cloneInstance(); Map<String, Object> tags = new HashMap<>(); tags.putAll(this.tagsWithBool); tags.putAll(this.tagsWithStr); tags.putAll(this.tagsWithNumber); SofaTracerSpan cloneSpan = new SofaTracerSpan(this.sofaTracer, this.startTime, this.spanReferences, this.operationName, spanContext, tags); if (this.logs != null && this.logs.size() > 0) { for (LogData logData : this.logs) { cloneSpan.log(logData); } } cloneSpan.setEndTime(this.endTime); cloneSpan.setLogType(this.logType); cloneSpan.setParentSofaTracerSpan(this.parentSofaTracerSpan); return cloneSpan; } }
SofaTracerSpan implements Span { public SofaTracerSpan cloneInstance() { SofaTracerSpanContext spanContext = this.sofaTracerSpanContext.cloneInstance(); Map<String, Object> tags = new HashMap<>(); tags.putAll(this.tagsWithBool); tags.putAll(this.tagsWithStr); tags.putAll(this.tagsWithNumber); SofaTracerSpan cloneSpan = new SofaTracerSpan(this.sofaTracer, this.startTime, this.spanReferences, this.operationName, spanContext, tags); if (this.logs != null && this.logs.size() > 0) { for (LogData logData : this.logs) { cloneSpan.log(logData); } } cloneSpan.setEndTime(this.endTime); cloneSpan.setLogType(this.logType); cloneSpan.setParentSofaTracerSpan(this.parentSofaTracerSpan); return cloneSpan; } SofaTracerSpan(SofaTracer sofaTracer, long startTime, String operationName,
                          SofaTracerSpanContext sofaTracerSpanContext, Map<String, ?> tags);  SofaTracerSpan(SofaTracer sofaTracer, long startTime,
                          List<SofaTracerSpanReferenceRelationship> spanReferences,
                          String operationName, SofaTracerSpanContext sofaTracerSpanContext,
                          Map<String, ?> tags); }
SofaTracerSpan implements Span { public SofaTracerSpan cloneInstance() { SofaTracerSpanContext spanContext = this.sofaTracerSpanContext.cloneInstance(); Map<String, Object> tags = new HashMap<>(); tags.putAll(this.tagsWithBool); tags.putAll(this.tagsWithStr); tags.putAll(this.tagsWithNumber); SofaTracerSpan cloneSpan = new SofaTracerSpan(this.sofaTracer, this.startTime, this.spanReferences, this.operationName, spanContext, tags); if (this.logs != null && this.logs.size() > 0) { for (LogData logData : this.logs) { cloneSpan.log(logData); } } cloneSpan.setEndTime(this.endTime); cloneSpan.setLogType(this.logType); cloneSpan.setParentSofaTracerSpan(this.parentSofaTracerSpan); return cloneSpan; } SofaTracerSpan(SofaTracer sofaTracer, long startTime, String operationName,
                          SofaTracerSpanContext sofaTracerSpanContext, Map<String, ?> tags);  SofaTracerSpan(SofaTracer sofaTracer, long startTime,
                          List<SofaTracerSpanReferenceRelationship> spanReferences,
                          String operationName, SofaTracerSpanContext sofaTracerSpanContext,
                          Map<String, ?> tags); SofaTracerSpan cloneInstance(); @Override SpanContext context(); @Override void finish(); @Override void finish(long endTime); @Override void close(); @Override Span setTag(String key, String value); @Override Span setTag(String key, boolean value); @Override Span setTag(String key, Number number); @Override Span log(String eventValue); @Override Span log(long currentTime, String eventValue); Span log(LogData logData); @Override Span log(long currentTime, Map<String, ?> map); @Override Span log(Map<String, ?> map); @Override Span log(String eventName, /* @Nullable */Object payload); @Override Span log(long currentTime, String eventName, /* @Nullable */Object payload); @Override Span setBaggageItem(String key, String value); @Override String getBaggageItem(String key); @Override Span setOperationName(String operationName); void reportError(String errorType, Map<String, String> context, Throwable e,
                            String errorSourceApp, String... errorSources); void profile(String profileApp, String protocolType, String profileMessage); SofaTracerSpan getThisAsParentWhenExceedLayer(); List<SofaTracerSpanReferenceRelationship> getSpanReferences(); SofaTracer getSofaTracer(); long getStartTime(); void setStartTime(long startTime); long getEndTime(); void setEndTime(long endTime); long getDurationMicroseconds(); Map<String, String> getTagsWithStr(); Map<String, Boolean> getTagsWithBool(); Map<String, Number> getTagsWithNumber(); String getOperationName(); SofaTracerSpanContext getSofaTracerSpanContext(); List<LogData> getLogs(); String getLogType(); void setLogType(String logType); SofaTracerSpan getParentSofaTracerSpan(); void setParentSofaTracerSpan(SofaTracerSpan parentSofaTracerSpan); boolean isServer(); boolean isClient(); @Override String toString(); }
SofaTracerSpan implements Span { public SofaTracerSpan cloneInstance() { SofaTracerSpanContext spanContext = this.sofaTracerSpanContext.cloneInstance(); Map<String, Object> tags = new HashMap<>(); tags.putAll(this.tagsWithBool); tags.putAll(this.tagsWithStr); tags.putAll(this.tagsWithNumber); SofaTracerSpan cloneSpan = new SofaTracerSpan(this.sofaTracer, this.startTime, this.spanReferences, this.operationName, spanContext, tags); if (this.logs != null && this.logs.size() > 0) { for (LogData logData : this.logs) { cloneSpan.log(logData); } } cloneSpan.setEndTime(this.endTime); cloneSpan.setLogType(this.logType); cloneSpan.setParentSofaTracerSpan(this.parentSofaTracerSpan); return cloneSpan; } SofaTracerSpan(SofaTracer sofaTracer, long startTime, String operationName,
                          SofaTracerSpanContext sofaTracerSpanContext, Map<String, ?> tags);  SofaTracerSpan(SofaTracer sofaTracer, long startTime,
                          List<SofaTracerSpanReferenceRelationship> spanReferences,
                          String operationName, SofaTracerSpanContext sofaTracerSpanContext,
                          Map<String, ?> tags); SofaTracerSpan cloneInstance(); @Override SpanContext context(); @Override void finish(); @Override void finish(long endTime); @Override void close(); @Override Span setTag(String key, String value); @Override Span setTag(String key, boolean value); @Override Span setTag(String key, Number number); @Override Span log(String eventValue); @Override Span log(long currentTime, String eventValue); Span log(LogData logData); @Override Span log(long currentTime, Map<String, ?> map); @Override Span log(Map<String, ?> map); @Override Span log(String eventName, /* @Nullable */Object payload); @Override Span log(long currentTime, String eventName, /* @Nullable */Object payload); @Override Span setBaggageItem(String key, String value); @Override String getBaggageItem(String key); @Override Span setOperationName(String operationName); void reportError(String errorType, Map<String, String> context, Throwable e,
                            String errorSourceApp, String... errorSources); void profile(String profileApp, String protocolType, String profileMessage); SofaTracerSpan getThisAsParentWhenExceedLayer(); List<SofaTracerSpanReferenceRelationship> getSpanReferences(); SofaTracer getSofaTracer(); long getStartTime(); void setStartTime(long startTime); long getEndTime(); void setEndTime(long endTime); long getDurationMicroseconds(); Map<String, String> getTagsWithStr(); Map<String, Boolean> getTagsWithBool(); Map<String, Number> getTagsWithNumber(); String getOperationName(); SofaTracerSpanContext getSofaTracerSpanContext(); List<LogData> getLogs(); String getLogType(); void setLogType(String logType); SofaTracerSpan getParentSofaTracerSpan(); void setParentSofaTracerSpan(SofaTracerSpan parentSofaTracerSpan); boolean isServer(); boolean isClient(); @Override String toString(); static final char ARRAY_SEPARATOR; }