CassandraUtil { static List<String> annotationKeys(QueryRequest request) { Set<String> annotationKeys = new LinkedHashSet<>(); for (Map.Entry<String, String> e : request.annotationQuery().entrySet()) { if (e.getValue().isEmpty()) { annotationKeys.add(e.getKey()); } else { annotationKeys.add(e.getKey() + "=" + e.getValue()); } } return new ArrayList<>(annotationKeys); }  static int durationIndexBucket(long ts_micro);  }
@Test public void annotationKeys_emptyRequest() { assertThat( CassandraUtil.annotationKeys( QueryRequest.newBuilder() .endTs(System.currentTimeMillis()) .limit(10) .serviceName("test") .lookback(86400000L) .build())) .isEmpty(); }
@Test public void annotationKeys() { assertThat( CassandraUtil.annotationKeys( QueryRequest.newBuilder() .endTs(System.currentTimeMillis()) .limit(10) .lookback(86400000L) .serviceName("service") .parseAnnotationQuery("error and http.method=GET") .build())) .containsExactly("error", "http.method=GET"); }
@Test public void annotationKeys_dedupes() { assertThat( CassandraUtil.annotationKeys( QueryRequest.newBuilder() .endTs(System.currentTimeMillis()) .limit(10) .lookback(86400000L) .serviceName("service") .parseAnnotationQuery("error and error") .build())) .containsExactly("error"); }