CassandraUtil { static @Nullable String annotationQuery(Span span) { if (span.annotations().isEmpty() && span.tags().isEmpty()) return null; char delimiter = '░'; StringBuilder result = new StringBuilder().append(delimiter); for (Annotation a : span.annotations()) { if (a.value().length() > SHORT_STRING_LENGTH) continue; result.append(a.value()).append(delimiter); } for (Map.Entry<String, String> tag : span.tags().entrySet()) { if (tag.getValue().length() > SHORT_STRING_LENGTH) continue; result.append(tag.getKey()).append(delimiter); result.append(tag.getKey()).append('=').append(tag.getValue()).append(delimiter); } return result.length() == 1 ? null : result.toString(); }  static int durationIndexBucket(long ts_micro);  }
@Test public void annotationKeys_skipsTagsLongerThan256chars() { String arn = "arn:aws:acm:us-east-1:123456789012:certificate/12345678-1234-1234-1234-123456789012"; String url = "http: Span span = TestObjects.CLIENT_SPAN.toBuilder().putTag("aws.arn", arn).putTag("http.url", url).build(); assertThat(CassandraUtil.annotationQuery(span)) .contains("aws.arn", "aws.arn=" + arn) .doesNotContain("http.url") .doesNotContain("http.url=" + url); }
@Test public void annotationKeys_skipsAnnotationsLongerThan256chars() { String arn = "arn:aws:acm:us-east-1:123456789012:certificate/12345678-1234-1234-1234-123456789012"; String url = "http: Span span = TestObjects.CLIENT_SPAN.toBuilder().addAnnotation(1L, arn).addAnnotation(1L, url).build(); assertThat(CassandraUtil.annotationQuery(span)).contains(arn).doesNotContain(url); }
@Test public void annotationKeys_skipsAllocationWhenNoValidInput() { String url = "http: Span span = Span.newBuilder().traceId("1").id("1").build(); assertThat(CassandraUtil.annotationQuery(span)).isNull(); span = span.toBuilder().addAnnotation(1L, url).putTag("http.url", url).build(); assertThat(CassandraUtil.annotationQuery(span)).isNull(); }