public class ListGauge<T> extends java.lang.Object implements Metric
ListGauge
is a Metric
that buffers multiple instances of a type T in a list.
ListGauge
s are useful for maintaining, recording, or collecting values over time.
For example, a set of specific logging-events (e.g., errors).
Eviction is controlled by parameters (maxNumberOfItems and maxStaleness), which are set during instantiation.
Eviction happens during element addition or during reads of the ListGauge (getValues).
All public methods are thread-safe.Constructor and Description |
---|
ListGauge(java.lang.String name)
Create a new
ListGauge that auto evicts upto a max of 100 items and a max-staleness of 60 minutes. |
ListGauge(java.lang.String name,
int maxNumberOfItems,
java.time.Duration maxStaleness)
Create a new
ListGauge that auto evicts based on the given maxNumberOfItems, maxStaleness, and period parameters. |
Modifier and Type | Method and Description |
---|---|
void |
add(T value)
Add a value to the list.
|
java.lang.String |
getName()
Get the name assigned to this
ListGauge |
java.util.Collection<T> |
getValues()
Get the Collection of values currently in the list.
|
void |
visit(MetricsVisitor visitor) |
public ListGauge(java.lang.String name, int maxNumberOfItems, java.time.Duration maxStaleness)
ListGauge
that auto evicts based on the given maxNumberOfItems, maxStaleness, and period parameters.name
- Name to be assignedmaxNumberOfItems
- The max number of items that can remain in the listgaugemaxStaleness
- The max staleness of items permitted in the listgaugepublic ListGauge(java.lang.String name)
ListGauge
that auto evicts upto a max of 100 items and a max-staleness of 60 minutes.name
- Name to be assignedpublic java.lang.String getName()
ListGauge
public java.util.Collection<T> getValues()
public void add(T value)
value
- The Gauge value to be addedpublic void visit(MetricsVisitor visitor)