コード例 #1
0
  /** Sleuth host corresponds to annotation/binaryAnnotation.host in zipkin. */
  @Test
  public void annotationsIncludeHost() {
    span.log("http/request/retry");
    span.tag("spring-boot/version", "1.3.1.RELEASE");

    io.zipkin.Span result = ZipkinMessageListener.convert(span, host);

    assertThat(result.annotations.get(0).endpoint).isEqualTo(endpoint);
    assertThat(result.binaryAnnotations.get(0).endpoint)
        .isEqualTo(result.annotations.get(0).endpoint);
  }
コード例 #2
0
  /** Sleuth timestamps are millisecond granularity while zipkin is microsecond. */
  @Test
  public void convertsTimestampAndDurationToMicroseconds() {
    long start = System.currentTimeMillis();
    span.log("http/request/retry"); // System.currentTimeMillis

    io.zipkin.Span result = ZipkinMessageListener.convert(span, host);

    assertThat(result.timestamp).isEqualTo(span.getBegin() * 1000);
    assertThat(result.duration).isEqualTo((span.getEnd() - span.getBegin()) * 1000);
    assertThat(result.annotations.get(0).timestamp)
        .isGreaterThanOrEqualTo(start * 1000)
        .isLessThanOrEqualTo(System.currentTimeMillis() * 1000);
  }
コード例 #3
0
  // TODO: "unknown" bc process id, documented as not nullable, is null in some tests.
  @Test
  public void nullProcessIdCoercesToUnknownServiceName() {
    MilliSpan noProcessId = MilliSpan.builder().traceId(1L).name("parent").remote(true).build();

    io.zipkin.Span result = ZipkinMessageListener.convert(noProcessId, host);

    assertThat(result.binaryAnnotations)
        .containsOnly(BinaryAnnotation.create("lc", "unknown", endpoint));
  }
コード例 #4
0
  /**
   * In zipkin, the service context is attached to annotations. Sleuth spans that have no
   * annotations will get an "lc" one, which allows them to be queryable in zipkin by service name.
   */
  @Test
  public void spanWithoutAnnotationsLogsComponent() {
    io.zipkin.Span result = ZipkinMessageListener.convert(span, host);

    assertThat(result.binaryAnnotations).hasSize(1);
    assertThat(result.binaryAnnotations.get(0))
        .isEqualToComparingFieldByField(
            BinaryAnnotation.create("lc", span.getProcessId(), endpoint));
  }