Example #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);
  }
Example #2
0
  @Test
  public void ignoreNull_debug() {
    String json =
        "{\n"
            + "  \"traceId\": \"6b221d5bc9e6496c\",\n"
            + "  \"name\": \"get-traces\",\n"
            + "  \"id\": \"6b221d5bc9e6496c\",\n"
            + "  \"debug\": null\n"
            + "}";

    Codec.JSON.readSpan(json.getBytes(Util.UTF_8));
  }
Example #3
0
  @Test
  public void niceErrorOnNull_id() {
    thrown.expect(IllegalArgumentException.class);
    thrown.expectMessage("Expected a string but was NULL");

    String json =
        "{\n"
            + "  \"traceId\": \"6b221d5bc9e6496c\",\n"
            + "  \"name\": \"get-traces\",\n"
            + "  \"id\": null\n"
            + "}";

    Codec.JSON.readSpan(json.getBytes(Util.UTF_8));
  }
Example #4
0
  @Test
  public void ignoreNull_binaryAnnotation_endpoint() {
    String json =
        "{\n"
            + "  \"traceId\": \"6b221d5bc9e6496c\",\n"
            + "  \"name\": \"get-traces\",\n"
            + "  \"id\": \"6b221d5bc9e6496c\",\n"
            + "  \"binaryAnnotations\": [\n"
            + "    {\n"
            + "      \"key\": \"lc\",\n"
            + "      \"value\": \"JDBCSpanStore\",\n"
            + "      \"endpoint\": null\n"
            + "    }\n"
            + "  ]\n"
            + "}";

    Codec.JSON.readSpan(json.getBytes(Util.UTF_8));
  }
Example #5
0
  @Test
  public void ignoreNull_annotation_endpoint() {
    String json =
        "{\n"
            + "  \"traceId\": \"6b221d5bc9e6496c\",\n"
            + "  \"name\": \"get-traces\",\n"
            + "  \"id\": \"6b221d5bc9e6496c\",\n"
            + "  \"annotations\": [\n"
            + "    {\n"
            + "      \"timestamp\": 1461750491274000,\n"
            + "      \"value\": \"cs\",\n"
            + "      \"endpoint\": null\n"
            + "    }\n"
            + "  ]\n"
            + "}";

    Codec.JSON.readSpan(json.getBytes(Util.UTF_8));
  }