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);
}
Aggregations