Skip to content

Commit

Permalink
Address review comments
Browse files Browse the repository at this point in the history
Signed-off-by: Siddhant Deshmukh <deshsid@amazon.com>
  • Loading branch information
deshsidd committed Jul 18, 2024
1 parent fbd65a7 commit 57b679b
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,9 @@ public SearchRequestOperationsListener.CompositeListener buildCompositeListener(
final SearchRequestOperationsListener... perRequestListeners
) {
final List<SearchRequestOperationsListener> searchListenersList = Stream.concat(
Arrays.stream(perRequestListeners),
searchRequestListenersList.stream()
searchRequestListenersList.stream(),
Arrays.stream(perRequestListeners)

)
.filter((searchRequestOperationsListener -> searchRequestOperationsListener.isEnabled(searchRequest)))
.collect(Collectors.toList());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@
import org.opensearch.search.profile.ProfileShardResult;
import org.opensearch.search.profile.SearchProfileShardResults;
import org.opensearch.tasks.CancellableTask;
import org.opensearch.tasks.SearchTaskResourceOperationsListener;
import org.opensearch.tasks.SearchTaskRequestOperationsListener;
import org.opensearch.tasks.Task;
import org.opensearch.tasks.TaskResourceTrackingService;
import org.opensearch.telemetry.metrics.MetricsRegistry;
Expand Down Expand Up @@ -435,7 +435,7 @@ private void executeRequest(
originalSearchRequest,
logger,
TraceableSearchRequestOperationsListener.create(tracer, requestSpan),
new SearchTaskResourceOperationsListener(taskResourceTrackingService)
new SearchTaskRequestOperationsListener(taskResourceTrackingService)
);
SearchRequestContext searchRequestContext = new SearchRequestContext(
requestOperationsListeners,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,31 +13,18 @@
import org.opensearch.action.search.SearchRequestOperationsListener;

/**
* SearchTaskResourceOperationsListener subscriber for operations on search tasks resource usages.
* SearchTaskRequestOperationsListener subscriber for operations on search tasks resource usages.
* Listener ensures to refreshResourceStats on request end capturing the search task resource usage
* upon request completion.
*
* @PublicApi
*/
public final class SearchTaskResourceOperationsListener extends SearchRequestOperationsListener {
public final class SearchTaskRequestOperationsListener extends SearchRequestOperationsListener {
private final TaskResourceTrackingService taskResourceTrackingService;

public SearchTaskResourceOperationsListener(TaskResourceTrackingService taskResourceTrackingService) {
public SearchTaskRequestOperationsListener(TaskResourceTrackingService taskResourceTrackingService) {
this.taskResourceTrackingService = taskResourceTrackingService;
}

@Override
protected void onPhaseStart(SearchPhaseContext context) {}

@Override
protected void onPhaseEnd(SearchPhaseContext context, SearchRequestContext searchRequestContext) {}

@Override
protected void onPhaseFailure(SearchPhaseContext context, Throwable cause) {}

@Override
public void onRequestStart(SearchRequestContext searchRequestContext) {}

@Override
public void onRequestEnd(SearchPhaseContext context, SearchRequestContext searchRequestContext) {
taskResourceTrackingService.refreshResourceStats(context.getTask());
Expand Down

0 comments on commit 57b679b

Please sign in to comment.