/**
* 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));
};
}
ReporterConfig.java 文件源码
java
阅读 22
收藏 0
点赞 0
评论 0
项目:carbon-metrics
作者:
评论列表
文章目录