Skip to content

Commit d3ce1ed

Browse files
authored
handle profiler being shutdown more than once (#2527)
1 parent 287231a commit d3ce1ed

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

inferred-spans/src/main/java/io/opentelemetry/contrib/inferredspans/internal/SamplingProfiler.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -454,8 +454,16 @@ private void profile(Duration profilingDuration) throws Exception {
454454
// dynamically
455455
consumeActivationEventsFromRingBufferAndWriteToFile(profilingDuration);
456456
} finally {
457-
String stopMessage = profiler.execute("stop");
458-
logger.fine(stopMessage);
457+
try {
458+
String stopMessage = profiler.execute("stop");
459+
logger.fine(stopMessage);
460+
} catch (IllegalStateException e) {
461+
if (e.getMessage() != null && e.getMessage().contains("Profiler is not active")) {
462+
logger.fine("Profiler already stopped");
463+
} else {
464+
logger.log(Level.WARNING, "Failure shutting down profiler", e);
465+
}
466+
}
459467
}
460468

461469
// When post-processing is disabled, jfr file will not be parsed and the heavy processing will

0 commit comments

Comments
 (0)