diff --git a/pom.xml b/pom.xml
index 5990acba..21dd0fb3 100644
--- a/pom.xml
+++ b/pom.xml
@@ -42,7 +42,7 @@
- 1.22.0
+ 1.30.2
0.3.2
1.0.2
@@ -53,7 +53,7 @@
org.springframework.boot
spring-boot-dependencies
- 1.4.2.RELEASE
+ 1.5.6.RELEASE
pom
import
diff --git a/translation/pom.xml b/translation/pom.xml
index eb05d51d..3c78141a 100644
--- a/translation/pom.xml
+++ b/translation/pom.xml
@@ -35,5 +35,49 @@
-
+
+
+
+
+ maven-shade-plugin
+ 3.0.0
+
+
+ package
+
+ shade
+
+
+ true
+ false
+
+
+ zipkin.internal
+ com.google.cloud.trace.zipkin.translation.internal.zipkin
+
+
+
+
+ io.zipkin.java:zipkin
+
+
+
+
+
+ io.zipkin.java:zipkin
+
+ zipkin/internal/*Span2*.class
+ zipkin/internal/Util.class
+
+
+ *
+
+
+
+
+
+
+
+
+
diff --git a/translation/src/main/java/com/google/cloud/trace/zipkin/translation/LabelExtractor.java b/translation/src/main/java/com/google/cloud/trace/zipkin/translation/LabelExtractor.java
index 15eb89ab..2a95b8fc 100644
--- a/translation/src/main/java/com/google/cloud/trace/zipkin/translation/LabelExtractor.java
+++ b/translation/src/main/java/com/google/cloud/trace/zipkin/translation/LabelExtractor.java
@@ -17,16 +17,14 @@
package com.google.cloud.trace.zipkin.translation;
import com.google.common.collect.ImmutableMap;
-import java.nio.ByteBuffer;
-import java.nio.ByteOrder;
-import java.nio.charset.Charset;
import java.text.SimpleDateFormat;
import java.util.Date;
-import java.util.HashMap;
+import java.util.LinkedHashMap;
import java.util.Map;
import zipkin.Annotation;
-import zipkin.BinaryAnnotation;
import zipkin.Span;
+import zipkin.internal.Span2;
+import zipkin.internal.Span2Converter;
/**
* LabelExtractor extracts the set of Stackdriver Span labels equivalent to the annotations in a given Zipkin Span.
@@ -60,27 +58,33 @@ public LabelExtractor(Map renamedLabels) {
* @return A map of the Stackdriver span labels equivalent to the Zipkin annotations.
*/
public Map extract(Span zipkinSpan) {
- Map labels = new HashMap<>();
- for (BinaryAnnotation annotation : zipkinSpan.binaryAnnotations) {
- labels.put(getLabelName(annotation.key), readBinaryAnnotation(annotation));
+ Map result = new LinkedHashMap<>();
+ for (Span2 span2 : Span2Converter.fromSpan(zipkinSpan)) {
+ result.putAll(extract(span2));
+ }
+ return result;
+ }
+
+ Map extract(Span2 zipkinSpan) { // not exposed until Span2 is a formal type
+ Map result = new LinkedHashMap<>();
+ for (Map.Entry tag : zipkinSpan.tags().entrySet()) {
+ result.put(getLabelName(tag.getKey()), tag.getValue());
+ }
+
+ for (Annotation annotation : zipkinSpan.annotations()) {
+ result.put(getLabelName(annotation.value), formatTimestamp(annotation.timestamp));
}
- for (Annotation annotation : zipkinSpan.annotations) {
- labels.put(getLabelName(annotation.value), formatTimestamp(annotation.timestamp));
- if ("cs".equals(annotation.value) || "sr".equals(annotation.value)) {
- // Consistently grab the serviceName from a specific annotation.
- if (annotation.endpoint != null && annotation.endpoint.serviceName != null) {
- labels.put(kComponentLabelKey, annotation.endpoint.serviceName);
- }
- }
+ if (zipkinSpan.localEndpoint() != null && !zipkinSpan.localEndpoint().serviceName.isEmpty()) {
+ result.put(kComponentLabelKey, zipkinSpan.localEndpoint().serviceName);
}
- if (zipkinSpan.parentId == null) {
- String agentName = System.getProperty("stackdriver.trace.zipkin.agent", "zipkin-java");
- labels.put(kAgentLabelKey, agentName);
+ if (zipkinSpan.parentId() == null) {
+ String agentName = System.getProperty("stackdriver.trace.zipkin.agent", "zipkin-java");
+ result.put(kAgentLabelKey, agentName);
}
- return labels;
+ return result;
}
private String getLabelName(String zipkinName) {
@@ -91,26 +95,6 @@ private String getLabelName(String zipkinName) {
}
}
- private String readBinaryAnnotation(BinaryAnnotation annotation) {
- // The value of a BinaryAnnotation is encoded in big endian order.
- ByteBuffer buffer = ByteBuffer.wrap(annotation.value).order(ByteOrder.BIG_ENDIAN);
- switch (annotation.type) {
- case BOOL:
- return annotation.value[0] == 1 ? "true" : "false";
- case I16:
- return Short.toString(buffer.getShort());
- case I32:
- return Integer.toString(buffer.getInt());
- case I64:
- return Long.toString(buffer.getLong());
- case DOUBLE:
- return Double.toString(buffer.getDouble());
- case STRING:
- default:
- return new String(annotation.value, Charset.forName("UTF-8"));
- }
- }
-
private String formatTimestamp(long microseconds) {
long milliseconds = microseconds / 1000;
Date date = new Date(milliseconds);
diff --git a/translation/src/main/java/com/google/cloud/trace/zipkin/translation/SpanTranslator.java b/translation/src/main/java/com/google/cloud/trace/zipkin/translation/SpanTranslator.java
index 77917a2f..2a62eae8 100644
--- a/translation/src/main/java/com/google/cloud/trace/zipkin/translation/SpanTranslator.java
+++ b/translation/src/main/java/com/google/cloud/trace/zipkin/translation/SpanTranslator.java
@@ -16,18 +16,15 @@
package com.google.cloud.trace.zipkin.translation;
-import static zipkin.Constants.CLIENT_RECV;
-import static zipkin.Constants.CLIENT_SEND;
-import static zipkin.Constants.SERVER_RECV;
-import static zipkin.Constants.SERVER_SEND;
-
import com.google.devtools.cloudtrace.v1.TraceSpan;
import com.google.devtools.cloudtrace.v1.TraceSpan.SpanKind;
import com.google.protobuf.Timestamp;
import java.util.HashMap;
import java.util.Map;
-import zipkin.Annotation;
+import javax.annotation.Nullable;
import zipkin.Span;
+import zipkin.internal.Span2;
+import zipkin.internal.Span2Converter;
/**
* SpanTranslator converts a Zipkin Span to a Stackdriver Trace Span.
@@ -61,69 +58,55 @@ public SpanTranslator() {
* @return A Stackdriver Trace Span.
*/
public TraceSpan translate(Span zipkinSpan) {
- Map annotations = getAnnotations(zipkinSpan);
- TraceSpan.Builder spanBuilder = TraceSpan.newBuilder();
+ TraceSpan.Builder builder = TraceSpan.newBuilder();
+ for (Span2 span : Span2Converter.fromSpan(zipkinSpan)) {
+ translate(builder, span);
+ }
+ return builder.build();
+ }
- spanBuilder.setName(zipkinSpan.name);
- SpanKind kind = getSpanKind(annotations);
+ TraceSpan.Builder translate(TraceSpan.Builder spanBuilder, Span2 zipkinSpan) {
+ spanBuilder.setName(zipkinSpan.name());
+ SpanKind kind = getSpanKind(zipkinSpan.kind());
spanBuilder.setKind(kind);
rewriteIds(zipkinSpan, spanBuilder, kind);
- writeBestTimestamp(zipkinSpan, spanBuilder, annotations);
- spanBuilder.putAllLabels(labelExtractor.extract(zipkinSpan));
- return spanBuilder.build();
- }
-
- private void writeBestTimestamp(Span zipkinSpan, TraceSpan.Builder spanBuilder, Map annotations) {
- if (zipkinSpan.timestamp != null) {
- // Span.timestamp is the authoritative value if it's present.
- spanBuilder.setStartTime(createTimestamp(zipkinSpan.timestamp));
- spanBuilder.setEndTime(createTimestamp(zipkinSpan.timestamp + zipkinSpan.duration));
- } else if (annotations.containsKey(CLIENT_SEND) && annotations.containsKey(CLIENT_RECV)) {
- // Client timestamps are more authoritative than server timestamps.
- spanBuilder.setStartTime(
- createTimestamp(annotations.get(CLIENT_SEND).timestamp)
- );
- spanBuilder.setEndTime(
- createTimestamp(annotations.get(CLIENT_RECV).timestamp)
- );
- } else if (annotations.containsKey(SERVER_RECV) && annotations.containsKey(SERVER_SEND)) {
- spanBuilder.setStartTime(
- createTimestamp(annotations.get(SERVER_RECV).timestamp)
- );
- spanBuilder.setEndTime(
- createTimestamp(annotations.get(SERVER_SEND).timestamp)
- );
+ if (zipkinSpan.timestamp() != null) {
+ spanBuilder.setStartTime(createTimestamp(zipkinSpan.timestamp()));
+ if (zipkinSpan.duration() != null) {
+ Timestamp endTime = createTimestamp(zipkinSpan.timestamp() + zipkinSpan.duration());
+ spanBuilder.setEndTime(endTime);
+ }
}
+ spanBuilder.putAllLabels(labelExtractor.extract(zipkinSpan));
+ return spanBuilder;
}
/**
* Rewrite Span IDs to split multi-host Zipkin spans into multiple single-host Stackdriver spans.
*/
- private void rewriteIds(Span zipkinSpan, TraceSpan.Builder builder, SpanKind kind) {
+ private void rewriteIds(Span2 zipkinSpan, TraceSpan.Builder builder, SpanKind kind) {
// Change the spanId of RPC_CLIENT spans.
if (kind == SpanKind.RPC_CLIENT) {
- builder.setSpanId(rewriteId(zipkinSpan.id));
+ builder.setSpanId(rewriteId(zipkinSpan.id()));
} else {
- builder.setSpanId(zipkinSpan.id);
+ builder.setSpanId(zipkinSpan.id());
}
// Change the parentSpanId of RPC_SERVER spans to use the rewritten spanId of the RPC_CLIENT spans.
if (kind == SpanKind.RPC_SERVER) {
- if (zipkinSpan.timestamp != null ) {
- // The timestamp field should only be written by instrumentation whenever it "owns" a span.
- // Because this field is here, we know that the server "owns" this span which implies this
- // is a single-host span.
- // This means the parent RPC_CLIENT span was a separate span with id=zipkinSpan.parentId. When
- // that span fragment was converted, it would have had id=rewriteId(zipkinSpan.parentId)
- builder.setParentSpanId(rewriteId(zipkinSpan.parentId));
- } else {
+ if (Boolean.TRUE.equals(zipkinSpan.shared())) {
// This is a multi-host span.
// This means the parent client-side span has the same id as this span. When that fragment of
// the span was converted, it would have had id rewriteId(zipkinSpan.id)
- builder.setParentSpanId(rewriteId(zipkinSpan.id));
+ builder.setParentSpanId(rewriteId(zipkinSpan.id()));
+ } else {
+ // This span isn't shared: the server "owns" this span and it is a single-host span.
+ // This means the parent RPC_CLIENT span was a separate span with id=zipkinSpan.parentId. When
+ // that span fragment was converted, it would have had id=rewriteId(zipkinSpan.parentId)
+ builder.setParentSpanId(rewriteId(zipkinSpan.parentId()));
}
} else {
- long parentId = zipkinSpan.parentId == null ? 0 : zipkinSpan.parentId;
+ long parentId = zipkinSpan.parentId() == null ? 0 : zipkinSpan.parentId();
builder.setParentSpanId(parentId);
}
}
@@ -137,22 +120,15 @@ private long rewriteId(Long id) {
return id ^ pad;
}
- private SpanKind getSpanKind(Map annotations) {
- if (annotations.containsKey(CLIENT_SEND) || annotations.containsKey(CLIENT_RECV)) {
+ private SpanKind getSpanKind(@Nullable Span2.Kind zipkinKind) {
+ if (zipkinKind == null) return SpanKind.SPAN_KIND_UNSPECIFIED;
+ if (zipkinKind == Span2.Kind.CLIENT) {
return SpanKind.RPC_CLIENT;
}
- if (annotations.containsKey(SERVER_SEND) || annotations.containsKey(SERVER_RECV)) {
+ if (zipkinKind == Span2.Kind.SERVER) {
return SpanKind.RPC_SERVER;
}
- return SpanKind.SPAN_KIND_UNSPECIFIED;
- }
-
- private Map getAnnotations(Span zipkinSpan) {
- Map annotations = new HashMap<>();
- for (Annotation annotation : zipkinSpan.annotations) {
- annotations.put(annotation.value, annotation);
- }
- return annotations;
+ return SpanKind.UNRECOGNIZED;
}
private Timestamp createTimestamp(long microseconds) {
diff --git a/translation/src/main/java/com/google/cloud/trace/zipkin/translation/TraceTranslator.java b/translation/src/main/java/com/google/cloud/trace/zipkin/translation/TraceTranslator.java
index bc2d8895..dde03b03 100644
--- a/translation/src/main/java/com/google/cloud/trace/zipkin/translation/TraceTranslator.java
+++ b/translation/src/main/java/com/google/cloud/trace/zipkin/translation/TraceTranslator.java
@@ -18,13 +18,14 @@
import com.google.devtools.cloudtrace.v1.Trace;
import com.google.devtools.cloudtrace.v1.TraceSpan;
-import java.nio.ByteBuffer;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import zipkin.Span;
+import zipkin.internal.Span2;
+import zipkin.internal.Span2Converter;
/**
* TraceTranslator converts a collection of Zipkin Spans into a Collection of Stackdriver Trace Spans.
@@ -48,14 +49,17 @@ public TraceTranslator(String projectId) {
* @return A Collection of Stackdriver Trace Spans.
*/
public Collection translateSpans(Collection zipkinSpans) {
- List groupedSpans = new ArrayList<>(zipkinSpans);
- groupSpansByTraceId(groupedSpans);
-
+ List sortedByTraceAndSpanId = sortByTraceAndSpanId(zipkinSpans);
Trace.Builder currentTrace = null;
Collection translatedTraces = new ArrayList<>();
- for (Span zipkinSpan : groupedSpans) {
- String traceId = convertTraceId(zipkinSpan);
+ for (int i = 0, length = sortedByTraceAndSpanId.size(); i < length; i++) {
+ Span currentSpan = sortedByTraceAndSpanId.get(i);
+
+ // Zipkin trace ID is conditionally 16 or 32 characters, but Stackdriver needs 32
+ String traceId = currentSpan.traceIdString();
+ if (traceId.length() == 16) traceId = "0000000000000000" + traceId;
+
if (currentTrace == null || !traceId.equals(currentTrace.getTraceId())) {
finishTrace(currentTrace, translatedTraces);
@@ -63,23 +67,39 @@ public Collection translateSpans(Collection zipkinSpans) {
currentTrace.setProjectId(this.projectId);
currentTrace.setTraceId(traceId);
}
- appendSpan(currentTrace, zipkinSpan);
+
+ // Clients and servers may report against the same span ID. Collect all fragments together.
+ List sameSpan = new ArrayList<>(Span2Converter.fromSpan(currentSpan));
+ while (i + 1 < length) {
+ Span peekedSpan = sortedByTraceAndSpanId.get(i + 1);
+ if (currentSpan.traceId != peekedSpan.traceId || currentSpan.id != peekedSpan.id) break;
+ sameSpan.addAll(Span2Converter.fromSpan(peekedSpan));
+ i++;
+ }
+
+ for (Span2 span2 : sameSpan) {
+ appendSpan(currentTrace, span2);
+ }
}
finishTrace(currentTrace, translatedTraces);
return translatedTraces;
}
- private void groupSpansByTraceId(List spans) {
- Collections.sort(spans, new Comparator() {
+ private List sortByTraceAndSpanId(Collection input) {
+ List result = new ArrayList<>(input);
+ Collections.sort(result, new Comparator() {
@Override
public int compare(Span o1, Span o2) {
- return Long.compare(o1.traceId, o2.traceId);
+ int result = Long.compare(o1.traceId, o2.traceId);
+ if (result != 0) return result;
+ return Long.compare(o1.id, o2.id);
}
});
+ return result;
}
- private void appendSpan(Trace.Builder builder, Span zipkinSpan) {
- TraceSpan span = translator.translate(zipkinSpan);
+ private void appendSpan(Trace.Builder builder, Span2 zipkinSpan) {
+ TraceSpan span = translator.translate(TraceSpan.newBuilder(), zipkinSpan).build();
builder.addSpans(span);
}
@@ -88,17 +108,4 @@ private void finishTrace(Trace.Builder traceBuilder, Collection converted
convertedTraces.add(traceBuilder.build());
}
}
-
- static String convertTraceId(Span zipkinSpan) {
- // Stackdriver trace ID's are 128 bits = 16 bytes * 8
- ByteBuffer idBuffer = ByteBuffer.allocate(16); // or 32 characters
- // Note that when 64-bit trace IDs are used, the left-most 16 characters will be zero
- idBuffer.putLong(zipkinSpan.traceIdHigh);
- idBuffer.putLong(zipkinSpan.traceId);
- StringBuilder idBuilder = new StringBuilder();
- for (byte b : idBuffer.array()) {
- idBuilder.append(String.format("%02x", b));
- }
- return idBuilder.toString();
- }
}
diff --git a/translation/src/test/java/com/google/cloud/trace/zipkin/translation/TraceTranslatorTest.java b/translation/src/test/java/com/google/cloud/trace/zipkin/translation/TraceTranslatorTest.java
index 780c94e3..0ade8b33 100644
--- a/translation/src/test/java/com/google/cloud/trace/zipkin/translation/TraceTranslatorTest.java
+++ b/translation/src/test/java/com/google/cloud/trace/zipkin/translation/TraceTranslatorTest.java
@@ -29,6 +29,7 @@
import java.util.Set;
import org.junit.Test;
import zipkin.Annotation;
+import zipkin.Endpoint;
import zipkin.Span;
import static org.assertj.core.api.Assertions.assertThat;
@@ -40,6 +41,8 @@
import static zipkin.Constants.SERVER_SEND;
public class TraceTranslatorTest {
+ Endpoint clientEp = Endpoint.builder().serviceName("client").build();
+ Endpoint serverEp = Endpoint.builder().serviceName("server").build();
@Test
public void testTranslateTrace_128bitInputTraceId() {
@@ -112,19 +115,19 @@ public void testMultihostServerRootSpan() {
Span span1 = Span.builder().traceId(1).id(1).name("/a")
.timestamp(1474488796000000L) // This is set because the server owns the span
.duration(5000000L)
- .addAnnotation(Annotation.create(1474488796000000L, SERVER_RECV, null))
- .addAnnotation(Annotation.create(1474488801000000L, SERVER_SEND, null))
+ .addAnnotation(Annotation.create(1474488796000000L, SERVER_RECV, serverEp))
+ .addAnnotation(Annotation.create(1474488801000000L, SERVER_SEND, serverEp))
.build();
Span span2 = Span.builder().traceId(1).parentId(1L).id(2).name("/b?client")
.timestamp(1474488797000000L) // This is set because the client owns the span.
.duration(1500000L)
- .addAnnotation(Annotation.create(1474488797000000L, CLIENT_SEND, null))
- .addAnnotation(Annotation.create(1474488798500000L, CLIENT_RECV, null))
+ .addAnnotation(Annotation.create(1474488797000000L, CLIENT_SEND, clientEp))
+ .addAnnotation(Annotation.create(1474488798500000L, CLIENT_RECV, clientEp))
.build();
Span span3 = Span.builder().traceId(1).parentId(1L).id(2).name("/b?server")
// timestamp is not set because the server does not own this span.
- .addAnnotation(Annotation.create(1474488797500000L, SERVER_RECV, null))
- .addAnnotation(Annotation.create(1474488798300000L, SERVER_SEND, null))
+ .addAnnotation(Annotation.create(1474488797500000L, SERVER_RECV, serverEp))
+ .addAnnotation(Annotation.create(1474488798300000L, SERVER_SEND, serverEp))
.build();
Span span4 = Span.builder().traceId(1).parentId(2L).id(3).name("custom-span")
.timestamp(1474488797600000L)
@@ -163,16 +166,16 @@ public void testMultihostServerRootSpan() {
@Test
public void testMultihostServerRootSpan_noTimestamp() {
Span span1 = Span.builder().traceId(1).id(1).name("/a")
- .addAnnotation(Annotation.create(1474488796000000L, SERVER_RECV, null))
- .addAnnotation(Annotation.create(1474488801000000L, SERVER_SEND, null))
+ .addAnnotation(Annotation.create(1474488796000000L, SERVER_RECV, serverEp))
+ .addAnnotation(Annotation.create(1474488801000000L, SERVER_SEND, serverEp))
.build();
Span span2 = Span.builder().traceId(1).parentId(1L).id(2).name("/b?client")
- .addAnnotation(Annotation.create(1474488797000000L, CLIENT_SEND, null))
- .addAnnotation(Annotation.create(1474488798500000L, CLIENT_RECV, null))
+ .addAnnotation(Annotation.create(1474488797000000L, CLIENT_SEND, clientEp))
+ .addAnnotation(Annotation.create(1474488798500000L, CLIENT_RECV, clientEp))
.build();
Span span3 = Span.builder().traceId(1).parentId(1L).id(2).name("/b?server")
- .addAnnotation(Annotation.create(1474488797500000L, SERVER_RECV, null))
- .addAnnotation(Annotation.create(1474488798300000L, SERVER_SEND, null))
+ .addAnnotation(Annotation.create(1474488797500000L, SERVER_RECV, serverEp))
+ .addAnnotation(Annotation.create(1474488798300000L, SERVER_SEND, serverEp))
.build();
Span span4 = Span.builder().traceId(1).parentId(2L).id(3).name("custom-span")
.build();
@@ -208,24 +211,24 @@ public void testMultihostClientRootSpan() {
Span span1 = Span.builder().traceId(1).id(1).name("/a?client")
.timestamp(1474488796000000L) // This is set because the client owns the span
.duration(5000000L)
- .addAnnotation(Annotation.create(1474488796000000L, CLIENT_SEND, null))
- .addAnnotation(Annotation.create(1474488801000000L, CLIENT_RECV, null))
+ .addAnnotation(Annotation.create(1474488796000000L, CLIENT_SEND, clientEp))
+ .addAnnotation(Annotation.create(1474488801000000L, CLIENT_RECV, clientEp))
.build();
Span span2 = Span.builder().traceId(1).id(1).name("/a?server")
// timestamp is not set because the server does not own this span.
- .addAnnotation(Annotation.create(1474488796000000L, SERVER_RECV, null))
- .addAnnotation(Annotation.create(1474488801000000L, SERVER_SEND, null))
+ .addAnnotation(Annotation.create(1474488796000000L, SERVER_RECV, serverEp))
+ .addAnnotation(Annotation.create(1474488801000000L, SERVER_SEND, serverEp))
.build();
Span span3 = Span.builder().traceId(1).parentId(1L).id(2).name("/b?client")
.timestamp(1474488797000000L) // This is set because the client owns the span.
.duration(1500000L)
- .addAnnotation(Annotation.create(1474488797000000L, CLIENT_SEND, null))
- .addAnnotation(Annotation.create(1474488798500000L, CLIENT_RECV, null))
+ .addAnnotation(Annotation.create(1474488797000000L, CLIENT_SEND, clientEp))
+ .addAnnotation(Annotation.create(1474488798500000L, CLIENT_RECV, clientEp))
.build();
Span span4 = Span.builder().traceId(1).parentId(1L).id(2).name("/b?server")
// timestamp is not set because the server does not own this span.
- .addAnnotation(Annotation.create(1474488797500000L, SERVER_RECV, null))
- .addAnnotation(Annotation.create(1474488798300000L, SERVER_SEND, null))
+ .addAnnotation(Annotation.create(1474488797500000L, SERVER_RECV, serverEp))
+ .addAnnotation(Annotation.create(1474488798300000L, SERVER_SEND, serverEp))
.build();
Span span5 = Span.builder().traceId(1).parentId(2L).id(3).name("custom-span")
.timestamp(1474488797600000L)
@@ -269,20 +272,20 @@ public void testMultihostClientRootSpan() {
@Test
public void testMultihostClientRootSpan_noTimestamp() {
Span span1 = Span.builder().traceId(1).id(1).name("/a?client")
- .addAnnotation(Annotation.create(1474488796000000L, CLIENT_SEND, null))
- .addAnnotation(Annotation.create(1474488801000000L, CLIENT_RECV, null))
+ .addAnnotation(Annotation.create(1474488796000000L, CLIENT_SEND, clientEp))
+ .addAnnotation(Annotation.create(1474488801000000L, CLIENT_RECV, clientEp))
.build();
Span span2 = Span.builder().traceId(1).id(1).name("/a?server")
- .addAnnotation(Annotation.create(1474488796000000L, SERVER_RECV, null))
- .addAnnotation(Annotation.create(1474488801000000L, SERVER_SEND, null))
+ .addAnnotation(Annotation.create(1474488796000000L, SERVER_RECV, serverEp))
+ .addAnnotation(Annotation.create(1474488801000000L, SERVER_SEND, serverEp))
.build();
Span span3 = Span.builder().traceId(1).parentId(1L).id(2).name("/b?client")
- .addAnnotation(Annotation.create(1474488797000000L, CLIENT_SEND, null))
- .addAnnotation(Annotation.create(1474488798500000L, CLIENT_RECV, null))
+ .addAnnotation(Annotation.create(1474488797000000L, CLIENT_SEND, clientEp))
+ .addAnnotation(Annotation.create(1474488798500000L, CLIENT_RECV, clientEp))
.build();
Span span4 = Span.builder().traceId(1).parentId(1L).id(2).name("/b?server")
- .addAnnotation(Annotation.create(1474488797500000L, SERVER_RECV, null))
- .addAnnotation(Annotation.create(1474488798300000L, SERVER_SEND, null))
+ .addAnnotation(Annotation.create(1474488797500000L, SERVER_RECV, serverEp))
+ .addAnnotation(Annotation.create(1474488798300000L, SERVER_SEND, serverEp))
.build();
Span span5 = Span.builder().traceId(1).parentId(2L).id(3).name("custom-span")
.build();
@@ -327,27 +330,27 @@ public void testSinglehostClientRootSpan() {
Span span1 = Span.builder().traceId(1).id(1).name("/a?client")
.timestamp(1474488796000000L) // This is set because the client owns the span
.duration(5000000L)
- .addAnnotation(Annotation.create(1474488796000000L, CLIENT_SEND, null))
- .addAnnotation(Annotation.create(1474488801000000L, CLIENT_RECV, null))
+ .addAnnotation(Annotation.create(1474488796000000L, CLIENT_SEND, clientEp))
+ .addAnnotation(Annotation.create(1474488801000000L, CLIENT_RECV, clientEp))
.build();
Span span2 = Span.builder().traceId(1).parentId(1L).id(2).name("/a?server")
.timestamp(1474488796000000L)
.duration(5000000L)
- .addAnnotation(Annotation.create(1474488796000000L, SERVER_RECV, null))
- .addAnnotation(Annotation.create(1474488801000000L, SERVER_SEND, null))
+ .addAnnotation(Annotation.create(1474488796000000L, SERVER_RECV, serverEp))
+ .addAnnotation(Annotation.create(1474488801000000L, SERVER_SEND, serverEp))
.build();
Span span3 = Span.builder().traceId(1).parentId(2L).id(3).name("/b?client")
.timestamp(1474488797000000L) // This is set because the client owns the span.
.duration(1500000L)
- .addAnnotation(Annotation.create(1474488797000000L, CLIENT_SEND, null))
- .addAnnotation(Annotation.create(1474488798500000L, CLIENT_RECV, null))
+ .addAnnotation(Annotation.create(1474488797000000L, CLIENT_SEND, clientEp))
+ .addAnnotation(Annotation.create(1474488798500000L, CLIENT_RECV, clientEp))
.build();
Span span4 = Span.builder().traceId(1).parentId(3L).id(4).name("/b?server")
// timestamp is not set because the server does not own this span.
.timestamp(1474488797500000L)
.duration(800000L)
- .addAnnotation(Annotation.create(1474488797500000L, SERVER_RECV, null))
- .addAnnotation(Annotation.create(1474488798300000L, SERVER_SEND, null))
+ .addAnnotation(Annotation.create(1474488797500000L, SERVER_RECV, serverEp))
+ .addAnnotation(Annotation.create(1474488798300000L, SERVER_SEND, serverEp))
.build();
Span span5 = Span.builder().traceId(1).parentId(4L).id(5).name("custom-span")
.timestamp(1474488797600000L)