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, org.joda.time.Duration)
to allow runtime configuration via a system property.Clients perform a timing by calling
newDescribedTimer(java.util.function.Supplier, boolean)
and thenDurationThresholdWarningTimingHelper.Timer.start()
andDurationThresholdWarningTimingHelper.Timer.stopAndCheckTiming()
. Any warnings will be logged when the stop method is called.- Since:
- 5.5.5
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
DurationThresholdWarningTimingHelper.Timer
Simple start/stop timing interface to be used by clients.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description DurationThresholdWarningTimingHelper.Timer
newDescribedTimer(Supplier<String> actionDescriptionSupplier, boolean disableWarnings)
Creates a new Timer for timing an operation.DurationThresholdWarningTimingHelper.Timer
newTimer(com.google.common.base.Supplier<String> actionDescriptionSupplier, boolean disableWarnings)
Deprecated.since 6.14.DurationThresholdWarningTimingHelper.Timer
newWarningTimer(String actionDescriptionFormat, Object... actionDescriptionArgs)
Creates a new timer for timing an operation.
-
-
-
Method Detail
-
newTimer
@Deprecated public DurationThresholdWarningTimingHelper.Timer newTimer(com.google.common.base.Supplier<String> actionDescriptionSupplier, boolean disableWarnings)
Deprecated.since 6.14. UsenewDescribedTimer(java.util.function.Supplier, boolean)
instead.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.
-
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)
-
-