profiler command support include/exclude options. #1479

This commit is contained in:
hengyunabc
2020-09-07 20:51:17 +08:00
parent fa4561533f
commit b522ab1472
@@ -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<String> includes;
/**
* exclude stack traces containing PATTERN
*/
private List<String> 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<String> includes) {
this.includes = includes;
}
@Option(longName = "exclude")
@Description("exclude stack traces containing PATTERN, for example: '*Unsafe.park*'")
public void setExclude(List<String> 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();
}