Class ValueFilterMap
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".
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final String -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaddFilter(com.codahale.metrics.Metric metric, String measure, ValueFilter filter) Add a filter associated with the given measure for the given metric.voidclear()Clear all mappings for all Metric instances.voidclear(com.codahale.metrics.Metric metric) Clear all state mappings associated with the given Metric.getFilterList(com.codahale.metrics.Metric metric, String measure) Returns the list of filters that have been added to the given metric, measure pair.state(com.codahale.metrics.Counter counter) Return the state that should be reported for the given counter, based on its value.Return the state that should be reported for the given measure, histogram pair.Return the state that should be reported for the given measure, metered instance pair.Determines the state that should be reported with the given measure for the given timer instance.
-
Field Details
-
MAX
- See Also:
-
MEAN
- See Also:
-
MIN
- See Also:
-
STDDEV
- See Also:
-
P50
- See Also:
-
P75
- See Also:
-
P95
- See Also:
-
P98
- See Also:
-
P99
- See Also:
-
P999
- See Also:
-
COUNT
- See Also:
-
M1_RATE
- See Also:
-
M5_RATE
- See Also:
-
M15_RATE
- See Also:
-
MEAN_RATE
- See Also:
-
-
Constructor Details
-
ValueFilterMap
public ValueFilterMap()
-
-
Method Details
-
addFilter
public ValueFilterMap addFilter(com.codahale.metrics.Metric metric, String measure, ValueFilter filter) Add a filter associated with the given measure for the given metric.- Parameters:
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 measure- Returns:
- a reference to *this (for fluent activation)
-
getFilterList
Returns the list of filters that have been added to the given metric, measure pair.- Parameters:
metric- metric the measure belongs tomeasure- name of one of the values reported by the metric- Returns:
- list of filters that should be applied when determining the state reported with the given measure
-
state
Determines the state that should be reported with the given measure for the given timer instance.- Parameters:
timer- timer instancemeasure- name of the value reported by the timer whose reported state is soughtdurationUnit- TimeUnit to convert timer's native (nanosecond) measurements to- Returns:
- state corresponding to the given measure
-
state
Return the state that should be reported for the given measure, histogram pair.- Parameters:
histogram- histogram instancemeasure- name of a measure included in the histogram report- Returns:
- the state associated to the current value of the measure in the histogram, or "ok" if there is no state mapped to this measure, histogram pair.
-
state
Return the state that should be reported for the given measure, metered instance pair.- Parameters:
metered- metered instancemeasure- name of a measure included in the metered instance report- Returns:
- the state associated to the current value of the measure in the metered instance, or "ok" if there is no state mapped to this measure, metered instance pair.
-
state
Return the state that should be reported for the given counter, based on its value.- Parameters:
counter- Counter instance- Returns:
- the state associated to the current value of the counter in the or "ok" if there is no state mapped to this Counter value.
-
clear
public void clear(com.codahale.metrics.Metric metric) Clear all state mappings associated with the given Metric.- Parameters:
metric- Metric instance to clear mappings for
-
clear
public void clear()Clear all mappings for all Metric instances.
-