com.atlassian.confluence.util.profiling
Class DurationThresholdWarningTimingHelper

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

@Internal
@ThreadSafe
@ParametersAreNonnullByDefault
public class DurationThresholdWarningTimingHelper
extends java.lang.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 newTimer(com.google.common.base.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

Nested Class Summary
static interface DurationThresholdWarningTimingHelper.Timer
          Simple start/stop timing interface to be used by clients.
 
Method Summary
 DurationThresholdWarningTimingHelper.Timer newTimer(com.google.common.base.Supplier<java.lang.String> actionDescriptionSupplier, boolean disableWarnings)
          Creates a new Timer for timing an operation.
 DurationThresholdWarningTimingHelper.Timer newWarningTimer(java.lang.String actionDescriptionFormat, java.lang.Object... actionDescriptionArgs)
          Creates a new timer for timing an operation.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

newTimer

public DurationThresholdWarningTimingHelper.Timer newTimer(com.google.common.base.Supplier<java.lang.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.

newWarningTimer

public DurationThresholdWarningTimingHelper.Timer newWarningTimer(java.lang.String actionDescriptionFormat,
                                                                  java.lang.Object... actionDescriptionArgs)
Creates a new timer for timing an operation. Delegates to newTimer(com.google.common.base.Supplier, boolean)



Copyright © 2003-2014 Atlassian. All Rights Reserved.