com.twitter.common.metrics
Class Ratio

java.lang.Object
  extended by com.twitter.common.metrics.AbstractGauge<Double>
      extended by com.twitter.common.metrics.Ratio
All Implemented Interfaces:
Gauge<Double>

public class Ratio
extends AbstractGauge<Double>

Function to compute the ratio of two metrics.


Method Summary
static
<N extends Number,D extends Number>
Ratio
of(Gauge<N> numerator, Gauge<D> denominator)
          Identical to of(String, Gauge, Gauge), but using a fixed naming format.
static
<N extends Number,D extends Number>
Ratio
of(String name, Gauge<N> numerator, Gauge<D> denominator)
          Creates a ratio of two gauges, registering the result with a custom metric name.
static Ratio of(String name, Number numerator, Number denominator)
          Creates a ratio of two numbers.
 Double read()
          Reads the latest value of the metric.
 
Methods inherited from class com.twitter.common.metrics.AbstractGauge
getName
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

of

public static <N extends Number,D extends Number> Ratio of(String name,
                                                           Gauge<N> numerator,
                                                           Gauge<D> denominator)
Creates a ratio of two gauges, registering the result with a custom metric name.

Type Parameters:
N - Numerator gauge type.
D - Denominator gauge type.
Parameters:
name - Name to associate with the ratio.
numerator - Numerator gauge.
denominator - Denominator gauge.
Returns:
A ratio that computes numerator / denominator.

of

public static <N extends Number,D extends Number> Ratio of(Gauge<N> numerator,
                                                           Gauge<D> denominator)
Identical to of(String, Gauge, Gauge), but using a fixed naming format.

Type Parameters:
N - Numerator gauge type.
D - Denominator gauge type.
Parameters:
numerator - Numerator guage.
denominator - Denominator gauge.
Returns:
A ratio that computes numerator / denominator.

of

public static Ratio of(String name,
                       Number numerator,
                       Number denominator)
Creates a ratio of two numbers.

Parameters:
name - Name to associate with the ratio.
numerator - Numerator number.
denominator - Denominator numbers.
Returns:
A ratio that computes numerator / denominator.

read

public Double read()
Description copied from interface: Gauge
Reads the latest value of the metric. Must never return null.

Returns:
The metric value.