Skip to content

Commit

Permalink
Close WrappedPhase span
Browse files Browse the repository at this point in the history
Signed-off-by: David Zane <[email protected]>
  • Loading branch information
dzane17 committed Feb 21, 2024
1 parent ec73bef commit 0b9106c
Showing 1 changed file with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -462,7 +462,7 @@ private void onRequestEnd(SearchRequestContext searchRequestContext) {
}

private void executePhase(SearchPhase phase) {
final Span phaseSpan = tracer.startSpan(SpanCreationContext.server().name("[phase/" + phase.getName() + "]"));
Span phaseSpan = tracer.startSpan(SpanCreationContext.server().name("[phase/" + phase.getName() + "]"));
try (final SpanScope scope = tracer.withSpanInScope(phaseSpan)) {
onPhaseStart(phase);
phase.recordAndRun();
Expand All @@ -471,7 +471,15 @@ private void executePhase(SearchPhase phase) {
logger.debug(new ParameterizedMessage("Failed to execute [{}] while moving to [{}] phase", request, phase.getName()), e);
}

if (currentPhaseHasLifecycle == false) {
phaseSpan.setError(e);
}

onPhaseFailure(phase, "", e);
} finally {
if (currentPhaseHasLifecycle == false) {
phaseSpan.endSpan();
}
}
}

Expand Down

0 comments on commit 0b9106c

Please sign in to comment.