ElasticsearchSpanStore implements SpanStore, Traces, ServiceAndSpanNames { @Override public Call<List<String>> getServiceNames() { if (!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(); SearchRequest request = SearchRequest.create(indices) .filters(new SearchRequest.Filters().addRange("timestamp_millis", beginMillis, endMillis)) .addAggregation(Aggregation.terms("localEndpoint.serviceName", Integer.MAX_VALUE)); return search.newCall(request, BodyConverters.KEYS); } ElasticsearchSpanStore(ElasticsearchStorage es); @Override Call<List<List<Span>>> getTraces(QueryRequest request); @Override Call<List<Span>> getTrace(String traceId); @Override Call<List<List<Span>>> getTraces(Iterable<String> traceIds); @Override Call<List<String>> getServiceNames(); @Override Call<List<String>> getRemoteServiceNames(String serviceName); @Override Call<List<String>> getSpanNames(String serviceName); @Override Call<List<DependencyLink>> getDependencies(long endTs, long lookback);  }
@Test void serviceNames_defaultsTo24HrsAgo_6x() throws Exception { server.enqueue(AggregatedHttpResponse.of( HttpStatus.OK, MediaType.JSON_UTF_8, TestResponses.SERVICE_NAMES)); spanStore.getServiceNames().execute(); requestLimitedTo2DaysOfIndices_singleTypeIndex(); }