From ea24440cf3fa6a1a7fa2ef3f09035bb1b963a6e5 Mon Sep 17 00:00:00 2001 From: Luck Date: Sun, 14 Nov 2021 19:20:29 +0000 Subject: Print more useful information when async-profiler fails to load --- .../common/sampler/async/AsyncProfilerAccess.java | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) (limited to 'spark-common') diff --git a/spark-common/src/main/java/me/lucko/spark/common/sampler/async/AsyncProfilerAccess.java b/spark-common/src/main/java/me/lucko/spark/common/sampler/async/AsyncProfilerAccess.java index 2506db3..f1d7209 100644 --- a/spark-common/src/main/java/me/lucko/spark/common/sampler/async/AsyncProfilerAccess.java +++ b/spark-common/src/main/java/me/lucko/spark/common/sampler/async/AsyncProfilerAccess.java @@ -73,8 +73,15 @@ public enum AsyncProfilerAccess { public boolean checkSupported(SparkPlatform platform) { if (this.setupException != null) { - platform.getPlugin().log(Level.INFO, "async-profiler engine is not supported on your system: " + this.setupException.getMessage()); - platform.getPlugin().log(Level.INFO, "Please see here for more information: https://spark.lucko.me/docs/misc/Using-async-profiler"); + if (this.setupException instanceof UnsupportedSystemException) { + platform.getPlugin().log(Level.INFO, "The async-profiler engine is not supported for your os/arch (" + + this.setupException.getMessage() + "), so the built-in Java engine will be used instead."); + } else { + platform.getPlugin().log(Level.WARNING, "Unable to initialise the async-profiler engine: " + this.setupException.getMessage()); + platform.getPlugin().log(Level.WARNING, "Please see here for more information: https://spark.lucko.me/docs/misc/Using-async-profiler"); + this.setupException.printStackTrace(); + } + } return this.profiler != null; } @@ -91,7 +98,7 @@ public enum AsyncProfilerAccess { .build(); if (!supported.containsEntry(os, arch)) { - throw new UnsupportedOperationException("Not supported for your os/arch: " + os + '/' + arch); + throw new UnsupportedSystemException(os, arch); } // extract the profiler binary from the spark jar file @@ -127,4 +134,10 @@ public enum AsyncProfilerAccess { throw new UnsupportedOperationException("CPU event is not supported"); } } + + private static final class UnsupportedSystemException extends UnsupportedOperationException { + public UnsupportedSystemException(String os, String arch) { + super(os + '/' + arch); + } + } } -- cgit