com.netflix.servo.monitor
Class Monitors

java.lang.Object
  extended by com.netflix.servo.monitor.Monitors

public final class Monitors
extends java.lang.Object

Some helper functions for creating monitor objects.


Method Summary
static CompositeMonitor<?> newCacheMonitor(java.lang.String id, com.google.common.cache.Cache<?,?> cache)
          Creates a new monitor for a cache with standard metrics for the hits, misses, and loads.
static Counter newCounter(java.lang.String name)
          Create a new counter instance.
static Counter newCounter(java.lang.String name, TaggingContext context)
          Create a new counter with a name and context.
static CompositeMonitor<?> newObjectMonitor(java.lang.Object obj)
          Helper function to easily create a composite for all monitor fields and annotated attributes of a given object.
static CompositeMonitor<?> newObjectMonitor(java.lang.String id, java.lang.Object obj)
          Helper function to easily create a composite for all monitor fields and annotated attributes of a given object.
static CompositeMonitor<?> newThreadPoolMonitor(java.lang.String id, java.util.concurrent.ThreadPoolExecutor pool)
          Creates a new monitor for a thread pool with standard metrics for the pool size, queue size, task counts, etc.
static Timer newTimer(java.lang.String name)
          Create a new timer with only the name specified.
static Timer newTimer(java.lang.String name, TaggingContext context)
          Create a new timer with a name and context.
static Timer newTimer(java.lang.String name, java.util.concurrent.TimeUnit unit)
          Create a new timer with only the name specified.
static Timer newTimer(java.lang.String name, java.util.concurrent.TimeUnit unit, TaggingContext context)
          Create a new timer with a name and context.
static void registerObject(java.lang.Object obj)
          Register an object with the default registry.
static void registerObject(java.lang.String id, java.lang.Object obj)
          Register an object with the default registry.
static void unregisterObject(java.lang.Object obj)
          Unregister an object from the default registry.
static void unregisterObject(java.lang.String id, java.lang.Object obj)
          Unregister an object from the default registry.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

newTimer

public static Timer newTimer(java.lang.String name)
Create a new timer with only the name specified.


newTimer

public static Timer newTimer(java.lang.String name,
                             TaggingContext context)
Create a new timer with a name and context. The returned timer will maintain separate sub-monitors for each distinct set of tags returned from the context on an update operation.


newTimer

public static Timer newTimer(java.lang.String name,
                             java.util.concurrent.TimeUnit unit)
Create a new timer with only the name specified.


newTimer

public static Timer newTimer(java.lang.String name,
                             java.util.concurrent.TimeUnit unit,
                             TaggingContext context)
Create a new timer with a name and context. The returned timer will maintain separate sub-monitors for each distinct set of tags returned from the context on an update operation.


newCounter

public static Counter newCounter(java.lang.String name)
Create a new counter instance.


newCounter

public static Counter newCounter(java.lang.String name,
                                 TaggingContext context)
Create a new counter with a name and context. The returned counter will maintain separate sub-monitors for each distinct set of tags returned from the context on an update operation.


newObjectMonitor

public static CompositeMonitor<?> newObjectMonitor(java.lang.Object obj)
Helper function to easily create a composite for all monitor fields and annotated attributes of a given object.


newObjectMonitor

public static CompositeMonitor<?> newObjectMonitor(java.lang.String id,
                                                   java.lang.Object obj)
Helper function to easily create a composite for all monitor fields and annotated attributes of a given object.

Parameters:
id - a unique id associated with this particular instance of the object. If multiple objects of the same class are registered they will have the same config and conflict unless the id values are distinct.
obj - object to search for monitors on. All fields of type Monitor and fields/methods with a Monitor annotation will be extracted and returned using CompositeMonitor.getMonitors().
Returns:
composite monitor based on the fields of the class

newThreadPoolMonitor

public static CompositeMonitor<?> newThreadPoolMonitor(java.lang.String id,
                                                       java.util.concurrent.ThreadPoolExecutor pool)
Creates a new monitor for a thread pool with standard metrics for the pool size, queue size, task counts, etc.

Parameters:
id - id to differentiate metrics for this pool from others.
pool - thread pool instance to monitor.
Returns:
composite monitor based on stats provided for the pool

newCacheMonitor

public static CompositeMonitor<?> newCacheMonitor(java.lang.String id,
                                                  com.google.common.cache.Cache<?,?> cache)
Creates a new monitor for a cache with standard metrics for the hits, misses, and loads.

Parameters:
id - id to differentiate metrics for this cache from others.
cache - cache instance to monitor.
Returns:
composite monitor based on stats provided for the cache

registerObject

public static void registerObject(java.lang.Object obj)
Register an object with the default registry. Equivalent to DefaultMonitorRegistry.getInstance().register(Monitors.newObjectMonitor(obj)).


unregisterObject

public static void unregisterObject(java.lang.Object obj)
Unregister an object from the default registry. Equivalent to DefaultMonitorRegistry.getInstance().unregister(Monitors.newObjectMonitor(obj)).

Parameters:
obj - Previously registered using Monitors.registerObject(obj)

unregisterObject

public static void unregisterObject(java.lang.String id,
                                    java.lang.Object obj)
Unregister an object from the default registry. Equivalent to DefaultMonitorRegistry.getInstance().unregister(Monitors.newObjectMonitor(id, obj)).

Parameters:
obj - Previously registered using Monitors.registerObject(id, obj)

registerObject

public static void registerObject(java.lang.String id,
                                  java.lang.Object obj)
Register an object with the default registry. Equivalent to DefaultMonitorRegistry.getInstance().register(Monitors.newObjectMonitor(id, obj)).