use of zipkin2.Span.Kind in project zipkin by openzipkin.
the class SpanConverterTest method lateRemoteEndpoint_ca.
/**
* Late flushed data on a v1 v1
*/
@Test
public void lateRemoteEndpoint_ca() {
Span v2 = Span.newBuilder().traceId("1").id("2").kind(Kind.SERVER).remoteEndpoint(FRONTEND).build();
V1Span v1 = V1Span.newBuilder().traceId(1L).id(2L).addBinaryAnnotation("ca", FRONTEND).build();
assertThat(v2SpanConverter.convert(v2)).usingRecursiveComparison().isEqualTo(v1);
assertThat(v1SpanConverter.convert(v1)).containsExactly(v2);
}
use of zipkin2.Span.Kind in project zipkin by openzipkin.
the class SpanConverterTest method redundantAddressAnnotations_client.
/**
* Intentionally create service loopback endpoints as dependency linker can correct it later if
* incorrect, provided the server is instrumented.
*/
@Test
public void redundantAddressAnnotations_client() {
Span v2 = Span.newBuilder().traceId("1").parentId("2").id("3").kind(Kind.CLIENT).name("get").localEndpoint(FRONTEND).remoteEndpoint(FRONTEND).timestamp(1472470996199000L).duration(207000L).build();
V1Span v1 = V1Span.newBuilder().traceId(1L).parentId(2L).id(3L).name("get").timestamp(1472470996199000L).duration(207000L).addAnnotation(1472470996199000L, "cs", FRONTEND).addAnnotation(1472470996406000L, "cr", FRONTEND).addBinaryAnnotation("ca", FRONTEND).addBinaryAnnotation("sa", FRONTEND).build();
assertThat(v1SpanConverter.convert(v1)).containsExactly(v2);
}
use of zipkin2.Span.Kind in project zipkin by openzipkin.
the class SpanConverterTest method assumesServerWithoutTimestampIsShared.
/**
* The old v1 format had no means of saying it is shared or not. This uses lack of timestamp as a
* signal
*/
@Test
public void assumesServerWithoutTimestampIsShared() {
V1Span v1 = V1Span.newBuilder().traceId(1L).parentId(2L).id(3L).name("get").addAnnotation(1472470996250000L, "sr", BACKEND).addAnnotation(1472470996350000L, "ss", BACKEND).build();
Span v2 = Span.newBuilder().traceId("1").parentId("2").id("3").name("get").kind(Kind.SERVER).shared(true).localEndpoint(BACKEND).timestamp(1472470996250000L).duration(100000L).build();
assertThat(v1SpanConverter.convert(v1)).containsExactly(v2);
}
use of zipkin2.Span.Kind in project zipkin by openzipkin.
the class SpanConverterTest method redundantServiceNameOnAddressAnnotations_serverRetainsClientSocket.
@Test
public void redundantServiceNameOnAddressAnnotations_serverRetainsClientSocket() {
Span v2 = Span.newBuilder().traceId("1").parentId("2").id("3").kind(Kind.SERVER).name("get").localEndpoint(BACKEND).remoteEndpoint(FRONTEND.toBuilder().serviceName(null).build()).timestamp(1472470996199000L).duration(207000L).build();
V1Span v1 = V1Span.newBuilder().traceId(1L).parentId(2L).id(3L).name("get").timestamp(1472470996199000L).duration(207000L).addAnnotation(1472470996199000L, "sr", BACKEND).addAnnotation(1472470996406000L, "ss", BACKEND).addBinaryAnnotation("ca", FRONTEND.toBuilder().serviceName("backend").build()).addBinaryAnnotation("sa", BACKEND).build();
assertThat(v1SpanConverter.convert(v1)).containsExactly(v2);
}
use of zipkin2.Span.Kind in project zipkin by openzipkin.
the class WireSpanDecoder method decodeOne.
public static Span decodeOne(ProtoReader input) throws IOException {
Span.Builder span = Span.newBuilder();
boolean done = false;
while (!done) {
int tag = input.nextTag();
switch(tag) {
case -1:
done = true;
break;
case 1:
{
span.traceId(readHexString(input));
break;
}
case 2:
{
span.parentId(readHexString(input));
break;
}
case 3:
{
span.id(readHexString(input));
break;
}
case 4:
{
int kind = input.readVarint32();
if (kind == 0)
break;
if (kind > Span.Kind.values().length)
break;
span.kind(Span.Kind.values()[kind - 1]);
break;
}
case 5:
{
String name = input.readString();
span.name(name);
break;
}
case 6:
{
span.timestamp(input.readFixed64());
break;
}
case 7:
{
span.duration(input.readVarint64());
break;
}
case 8:
{
long token = input.beginMessage();
span.localEndpoint(decodeEndpoint(input));
input.endMessageAndGetUnknownFields(token);
break;
}
case 9:
{
long token = input.beginMessage();
span.remoteEndpoint(decodeEndpoint(input));
input.endMessageAndGetUnknownFields(token);
break;
}
case 10:
{
long token = input.beginMessage();
decodeAnnotation(input, span);
input.endMessageAndGetUnknownFields(token);
break;
}
case 11:
{
long token = input.beginMessage();
decodeTag(input, span);
input.endMessageAndGetUnknownFields(token);
break;
}
case 12:
{
span.debug(ProtoAdapter.BOOL.decode(input));
break;
}
case 13:
{
span.shared(ProtoAdapter.BOOL.decode(input));
break;
}
default:
{
logAndSkip(input, tag);
break;
}
}
}
return span.build();
}
Aggregations