Class DurationThresholdWarningTimingHelper

java.lang.Object
com.atlassian.confluence.util.profiling.DurationThresholdWarningTimingHelper

@Internal @ThreadSafe @ParametersAreNonnullByDefault public class DurationThresholdWarningTimingHelper extends Object
A helper class for code that wishes to perform timing of how long an arbitrary operation lasts, and for warnings to be logged if the elapsed time exceeds a configurable threshold.

Typically, clients should obtain an instance using DurationThresholdWarningTimingHelperFactory.createFromSystemProperty(String,java.time.Duration) to allow runtime configuration via a system property.

Clients perform a timing by calling newDescribedTimer(java.util.function.Supplier, boolean) and then DurationThresholdWarningTimingHelper.Timer.start() and DurationThresholdWarningTimingHelper.Timer.stopAndCheckTiming(). Any warnings will be logged when the stop method is called.

Since:
5.5.5
  • Method Details

    • newDescribedTimer

      public DurationThresholdWarningTimingHelper.Timer newDescribedTimer(Supplier<String> actionDescriptionSupplier, boolean disableWarnings)
      Creates a new Timer for timing an operation.
      Parameters:
      actionDescriptionSupplier - Supplies a description of the operation. Will only be invoked if a warning needs to be logged.
      disableWarnings - true if all threshold warnings from this timer should be disabled, false otherwise
      Returns:
      a new Timer to be used for this operation.
      Since:
      6.14
    • newWarningTimer

      public DurationThresholdWarningTimingHelper.Timer newWarningTimer(String actionDescriptionFormat, Object... actionDescriptionArgs)
      Creates a new timer for timing an operation.

      Delegates to newDescribedTimer(Supplier, boolean)