本文整理汇总了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());
}
}
}