com.netflix.servo.monitor
Class ContextualTimer

java.lang.Object
  extended by com.netflix.servo.monitor.AbstractContextualMonitor<java.lang.Long,Timer>
      extended by com.netflix.servo.monitor.ContextualTimer
All Implemented Interfaces:
CompositeMonitor<java.lang.Long>, Monitor<java.lang.Long>, NumericMonitor<java.lang.Long>, Timer

public class ContextualTimer
extends AbstractContextualMonitor<java.lang.Long,Timer>
implements Timer

Composite that maintains separate simple timers for each distinct set of tags returned by the tagging context.


Field Summary
 
Fields inherited from class com.netflix.servo.monitor.AbstractContextualMonitor
baseConfig, context, monitors, newMonitor
 
Constructor Summary
ContextualTimer(MonitorConfig config, TaggingContext context, com.google.common.base.Function<MonitorConfig,Timer> newMonitor)
          Create a new instance of the timer.
 
Method Summary
 java.util.concurrent.TimeUnit getTimeUnit()
          The time unit reported by this timer.
 java.lang.Long getValue()
          Returns the current value for the monitor.
 void record(long duration)
          Record a new value for this timer.
 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.
 
Methods inherited from class com.netflix.servo.monitor.AbstractContextualMonitor
getConfig, getMonitorForCurrentContext, getMonitors
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.netflix.servo.monitor.Monitor
getConfig
 

Constructor Detail

ContextualTimer

public ContextualTimer(MonitorConfig config,
                       TaggingContext context,
                       com.google.common.base.Function<MonitorConfig,Timer> newMonitor)
Create a new instance of the timer.

Parameters:
config - shared configuration
context - provider for context specific tags
newMonitor - function to create new timers
Method Detail

start

public Stopwatch start()
Returns a stopwatch that has been started and will automatically record its result to this timer when stopped.

Specified by:
start in interface Timer

getTimeUnit

public java.util.concurrent.TimeUnit getTimeUnit()
The time unit reported by this timer.

Specified by:
getTimeUnit in interface Timer

record

public void record(long duration)
Record a new value for this timer.

Specified by:
record in interface Timer

record

public void record(long duration,
                   java.util.concurrent.TimeUnit timeUnit)
Record a new value that was collected with the given TimeUnit.

Specified by:
record in interface Timer

getValue

public java.lang.Long getValue()
Returns the current value for the monitor.

Specified by:
getValue in interface Monitor<java.lang.Long>