Search in sources :

Example 1 with TABLE_SPAN

use of zipkin2.storage.cassandra.Schema.TABLE_SPAN in project zipkin by openzipkin.

the class CassandraUtil method annotationQuery.

/**
 * Returns a set of annotation getValues and tags joined on equals, delimited by ░
 *
 * <p>Values over {@link RecyclableBuffers#SHORT_STRING_LENGTH} are not considered. Zipkin's
 * {@link QueryRequest#annotationQuery()} are equals match. Not all values are lookup values. For
 * example, {@code sql.query} isn't something that is likely to be looked up by value and indexing
 * that could add a potentially kilobyte partition key on {@link Schema#TABLE_SPAN}
 *
 * @see QueryRequest#annotationQuery()
 */
@Nullable
static String annotationQuery(Span span) {
    if (span.annotations().isEmpty() && span.tags().isEmpty())
        return null;
    // as very unlikely to be in the query
    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;
        // search is possible by key alone
        result.append(tag.getKey()).append(delimiter);
        result.append(tag.getKey()).append('=').append(tag.getValue()).append(delimiter);
    }
    return result.length() == 1 ? null : result.toString();
}
Also used : TreeMap(java.util.TreeMap) Map(java.util.Map) Annotation(zipkin2.Annotation) Nullable(zipkin2.internal.Nullable)

Aggregations

Map (java.util.Map)1 TreeMap (java.util.TreeMap)1 Annotation (zipkin2.Annotation)1 Nullable (zipkin2.internal.Nullable)1