Skip to content

Commit

Permalink
Document all MetricFilter mutation methods
Browse files Browse the repository at this point in the history
  • Loading branch information
wavejumper committed Dec 18, 2024
1 parent 27b2151 commit b6f6b02
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions src/java/io/factorhouse/kpow/MetricFilter.java
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,11 @@ public List<FilterCriteria> getFilters() {
return Collections.unmodifiableList(filters);
}

/**
* Accepts all metrics.
*
* @return an updated MetricFilter
*/
public MetricFilter accept() {
Predicate<MetricName> acceptPredicate = (_filter) -> {
return true;
Expand All @@ -146,12 +151,22 @@ public MetricFilter accept() {
return this;
}

/**
* Accepts a metric based on the specified Predicate.
*
* @return an updated MetricFilter
*/
public MetricFilter accept(Predicate<MetricName> acceptFilter) {
FilterCriteria criteria = new FilterCriteria(acceptFilter, FilterType.ACCEPT);
this.filters.add(criteria);
return this;
}

/**
* Denies all metrics.
*
* @return an updated MetricFilter
*/
public MetricFilter deny() {
Predicate<MetricName> denyFilter = (_filter) -> {
return true;
Expand All @@ -161,12 +176,22 @@ public MetricFilter deny() {
return this;
}

/**
* Denies a metric based on the specified Predicate.
*
* @return an updated MetricFilter
*/
public MetricFilter deny(Predicate<MetricName> denyFilter) {
FilterCriteria criteria = new FilterCriteria(denyFilter, FilterType.DENY);
this.filters.add(criteria);
return this;
}

/**
* Accepts all metrics whose name start with the specified prefix.
*
* @return an updated MetricFilter
*/
public MetricFilter acceptNameStartsWith(String prefix) {
Predicate<MetricName> acceptFilter = (metricName) -> {
return metricName.name().startsWith(prefix);
Expand All @@ -176,6 +201,11 @@ public MetricFilter acceptNameStartsWith(String prefix) {
return this;
}

/**
* Denies all metrics whose name start with the specified prefix.
*
* @return an updated MetricFilter
*/
public MetricFilter denyNameStartsWith(String prefix) {
Predicate<MetricName> denyFilter = (metricName) -> {
return metricName.name().startsWith(prefix);
Expand Down

0 comments on commit b6f6b02

Please sign in to comment.