com.netflix.servo.publish
Class BaseMetricObserver

java.lang.Object
  extended by com.netflix.servo.publish.BaseMetricObserver
All Implemented Interfaces:
MetricObserver
Direct Known Subclasses:
AsyncMetricObserver, FileMetricObserver, MemoryMetricObserver

public abstract class BaseMetricObserver
extends java.lang.Object
implements MetricObserver

Helper class for metric observers that keeps track of the number of calls and number of failures.


Constructor Summary
BaseMetricObserver(java.lang.String name)
          Creates a new instance with a given name.
 
Method Summary
 int getFailedUpdateCount()
          Returns the number of times update failed with an exception.
 java.lang.String getName()
          Name associated with an observer.
 int getUpdateCount()
          Returns the total number of times update has been called.
protected  void incrementFailedCount()
          Can be used by sub-classes to increment the failed count if they handle exception internally.
 void update(java.util.List<Metric> metrics)
          Invoked with the most recent values for a set of metrics.
abstract  void updateImpl(java.util.List<Metric> metrics)
          Update method that should be defined by sub-classes.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BaseMetricObserver

public BaseMetricObserver(java.lang.String name)
Creates a new instance with a given name.

Method Detail

updateImpl

public abstract void updateImpl(java.util.List<Metric> metrics)
Update method that should be defined by sub-classes. This method will get invoked and counts will be maintained in the base observer.


update

public final void update(java.util.List<Metric> metrics)
Invoked with the most recent values for a set of metrics.

Specified by:
update in interface MetricObserver

getName

public final java.lang.String getName()
Name associated with an observer. Mostly used to make log messages more informative.

Specified by:
getName in interface MetricObserver

incrementFailedCount

protected final void incrementFailedCount()
Can be used by sub-classes to increment the failed count if they handle exception internally.


getUpdateCount

public int getUpdateCount()
Returns the total number of times update has been called.


getFailedUpdateCount

public int getFailedUpdateCount()
Returns the number of times update failed with an exception.