com.twitter.common.metrics
Class Metrics

java.lang.Object
  extended by com.twitter.common.metrics.Metrics
All Implemented Interfaces:
MetricProvider, MetricRegistry

public class Metrics
extends Object
implements MetricRegistry, MetricProvider

Root metric registry.


Method Summary
static Metrics createDetached()
          Create a new Metrics detached from the static root.
<T extends Number>
void
register(Gauge<T> gauge)
          Registers a new gauge.
 AtomicLong registerLong(String name)
          Creates a gauge and returns an AtomicLong that can be modified to update the value.
static Metrics root()
          Returns a handle to the root metric registry.
 Map<String,Number> sample()
          Obtains a snapshot of all available metric values.
 MetricRegistry scope(String name)
          Returns or creates a sub-scope of this metric registry.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

createDetached

public static Metrics createDetached()
Create a new Metrics detached from the static root.

Returns:
the detached metric registry.

root

public static Metrics root()
Returns a handle to the root metric registry.

Returns:
Root metric registry.

scope

public MetricRegistry scope(String name)
Description copied from interface: MetricRegistry
Returns or creates a sub-scope of this metric registry.

Specified by:
scope in interface MetricRegistry
Parameters:
name - Name for the sub-scope.
Returns:
A possibly-new metric registry, whose metrics will be 'children' of this scope.

register

public <T extends Number> void register(Gauge<T> gauge)
Description copied from interface: MetricRegistry
Registers a new gauge.

Specified by:
register in interface MetricRegistry
Type Parameters:
T - Number type of the gauge's values.
Parameters:
gauge - Gauge to register.

registerLong

public AtomicLong registerLong(String name)
Description copied from interface: MetricRegistry
Creates a gauge and returns an AtomicLong that can be modified to update the value.

Specified by:
registerLong in interface MetricRegistry
Parameters:
name - Name to associate with the gauge.
Returns:
Handle to modify the gauge value.

sample

public Map<String,Number> sample()
Description copied from interface: MetricProvider
Obtains a snapshot of all available metric values.

Specified by:
sample in interface MetricProvider
Returns:
Metric samples.