Search in sources :

Example 6 with SearchRequest

use of zipkin2.elasticsearch.internal.client.SearchRequest in project zipkin by openzipkin.

the class ElasticsearchSpanStore method aggregatedFieldByServiceName.

Call<List<String>> aggregatedFieldByServiceName(String serviceName, String term) {
    if (serviceName.isEmpty() || !searchEnabled)
        return Call.emptyList();
    long endMillis = System.currentTimeMillis();
    long beginMillis = endMillis - namesLookback;
    List<String> indices = indexNameFormatter.formatTypeAndRange(TYPE_SPAN, beginMillis, endMillis);
    if (indices.isEmpty())
        return Call.emptyList();
    // A span name is only valid on a local endpoint, as a span name is defined locally
    SearchRequest.Filters filters = new SearchRequest.Filters().addRange("timestamp_millis", beginMillis, endMillis).addTerm("localEndpoint.serviceName", serviceName.toLowerCase(Locale.ROOT));
    SearchRequest request = SearchRequest.create(indices).filters(filters).addAggregation(Aggregation.terms(term, Integer.MAX_VALUE));
    return search.newCall(request, BodyConverters.KEYS);
}
Also used : SearchRequest(zipkin2.elasticsearch.internal.client.SearchRequest)

Aggregations

SearchRequest (zipkin2.elasticsearch.internal.client.SearchRequest)6 Arrays.asList (java.util.Arrays.asList)1 LinkedHashSet (java.util.LinkedHashSet)1 List (java.util.List)1 Map (java.util.Map)1 Span (zipkin2.Span)1 Aggregation (zipkin2.elasticsearch.internal.client.Aggregation)1