com.netflix.servo.monitor
Class AbstractContextualMonitor<T,M extends Monitor<T>>

java.lang.Object
  extended by com.netflix.servo.monitor.AbstractContextualMonitor<T,M>
All Implemented Interfaces:
CompositeMonitor<T>, Monitor<T>
Direct Known Subclasses:
ContextualCounter, ContextualTimer

public abstract class AbstractContextualMonitor<T,M extends Monitor<T>>
extends java.lang.Object
implements CompositeMonitor<T>

Base class used to simplify creation of contextual monitors.


Field Summary
protected  MonitorConfig baseConfig
          Base configuration shared across all contexts.
protected  TaggingContext context
          Context to query when accessing a monitor.
protected  java.util.concurrent.ConcurrentMap<MonitorConfig,M> monitors
          Thread-safe map keeping track of the distinct monitors that have been created so far.
protected  com.google.common.base.Function<MonitorConfig,M> newMonitor
          Factory funtion used to create a new instance of a monitor.
 
Constructor Summary
protected AbstractContextualMonitor(MonitorConfig baseConfig, TaggingContext context, com.google.common.base.Function<MonitorConfig,M> newMonitor)
          Create a new instance of the monitor.
 
Method Summary
 MonitorConfig getConfig()
          Configuration used to identify a monitor and provide metadata used in aggregations.
protected  M getMonitorForCurrentContext()
          Returns a monitor instance for the current context.
 java.util.List<Monitor<?>> getMonitors()
          Returns a list of sub-monitors for this composite.
 
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
getValue
 

Field Detail

baseConfig

protected final MonitorConfig baseConfig
Base configuration shared across all contexts.


context

protected final TaggingContext context
Context to query when accessing a monitor.


newMonitor

protected final com.google.common.base.Function<MonitorConfig,M extends Monitor<T>> newMonitor
Factory funtion used to create a new instance of a monitor.


monitors

protected final java.util.concurrent.ConcurrentMap<MonitorConfig,M extends Monitor<T>> monitors
Thread-safe map keeping track of the distinct monitors that have been created so far.

Constructor Detail

AbstractContextualMonitor

protected AbstractContextualMonitor(MonitorConfig baseConfig,
                                    TaggingContext context,
                                    com.google.common.base.Function<MonitorConfig,M> newMonitor)
Create a new instance of the monitor.

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

getMonitorForCurrentContext

protected M getMonitorForCurrentContext()
Returns a monitor instance for the current context. If no monitor exists for the current context then a new one will be created.


getConfig

public MonitorConfig getConfig()
Configuration used to identify a monitor and provide metadata used in aggregations.

Specified by:
getConfig in interface Monitor<T>

getMonitors

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

Specified by:
getMonitors in interface CompositeMonitor<T>