本文整理匯總了Java中com.codahale.metrics.MetricFilter.matches方法的典型用法代碼示例。如果您正苦於以下問題:Java MetricFilter.matches方法的具體用法?Java MetricFilter.matches怎麽用?Java MetricFilter.matches使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.codahale.metrics.MetricFilter
的用法示例。
在下文中一共展示了MetricFilter.matches方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getFilter
import com.codahale.metrics.MetricFilter; //導入方法依賴的package包/類
/**
* Gets a {@link MetricFilter} that specifically includes and excludes configured metrics. This method needs the
* existing {@link MetricFilter} used to filter the disabled metrics. The includes and excludes will be checked
* only for enabled metrics.
*
* @param enabledFilter The existing {@link MetricFilter} to filter disabled metrics.
* @return the filter for selecting metrics based on the configured excludes/includes.
* @throws ReporterBuildException if the pattern compilation failed for regular expressions.
*/
protected MetricFilter getFilter(MetricFilter enabledFilter) throws ReporterBuildException {
if (includes.isEmpty() && excludes.isEmpty()) {
return enabledFilter;
}
final StringMatchingStrategy stringMatchingStrategy;
if (useRegexFilters) {
stringMatchingStrategy = regexStringMatchingStrategy;
compileAllRegex(getIncludes());
compileAllRegex(getExcludes());
} else {
stringMatchingStrategy = defaultStringMatchingStrategy;
}
return (name, metric) -> {
// Include the metric if its name is not excluded and its name is included
// Where, by default, with no includes setting, all names are included.
return enabledFilter.matches(name, metric) && !stringMatchingStrategy.containsMatch(getExcludes(), name) &&
(getIncludes().isEmpty() || stringMatchingStrategy.containsMatch(getIncludes(), name));
};
}
示例2: removeMatching
import com.codahale.metrics.MetricFilter; //導入方法依賴的package包/類
/**
* Removes all metrics which match the given filter.
*
* @param filter a filter
*/
public final void removeMatching(final MetricFilter filter) {
for(Map.Entry<String, Metric> entry : metrics.entrySet()) {
if(filter.matches(entry.getKey(), entry.getValue())) {
remove(entry.getKey());
}
}
}
示例3: getMetrics
import com.codahale.metrics.MetricFilter; //導入方法依賴的package包/類
@SuppressWarnings("unchecked")
private <T extends Metric> SortedMap<String, T> getMetrics(
final Class<T> klass, final MetricFilter filter
) {
final TreeMap<String, T> timers = new TreeMap<String, T>();
for(final Map.Entry<String, Metric> entry : metrics.entrySet()) {
if(klass.isInstance(entry.getValue()) && filter.matches(entry.getKey(),
entry.getValue())) {
timers.put(entry.getKey(), (T) entry.getValue());
}
}
return Collections.unmodifiableSortedMap(timers);
}
示例4: matches
import com.codahale.metrics.MetricFilter; //導入方法依賴的package包/類
private Predicate<Map.Entry<String, Gauge>> matches(final MetricFilter filter) {
return new Predicate<Map.Entry<String, Gauge>>() {
@Override
public boolean apply(final Map.Entry<String, Gauge> entry) {
return filter.matches(entry.getKey(), entry.getValue());
}
};
}
示例5: removeMatching
import com.codahale.metrics.MetricFilter; //導入方法依賴的package包/類
@Override
public void removeMatching(MetricFilter filter) {
for (Map.Entry<String, Metric> entry : this.contextAwareMetrics.entrySet()) {
if (filter.matches(entry.getKey(), entry.getValue())) {
remove(entry.getKey());
}
}
}