Search in sources :

Example 56 with Span

use of zipkin.Span in project zipkin by openzipkin.

the class CassandraSpanConsumerTest method logTimestampMissingOnClientSend.

@Test
public void logTimestampMissingOnClientSend() {
    Span span = Span.builder().traceId(1L).parentId(1L).id(2L).name("query").addAnnotation(Annotation.create(0L, CLIENT_SEND, APP_ENDPOINT)).addAnnotation(Annotation.create(0L, CLIENT_RECV, APP_ENDPOINT)).build();
    accept(span);
    verify(mockAppender).doAppend(considerSwitchStrategyLog());
}
Also used : Span(zipkin.Span) Test(org.junit.Test)

Example 57 with Span

use of zipkin.Span in project zipkin by openzipkin.

the class StrictTraceIdFalseTest method canSearchByLower64Bits.

@Test
public void canSearchByLower64Bits() throws IOException {
    Span span = Span.builder().traceIdHigh(1L).traceId(2L).id(2L).name("test-span").addAnnotation(Annotation.create(System.currentTimeMillis() * 1000L, "hello", Endpoint.create("foo-service", 127 << 24 | 1))).build();
    byte[] spansInJson = Codec.JSON.writeSpans(Collections.singletonList(span));
    client.newCall(new Request.Builder().url("http://localhost:" + zipkin.port() + "/api/v1/spans").post(RequestBody.create(MediaType.parse("application/json"), spansInJson)).build()).execute();
    Response response = client.newCall(new Request.Builder().url("http://localhost:" + zipkin.port() + "/api/v1/trace/" + Util.toLowerHex(span.traceId)).build()).execute();
    assertEquals(span, Codec.JSON.readSpans(response.body().bytes()).get(0));
}
Also used : Response(okhttp3.Response) Request(okhttp3.Request) Span(zipkin.Span) Test(org.junit.Test)

Example 58 with Span

use of zipkin.Span in project zipkin by openzipkin.

the class ZipkinServerIntegrationTest method getBy128BitId.

@Test
public void getBy128BitId() throws Exception {
    Span span1 = TRACE.get(0).toBuilder().traceIdHigh(1L).build();
    Span span2 = span1.toBuilder().traceIdHigh(2L).build();
    performAsync(post("/api/v1/spans").content(Codec.JSON.writeSpans(asList(span1, span2)))).andExpect(status().isAccepted());
    // sleep as the the storage operation is async
    Thread.sleep(1500);
    // Tosses high bits
    mockMvc.perform(get(format("/api/v1/trace/%016x%016x", span2.traceIdHigh, span2.traceId))).andExpect(status().isOk()).andExpect(content().string(new String(Codec.JSON.writeSpans(asList(span2)), UTF_8)));
}
Also used : Span(zipkin.Span) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 59 with Span

use of zipkin.Span in project zipkin by openzipkin.

the class CassandraUtilTest method annotationKeys_skipsCoreAndAddressAnnotations.

@Test
public void annotationKeys_skipsCoreAndAddressAnnotations() throws Exception {
    Span span = TestObjects.TRACE.get(1);
    assertThat(span.annotations).extracting(a -> a.value).matches(Constants.CORE_ANNOTATIONS::containsAll);
    assertThat(span.binaryAnnotations).extracting(b -> b.key).containsOnly(Constants.SERVER_ADDR, Constants.CLIENT_ADDR);
    assertThat(CassandraUtil.annotationKeys(span)).isEmpty();
}
Also used : TraceKeys(zipkin.TraceKeys) Rule(org.junit.Rule) ImmutableList(com.google.common.collect.ImmutableList) Span(zipkin.Span) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) Constants(zipkin.Constants) QueryRequest(zipkin.storage.QueryRequest) Test(org.junit.Test) BinaryAnnotation(zipkin.BinaryAnnotation) TestObjects(zipkin.TestObjects) ExpectedException(org.junit.rules.ExpectedException) Span(zipkin.Span) Test(org.junit.Test)

Example 60 with Span

use of zipkin.Span in project zipkin by openzipkin.

the class CassandraUtilTest method annotationKeys_skipsBinaryAnnotationsLongerThan256chars.

@Test
public void annotationKeys_skipsBinaryAnnotationsLongerThan256chars() throws Exception {
    // example long value
    String arn = "arn:aws:acm:us-east-1:123456789012:certificate/12345678-1234-1234-1234-123456789012";
    // example too long value
    String url = "http://webservices.amazon.com/onca/xml?AWSAccessKeyId=AKIAIOSFODNN7EXAMPLE&AssociateTag=mytag-20&ItemId=0679722769&Operation=ItemLookup&ResponseGroup=Images%2CItemAttributes%2COffers%2CReviews&Service=AWSECommerceService&Timestamp=2014-08-18T12%3A00%3A00Z&Version=2013-08-01&Signature=j7bZM0LXZ9eXeZruTqWm2DIvDYVUU3wxPPpp%2BiXxzQc%3D";
    Span span = TestObjects.TRACE.get(1).toBuilder().binaryAnnotations(ImmutableList.of(BinaryAnnotation.create("aws.arn", arn, TestObjects.WEB_ENDPOINT), BinaryAnnotation.create(TraceKeys.HTTP_URL, url, TestObjects.WEB_ENDPOINT))).build();
    assertThat(CassandraUtil.annotationKeys(span)).containsOnly("web:aws.arn:" + arn);
}
Also used : Span(zipkin.Span) Test(org.junit.Test)

Aggregations

Span (zipkin.Span)104 Test (org.junit.Test)84 Endpoint (zipkin.Endpoint)21 BinaryAnnotation (zipkin.BinaryAnnotation)12 ArrayList (java.util.ArrayList)11 Annotation (zipkin.Annotation)10 CodecTest (zipkin.CodecTest)9 CorrectForClockSkew.isLocalSpan (zipkin.internal.CorrectForClockSkew.isLocalSpan)9 ByteBuffer (java.nio.ByteBuffer)8 List (java.util.List)8 Buffer (okio.Buffer)8 LinkedHashMap (java.util.LinkedHashMap)6 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)5 ImmutableList (com.google.common.collect.ImmutableList)4 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)4 LinkedList (java.util.LinkedList)4 Constants (zipkin.Constants)4 ImmutableSet (com.google.common.collect.ImmutableSet)3 IOException (java.io.IOException)3 Arrays.asList (java.util.Arrays.asList)3