/** * @param threadFilter when returns true the thread is being ignored */ public FastStackCollector(final Predicate<Thread> threadFilter, final int maxNrSampledThreads) { this.threadFilter = threadFilter; this.collector = new StackCollectorImpl(); this.maxNrSampledThreads = maxNrSampledThreads; }
public ThreadStackSampler(final int maxSampledThreads, final Supplier<Iterable<Thread>> threadSupplier) { requestFor = new Thread[maxSampledThreads]; this.threadSupplier = threadSupplier; this.collector = new StackCollectorImpl(); }
public MxStackCollector(final Thread ignore) { this.ignore = ignore; this.collector = new StackCollectorImpl(); }
public SimpleStackCollector(final Thread ignore) { this.ignore = ignore; this.collector = new StackCollectorImpl(); }
@Override public void sample() { Iterable<Map.Entry<Thread, ExecutionContext>> currentThreads = execCtxSupplier.get(); int i = 0; for (Map.Entry<Thread, ExecutionContext> entry : currentThreads) { requestFor[i] = entry.getKey(); contexts[i++] = entry.getValue(); if (i >= requestFor.length) { break; } } Arrays.fill(requestFor, i, requestFor.length, null); StackTraceElement[][] stackTraces = Threads.getStackTraces(requestFor); for (int j = 0; j < i; j++) { StackTraceElement[] stackTrace = stackTraces[j]; if (stackTrace != null && stackTrace.length > 0) { ExecutionContext context = contexts[j]; context.add(stackTrace); String name = ctxToCategory.apply(context); StackCollector c = collections.computeIfAbsent(name, (k) -> new StackCollectorImpl()); c.collect(stackTrace); } } }
@SuppressFBWarnings({"PRMC_POSSIBLY_REDUNDANT_METHOD_CALLS", "ES_COMPARING_STRINGS_WITH_EQ"}) public void testSample() { StackCollector instance = new StackCollectorImpl(); StackTraceElement[] st1 = new StackTraceElement[3]; st1[0] = new StackTraceElement("C1", "m1", "C1.java", 10);