Class FilteredStackProfiler


  • public class FilteredStackProfiler
    extends Profiler
    This class functions very similar to the Profiler. The difference between the two is that this class only counts samples whose stack trace contains an entry matching a particular pattern.

    This is useful for drilling down into particular regions of code within an application also busy doing other things; for example, a production HTTP API may have many endpoints, but you only want to know what one of them spends its time doing.

    Since:
    5.35
    • Constructor Summary

      Constructors 
      Constructor Description
      FilteredStackProfiler​(int pollIntervalInMs, java.lang.String pattern)
      Constructs a new profiler instance.
      FilteredStackProfiler​(int pollIntervalInMs, java.util.function.Function<? super Profiler,​java.lang.String> startFutureResultSupplier, java.lang.String pattern)
      Constructs a new profiler instance.
      FilteredStackProfiler​(int pollIntervalInMs, java.util.function.Function<? super Profiler,​java.lang.String> startFutureResultSupplier, java.util.function.Predicate<java.lang.StackTraceElement[]> filter)
      Constructs a new profiler instance.
      FilteredStackProfiler​(int pollIntervalInMs, java.util.function.Predicate<java.lang.StackTraceElement[]> filter)
      Constructs a new profiler instance.
      FilteredStackProfiler​(java.lang.String pattern)
      Constructs a new profiler instance.
      FilteredStackProfiler​(java.util.function.Predicate<java.lang.StackTraceElement[]> filter)
      Constructs a new profiler instance.
    • Constructor Detail

      • FilteredStackProfiler

        public FilteredStackProfiler​(java.lang.String pattern)
        Constructs a new profiler instance. The only way to get results from this instance is to call #dump() with a provided output stream to get the results to.
        Parameters:
        pattern - Only stack traces where the string representation of a StackTraceElement matches this regular expression will be counted.
      • FilteredStackProfiler

        public FilteredStackProfiler​(java.util.function.Predicate<java.lang.StackTraceElement[]> filter)
        Constructs a new profiler instance. The only way to get results from this instance is to call #dump() with a provided output stream to get the results to.
        Parameters:
        filter - Only stack traces where the predicate returns true will be included
      • FilteredStackProfiler

        public FilteredStackProfiler​(int pollIntervalInMs,
                                     java.lang.String pattern)
        Constructs a new profiler instance. The only way to get results from this instance is to call #dump() with a provided output stream to get the results to.
        Parameters:
        pollIntervalInMs - frequency to check running threads
        pattern - Only stack traces where the string representation of a StackTraceElement matches this regular expression will be counted.
      • FilteredStackProfiler

        public FilteredStackProfiler​(int pollIntervalInMs,
                                     java.util.function.Predicate<java.lang.StackTraceElement[]> filter)
        Constructs a new profiler instance. The only way to get results from this instance is to call #dump() with a provided output stream to get the results to.
        Parameters:
        pollIntervalInMs - frequency to check running threads
        filter - Only stack traces where the predicate returns true will be included
      • FilteredStackProfiler

        public FilteredStackProfiler​(int pollIntervalInMs,
                                     java.util.function.Function<? super Profiler,​java.lang.String> startFutureResultSupplier,
                                     java.lang.String pattern)
        Constructs a new profiler instance. The only way to get results from this instance is to call #dump() with a provided output stream to get the results to.

        This constructor allows you to change the behavior of the ListenableFuture result when Profiler.start(long) or Profiler.start(Executor, long) is used. Generally this will provide the complete result of Profiler.dump(). This can be replaced with calling Profiler.dump(OutputStream, boolean, int) with parameters to reduce the output, or even null so long as the consumers of the future can handle a null result.

        Parameters:
        pollIntervalInMs - frequency to check running threads
        startFutureResultSupplier - Supplier to be used for providing future results
        pattern - Only stack traces where the string representation of a StackTraceElement matches this regular expression will be counted.
      • FilteredStackProfiler

        public FilteredStackProfiler​(int pollIntervalInMs,
                                     java.util.function.Function<? super Profiler,​java.lang.String> startFutureResultSupplier,
                                     java.util.function.Predicate<java.lang.StackTraceElement[]> filter)
        Constructs a new profiler instance. The only way to get results from this instance is to call #dump() with a provided output stream to get the results to.

        This constructor allows you to change the behavior of the ListenableFuture result when Profiler.start(long) or Profiler.start(Executor, long) is used. Generally this will provide the complete result of Profiler.dump(). This can be replaced with calling Profiler.dump(OutputStream, boolean, int) with parameters to reduce the output, or even null so long as the consumers of the future can handle a null result.

        Parameters:
        pollIntervalInMs - frequency to check running threads
        startFutureResultSupplier - Supplier to be used for providing future results
        filter - Only stack traces where the predicate returns true will be included