diff --git a/core/src/main/java/com/taobao/arthas/core/command/monitor200/ProfilerCommand.java b/core/src/main/java/com/taobao/arthas/core/command/monitor200/ProfilerCommand.java index f3b66aa31..e12f2266d 100644 --- a/core/src/main/java/com/taobao/arthas/core/command/monitor200/ProfilerCommand.java +++ b/core/src/main/java/com/taobao/arthas/core/command/monitor200/ProfilerCommand.java @@ -50,6 +50,7 @@ import one.profiler.Counter; + " profiler stop --format svg # output file format, support svg,html,jfr\n" + " profiler stop --file /tmp/result.html\n" + " profiler stop --threads \n" + + " profiler start --include 'java/*' --include 'demo/*' --exclude '*Unsafe.park*'\n" + " profiler status\n" + " profiler resume # Start or resume profiling without resetting collected data.\n" + " profiler getSamples # Get the number of samples collected during the profiling session\n" @@ -104,6 +105,16 @@ public class ProfilerCommand extends AnnotatedCommand { */ private Long duration; + /** + * include stack traces containing PATTERN + */ + private List includes; + + /** + * exclude stack traces containing PATTERN + */ + private List excludes; + private static String libPath; private static AsyncProfiler profiler = null; @@ -206,6 +217,18 @@ public class ProfilerCommand extends AnnotatedCommand { this.duration = duration; } + @Option(longName = "include") + @Description("include stack traces containing PATTERN, for example: 'java/*'") + public void setInclude(List includes) { + this.includes = includes; + } + + @Option(longName = "exclude") + @Description("exclude stack traces containing PATTERN, for example: '*Unsafe.park*'") + public void setExclude(List excludes) { + this.excludes = excludes; + } + private AsyncProfiler profilerInstance() { if (profiler != null) { return profiler; @@ -271,6 +294,16 @@ public class ProfilerCommand extends AnnotatedCommand { if (this.alluser) { sb.append("alluser").append(','); } + if (this.includes != null) { + for (String include : includes) { + sb.append("include=").append(include).append(','); + } + } + if (this.excludes != null) { + for (String exclude : excludes) { + sb.append("exclude=").append(exclude).append(','); + } + } return sb.toString(); }