public class MetricRegistry extends Object
| Modifier and Type | Field and Description |
|---|---|
protected boolean |
enabled
Metrics enabled status.
|
protected ConcurrentHashMap<String,ConcurrentHashMap<String,Object>> |
values
The values in the metric registry have a type and a key and are of type
LongAdder or Gauge.
|
| Constructor and Description |
|---|
MetricRegistry()
Instantiates a new metric registry.
|
MetricRegistry(boolean enabled)
Instantiates a new metric registry.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
add(String type,
String key,
long value)
Adds a value to a metric for a given type and key.
|
boolean |
decrement(String type,
String key)
Decrement a metric for a given type and key.
|
long |
get(String type,
String key)
Gets the value of a metric for a given type and key.
|
static MetricRegistry |
getInstance()
Gets the single instance of the Storage.
|
Iterable<String> |
getKeys(String type)
Gets the (unique) set of keys of all registered metrics of a given type.
|
long |
getMillis()
Gets the current (wall clock) time in milliseconds (milliseconds elapsed
since epoch).
|
long |
getNanos()
Gets the elapsed time in nanoseconds (from an arbitrary point in time,
probably JVM start).
|
Iterable<String> |
getTypes()
Gets the (unique) set of types of all registered metrics.
|
boolean |
has(String type,
String key)
Checks for existence of a metric for a given type and key.
|
boolean |
hasType(String type)
Checks for existence of a metric for a given type.
|
boolean |
increment(String type,
String key)
Increment a metric for a given type and key.
|
boolean |
isEnabled()
Checks if metrics are enabled.
|
void |
reset()
Resets the metric registry.
|
void |
set(String type,
String key,
Gauge value)
Sets the Gauge (measure function) of a metric for a given type and key.
|
void |
set(String type,
String key,
long value)
Sets the value of a metric for a given type and key.
|
void |
setEnabled(boolean enabled)
Sets the metrics enabled status.
|
protected volatile ConcurrentHashMap<String,ConcurrentHashMap<String,Object>> values
protected boolean enabled
public MetricRegistry()
public MetricRegistry(boolean enabled)
public void reset()
public boolean isEnabled()
public void setEnabled(boolean enabled)
enabled - the new metrics enabled statuspublic boolean increment(String type, String key)
type - the typekey - the keypublic boolean decrement(String type, String key)
type - the typekey - the keypublic boolean add(String type, String key, long value)
type - the typekey - the keyvalue - the valuepublic void set(String type, String key, long value)
type - the typekey - the keyvalue - the valuepublic void set(String type, String key, Gauge value)
type - the typekey - the keyvalue - the valuepublic Iterable<String> getTypes()
public Iterable<String> getKeys(String type)
type - the typepublic boolean has(String type, String key)
type - the typekey - the keypublic boolean hasType(String type)
type - the typepublic long get(String type, String key)
type - the typekey - the keypublic long getNanos()
public long getMillis()
public static MetricRegistry getInstance()
Copyright © 2018. All rights reserved.