Exemple #1
0
  @Test
  public void binaryAnnotation_double() {
    String json =
        "{\n"
            + "  \"traceId\": \"6b221d5bc9e6496c\",\n"
            + "  \"name\": \"get-traces\",\n"
            + "  \"id\": \"6b221d5bc9e6496c\",\n"
            + "  \"binaryAnnotations\": [\n"
            + "    {\n"
            + "      \"key\": \"num\",\n"
            + "      \"value\": 1.23456789,\n"
            + "      \"type\": \"DOUBLE\"\n"
            + "    }\n"
            + "  ]\n"
            + "}";

    Span span = Codec.JSON.readSpan(json.getBytes(Util.UTF_8));
    assertThat(span.binaryAnnotations)
        .containsExactly(
            BinaryAnnotation.builder()
                .key("num")
                .type(BinaryAnnotation.Type.DOUBLE)
                .value(toBytes(Double.doubleToRawLongBits(1.23456789)))
                .build());

    assertThat(Codec.JSON.readSpan(Codec.JSON.writeSpan(span))).isEqualTo(span);
  }
 private static void ensureServerAddr(Span span, zipkin.Span.Builder zipkinSpan, Endpoint ep) {
   String serviceName =
       span.tags().containsKey(Span.SPAN_PEER_SERVICE_TAG_NAME)
           ? span.tags().get(Span.SPAN_PEER_SERVICE_TAG_NAME)
           : ep.serviceName;
   Endpoint endpoint =
       ep.port == null
           ? Endpoint.create(serviceName, ep.ipv4)
           : Endpoint.create(serviceName, ep.ipv4, ep.port);
   zipkinSpan.addBinaryAnnotation(BinaryAnnotation.address(Constants.SERVER_ADDR, endpoint));
 }
 private static void ensureLocalComponent(Span span, Builder zipkinSpan, Endpoint ep) {
   if (span.tags().containsKey(Constants.LOCAL_COMPONENT)) {
     return;
   }
   String processId =
       span.getProcessId() != null
           ? span.getProcessId().toLowerCase()
           : ZipkinMessageListener.UNKNOWN_PROCESS_ID;
   zipkinSpan.addBinaryAnnotation(
       BinaryAnnotation.create(Constants.LOCAL_COMPONENT, processId, ep));
 }