com.netflix.servo.monitor
Class BucketTimer

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

public class BucketTimer
extends AbstractMonitor<java.lang.Long>
implements Timer, CompositeMonitor<java.lang.Long>

A simple timer implementation providing the total time, count, min, and max for the times that have been recorded.


Field Summary
 
Fields inherited from class com.netflix.servo.monitor.AbstractMonitor
config
 
Constructor Summary
BucketTimer(MonitorConfig config, BucketConfig bucketConfig)
          Creates a new instance of the timer with a unit of milliseconds.
BucketTimer(MonitorConfig config, BucketConfig bucketConfig, java.util.concurrent.TimeUnit unit)
          Creates a new instance of the timer.
 
Method Summary
 boolean equals(java.lang.Object obj)
          
 java.lang.Long getCount()
          Get the total number of updates.
 java.lang.Long getMax()
          Get the max value since the last reset.
 java.lang.Long getMin()
          Get the min value since the last reset.
 java.util.List<Monitor<?>> getMonitors()
          Returns a list of sub-monitors for this composite.
 java.util.concurrent.TimeUnit getTimeUnit()
          The time unit reported by this timer.
 java.lang.Long getTotalTime()
          Get the total time for all updates.
 java.lang.Long getValue()
          Returns the current value for the monitor.
 int hashCode()
          
 void record(long duration)
          Record a new value for this timer.
 void record(long duration, java.util.concurrent.TimeUnit unit)
          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.
 java.lang.String toString()
          
 
Methods inherited from class com.netflix.servo.monitor.AbstractMonitor
getConfig
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface com.netflix.servo.monitor.Monitor
getConfig
 

Constructor Detail

BucketTimer

public BucketTimer(MonitorConfig config,
                   BucketConfig bucketConfig)
Creates a new instance of the timer with a unit of milliseconds.


BucketTimer

public BucketTimer(MonitorConfig config,
                   BucketConfig bucketConfig,
                   java.util.concurrent.TimeUnit unit)
Creates a new instance of the timer.

Method Detail

getMonitors

public java.util.List<Monitor<?>> getMonitors()
Returns a list of sub-monitors for this composite.

Specified by:
getMonitors in interface CompositeMonitor<java.lang.Long>

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 unit)
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>

getTotalTime

public java.lang.Long getTotalTime()
Get the total time for all updates.


getCount

public java.lang.Long getCount()
Get the total number of updates.


getMin

public java.lang.Long getMin()
Get the min value since the last reset.


getMax

public java.lang.Long getMax()
Get the max value since the last reset.


equals

public boolean equals(java.lang.Object obj)

Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()

Overrides:
hashCode in class java.lang.Object

toString

public java.lang.String toString()

Overrides:
toString in class java.lang.Object