public class ContextualTimer extends AbstractContextualMonitor<java.lang.Long,Timer> implements Timer
baseConfig, context, monitors, newMonitor
Constructor and Description |
---|
ContextualTimer(MonitorConfig config,
TaggingContext context,
com.google.common.base.Function<MonitorConfig,Timer> newMonitor)
Create a new instance of the timer.
|
Modifier and Type | Method and Description |
---|---|
java.util.concurrent.TimeUnit |
getTimeUnit()
The time unit reported by this timer.
|
java.lang.Long |
getValue(int pollerIndex)
Returns the current value for the monitor for the nth poller.
|
void |
record(long duration)
Deprecated.
|
void |
record(long duration,
java.util.concurrent.TimeUnit timeUnit)
Record a new value that was collected with the given TimeUnit.
|
Stopwatch |
start()
Returns a stopwatch that has been started and will automatically
record its result to this timer when stopped.
|
getConfig, getMonitorForCurrentContext, getMonitors, getValue
public ContextualTimer(MonitorConfig config, TaggingContext context, com.google.common.base.Function<MonitorConfig,Timer> newMonitor)
config
- shared configurationcontext
- provider for context specific tagsnewMonitor
- function to create new timerspublic Stopwatch start()
public java.util.concurrent.TimeUnit getTimeUnit()
getTimeUnit
in interface Timer
@Deprecated public void record(long duration)
public void record(long duration, java.util.concurrent.TimeUnit timeUnit)