Skip to content

Commit

Permalink
Request level coordinator slow logs
Browse files Browse the repository at this point in the history
Signed-off-by: David Zane <[email protected]>
  • Loading branch information
dzane17 committed Sep 29, 2023
1 parent 7dc6683 commit 9cbc018
Show file tree
Hide file tree
Showing 6 changed files with 490 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -440,6 +440,10 @@ private void onPhaseStart(SearchPhase phase) {
this.searchRequestOperationsListener.ifPresent(searchRequestOperations -> { searchRequestOperations.onPhaseStart(this); });
}

private void onRequestEnd() {
this.searchRequestOperationsListener.ifPresent(searchRequestOperations -> { searchRequestOperations.onRequestEnd(this); });
}

private void executePhase(SearchPhase phase) {
try {
onPhaseStart(phase);
Expand Down Expand Up @@ -697,6 +701,7 @@ public void sendSearchResponse(InternalSearchResponse internalSearchResponse, At
listener.onResponse(buildSearchResponse(internalSearchResponse, failures, scrollId, searchContextId));
}
onPhaseEnd();
onRequestEnd();
setCurrentPhase(null);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ public interface SearchRequestOperationsListener {

void onPhaseFailure(SearchPhaseContext context);

default void onRequestStart() {};

default void onRequestEnd(SearchPhaseContext context) {};

/**
* Holder of Composite Listeners
*
Expand Down Expand Up @@ -73,5 +77,27 @@ public void onPhaseFailure(SearchPhaseContext context) {
}
}
}

@Override
public void onRequestStart() {
for (SearchRequestOperationsListener listener : listeners) {
try {
listener.onRequestStart();
} catch (Exception e) {
logger.warn(() -> new ParameterizedMessage("onRequestStart listener [{}] failed", listener), e);
}
}
}

@Override
public void onRequestEnd(SearchPhaseContext context) {
for (SearchRequestOperationsListener listener : listeners) {
try {
listener.onRequestEnd(context);
} catch (Exception e) {
logger.warn(() -> new ParameterizedMessage("onRequestEnd listener [{}] failed", listener), e);
}
}
}
}
}
Loading

0 comments on commit 9cbc018

Please sign in to comment.