Package org.apache.hadoop.metrics2.lib
Class MetricsRegistry
java.lang.Object
org.apache.hadoop.metrics2.lib.MetricsRegistry
An optional metrics registry class for creating and maintaining a
collection of MetricsMutables, making writing metrics source easier.
-
Constructor Summary
ConstructorsConstructorDescriptionMetricsRegistry(String name) Construct the registry with a record nameMetricsRegistry(MetricsInfo info) Construct the registry with a metadata object -
Method Summary
Modifier and TypeMethodDescriptionvoidAdd sample to a stat metric by name.Get a metric by nameGet a tag by nameinfo()newCounter(String name, String desc, int iVal) Create a mutable integer counternewCounter(String name, String desc, long iVal) Create a mutable long integer counternewCounter(MetricsInfo info, int iVal) Create a mutable integer counternewCounter(MetricsInfo info, long iVal) Create a mutable long integer counterorg.apache.hadoop.metrics2.lib.MutableGaugeFloatCreate a mutable float gaugeCreate a mutable integer gaugeCreate a mutable long integer gaugeorg.apache.hadoop.metrics2.lib.MutableGaugeFloatnewGauge(MetricsInfo info, float iVal) Create a mutable float gaugenewGauge(MetricsInfo info, int iVal) Create a mutable integer gaugenewGauge(MetricsInfo info, long iVal) Create a mutable long integer gaugenewInverseQuantiles(String name, String desc, String sampleName, String valueName, int interval) Create a mutable inverse metric that estimates inverse quantiles of a stream of valuesnewMutableRollingAverages(String name, String valueName) newQuantiles(String name, String desc, String sampleName, String valueName, int interval) Create a mutable metric that estimates quantiles of a stream of valuesCreate a mutable rate metricCreate a mutable rate metricCreate a mutable rate metric (for throughput measurement).Create a mutable metric with statsCreate a mutable metric with statssetContext(String name) Set the metrics context tagvoidsnapshot(MetricsRecordBuilder builder, boolean all) Sample all the mutable metrics and put the snapshot in the builderAdd a tag to the metricsAdd a tag to the metricstag(MetricsInfo info, String value) tag(MetricsInfo info, String value, boolean override) Add a tag to the metricstoString()
-
Constructor Details
-
MetricsRegistry
Construct the registry with a record name- Parameters:
name- of the record of the metrics
-
MetricsRegistry
Construct the registry with a metadata object- Parameters:
info- the info object for the metrics record/group
-
-
Method Details
-
info
- Returns:
- the info object of the metrics registry
-
get
Get a metric by name- Parameters:
name- of the metric- Returns:
- the metric object
-
getTag
Get a tag by name- Parameters:
name- of the tag- Returns:
- the tag object
-
newCounter
Create a mutable integer counter- Parameters:
name- of the metricdesc- metric descriptioniVal- initial value- Returns:
- a new counter object
-
newCounter
Create a mutable integer counter- Parameters:
info- metadata of the metriciVal- initial value- Returns:
- a new counter object
-
newCounter
Create a mutable long integer counter- Parameters:
name- of the metricdesc- metric descriptioniVal- initial value- Returns:
- a new counter object
-
newCounter
Create a mutable long integer counter- Parameters:
info- metadata of the metriciVal- initial value- Returns:
- a new counter object
-
newGauge
Create a mutable integer gauge- Parameters:
name- of the metricdesc- metric descriptioniVal- initial value- Returns:
- a new gauge object
-
newGauge
Create a mutable integer gauge- Parameters:
info- metadata of the metriciVal- initial value- Returns:
- a new gauge object
-
newGauge
Create a mutable long integer gauge- Parameters:
name- of the metricdesc- metric descriptioniVal- initial value- Returns:
- a new gauge object
-
newGauge
Create a mutable long integer gauge- Parameters:
info- metadata of the metriciVal- initial value- Returns:
- a new gauge object
-
newGauge
public org.apache.hadoop.metrics2.lib.MutableGaugeFloat newGauge(String name, String desc, float iVal) Create a mutable float gauge- Parameters:
name- of the metricdesc- metric descriptioniVal- initial value- Returns:
- a new gauge object
-
newGauge
Create a mutable float gauge- Parameters:
info- metadata of the metriciVal- initial value- Returns:
- a new gauge object
-
newQuantiles
public MutableQuantiles newQuantiles(String name, String desc, String sampleName, String valueName, int interval) Create a mutable metric that estimates quantiles of a stream of values- Parameters:
name- of the metricdesc- metric descriptionsampleName- of the metric (e.g., "Ops")valueName- of the metric (e.g., "Time" or "Latency")interval- rollover interval of estimator in seconds- Returns:
- a new quantile estimator object
- Throws:
MetricsException- if interval is not a positive integer
-
newInverseQuantiles
public MutableQuantiles newInverseQuantiles(String name, String desc, String sampleName, String valueName, int interval) Create a mutable inverse metric that estimates inverse quantiles of a stream of values- Parameters:
name- of the metricdesc- metric descriptionsampleName- of the metric (e.g., "Ops")valueName- of the metric (e.g., "Rate")interval- rollover interval of estimator in seconds- Returns:
- a new inverse quantile estimator object
- Throws:
MetricsException- if interval is not a positive integer
-
newStat
public MutableStat newStat(String name, String desc, String sampleName, String valueName, boolean extended) Create a mutable metric with stats- Parameters:
name- of the metricdesc- metric descriptionsampleName- of the metric (e.g., "Ops")valueName- of the metric (e.g., "Time" or "Latency")extended- produce extended stat (stdev, min/max etc.) if true.- Returns:
- a new mutable stat metric object
-
newStat
Create a mutable metric with stats- Parameters:
name- of the metricdesc- metric descriptionsampleName- of the metric (e.g., "Ops")valueName- of the metric (e.g., "Time" or "Latency")- Returns:
- a new mutable metric object
-
newRate
Create a mutable rate metric- Parameters:
name- of the metric- Returns:
- a new mutable metric object
-
newRate
Create a mutable rate metric- Parameters:
name- of the metricdescription- of the metric- Returns:
- a new mutable rate metric object
-
newRate
Create a mutable rate metric (for throughput measurement).- Parameters:
name- of the metricdesc- descriptionextended- produce extended stat (stdev/min/max etc.) if true- Returns:
- a new mutable rate metric object
-
newRate
@Private public MutableRate newRate(String name, String desc, boolean extended, boolean returnExisting) -
newRatesWithAggregation
-
newMutableRollingAverages
-
add
Add sample to a stat metric by name.- Parameters:
name- of the metricvalue- of the snapshot to add
-
setContext
Set the metrics context tag- Parameters:
name- of the context- Returns:
- the registry itself as a convenience
-
tag
Add a tag to the metrics- Parameters:
name- of the tagdescription- of the tagvalue- of the tag- Returns:
- the registry (for keep adding tags)
-
tag
Add a tag to the metrics- Parameters:
name- of the tagdescription- of the tagvalue- of the tagoverride- existing tag if true- Returns:
- the registry (for keep adding tags)
-
tag
Add a tag to the metrics- Parameters:
info- metadata of the tagvalue- of the tagoverride- existing tag if true- Returns:
- the registry (for keep adding tags etc.)
-
tag
-
snapshot
Sample all the mutable metrics and put the snapshot in the builder- Parameters:
builder- to contain the metrics snapshotall- get all the metrics even if the values are not changed.
-
toString
-