public class ValueFilterMap extends Object
ValueFilters to be associated with measures reported by
Metrics so that state can be computed based on values at report-generation
time. The addFilter(Metric, String, ValueFilter) method associates a
ValueFilter with a measure and the state methods compute what
state should be reported based on the value of a measure.
For example, ValueFilterMap valueFilterMap = new ValueFilterMap();
valueFilterMap
.addFilter(timer, ValueFilterMap.MAX,
new ValueFilter.Builder("critical").withLower(50).build())
.addFilter(timer, ValueFilterMap.MEAN, new ValueFilter.Builder("warn")
.withUpperExclusive(200).withLower(100).build());
Attaches filters to the mean and max values reported by timers so that
state(timer, "max") will return "critical" if the max value reported
by the timer is greater than or equal to 50 and state(timer, "mean")
will return "warn" if the mean value is between 100 (inclusive) and 200
(exclusive). Filters are applied in the order they are added and the last one
that applies wins. If no filter applies, state methods return "ok".
| Modifier and Type | Field and Description |
|---|---|
static String |
COUNT |
static String |
M1_RATE |
static String |
M15_RATE |
static String |
M5_RATE |
static String |
MAX |
static String |
MEAN |
static String |
MEAN_RATE |
static String |
MIN |
static String |
P50 |
static String |
P75 |
static String |
P95 |
static String |
P98 |
static String |
P99 |
static String |
P999 |
static String |
STDDEV |
| Constructor and Description |
|---|
ValueFilterMap() |
| Modifier and Type | Method and Description |
|---|---|
ValueFilterMap |
addFilter(com.codahale.metrics.Metric metric,
String measure,
ValueFilter filter)
Add a filter associated with the given measure for the given metric.
|
void |
clear()
Clear all mappings for all Metric instances.
|
void |
clear(com.codahale.metrics.Metric metric)
Clear all state mappings associated with the given Metric.
|
List<ValueFilter> |
getFilterList(com.codahale.metrics.Metric metric,
String measure)
Returns the list of filters that have been added to the given metric,
measure pair.
|
String |
state(com.codahale.metrics.Counter counter)
Return the state that should be reported for the given counter, based on
its value.
|
String |
state(com.codahale.metrics.Histogram histogram,
String measure)
Return the state that should be reported for the given measure, histogram
pair.
|
String |
state(com.codahale.metrics.Metered metered,
String measure)
Return the state that should be reported for the given measure, metered
instance pair.
|
String |
state(com.codahale.metrics.Timer timer,
String measure,
TimeUnit durationUnit)
Determines the state that should be reported with the given measure for
the given timer instance.
|
public static final String MAX
public static final String MEAN
public static final String MIN
public static final String STDDEV
public static final String P50
public static final String P75
public static final String P95
public static final String P98
public static final String P99
public static final String P999
public static final String COUNT
public static final String M1_RATE
public static final String M5_RATE
public static final String M15_RATE
public static final String MEAN_RATE
public ValueFilterMap addFilter(com.codahale.metrics.Metric metric, String measure, ValueFilter filter)
metric - metric instance reporting the measure that the filter
applies tomeasure - name of the value reported by the metric that the filter
applies tofilter - ValueFilter instance that, if it applies, may determine the
state reported for the measurepublic List<ValueFilter> getFilterList(com.codahale.metrics.Metric metric, String measure)
metric - metric the measure belongs tomeasure - name of one of the values reported by the metricpublic String state(com.codahale.metrics.Timer timer, String measure, TimeUnit durationUnit)
timer - timer instancemeasure - name of the value reported by the timer whose reported
state is soughtdurationUnit - TimeUnit to convert timer's native (nanosecond)
measurements topublic String state(com.codahale.metrics.Histogram histogram, String measure)
histogram - histogram instancemeasure - name of a measure included in the histogram reportpublic String state(com.codahale.metrics.Metered metered, String measure)
metered - metered instancemeasure - name of a measure included in the metered instance reportpublic String state(com.codahale.metrics.Counter counter)
counter - Counter instancepublic void clear(com.codahale.metrics.Metric metric)
metric - Metric instance to clear mappings forpublic void clear()
Copyright © 2019. All rights reserved.