Skip to content

Commit

Permalink
[Profiling] Return early when no data are found
Browse files Browse the repository at this point in the history
With this commit we check whether any documents match when custom
indices are provided and terminate early if the response is empty.
  • Loading branch information
danielmitterdorfer committed Feb 12, 2024
1 parent 858c614 commit 4544586
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -176,4 +176,25 @@ public void testGetStackTracesFromAPMNoMatch() throws Exception {
GetStackTracesResponse response = client().execute(GetStackTracesAction.INSTANCE, request).get();
assertEquals(0, response.getTotalFrames());
}

public void testGetStackTracesFromAPMIndexNotAvailable() throws Exception {
TermQueryBuilder query = QueryBuilders.termQuery("transaction.name", "nonExistingTransaction");

GetStackTracesRequest request = new GetStackTracesRequest(
null,
1.0d,
1.0d,
1.0d,
query,
new String[] { "non-existing-apm-index-*" },
"transaction.profiler_stack_trace_ids",
null,
null,
null,
null,
null
);
GetStackTracesResponse response = client().execute(GetStackTracesAction.INSTANCE, request).get();
assertEquals(0, response.getTotalFrames());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,11 @@ private void searchGenericEvents(
request.getIndices(),
responseBuilder.getSamplingRate()
);
searchGenericEventGroupedByStackTrace(submitTask, client, request, submitListener, responseBuilder);
if (sampleCount > 0) {
searchGenericEventGroupedByStackTrace(submitTask, client, request, submitListener, responseBuilder);
} else {
submitListener.onResponse(responseBuilder.build());
}
}, submitListener::onFailure));
}

Expand Down

0 comments on commit 4544586

Please sign in to comment.