-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #9 from kenshoo/customizable-filter
Resolve Issue #4: customizable filters + switch to builder API
- Loading branch information
Showing
5 changed files
with
114 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
...t-reporter2/src/main/java/com/kenshoo/metrics/anodot/metrics2/Anodot2ReporterBuilder.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package com.kenshoo.metrics.anodot.metrics2; | ||
|
||
import com.google.common.collect.Lists; | ||
import com.kenshoo.metrics.anodot.AnodotGlobalProperties; | ||
import com.kenshoo.metrics.anodot.AnodotReporterConfiguration; | ||
import com.kenshoo.metrics.anodot.AnodotReporterWrapper; | ||
import com.kenshoo.metrics.anodot.EmptyAnodotGlobalProperties; | ||
import com.yammer.metrics.core.AnodotMetricFilter; | ||
import com.yammer.metrics.core.MetricsRegistry; | ||
|
||
import java.util.List; | ||
|
||
/** | ||
* Created by tzachz on 4/21/17 | ||
*/ | ||
public class Anodot2ReporterBuilder { | ||
|
||
private static final Anodot2NonZeroFilter NON_ZERO_FILTER = new Anodot2NonZeroFilter(); | ||
|
||
private final AnodotReporterConfiguration conf; | ||
private final List<AnodotMetricFilter> filters = Lists.<AnodotMetricFilter>newArrayList(NON_ZERO_FILTER); | ||
private AnodotGlobalProperties globalProperties = new EmptyAnodotGlobalProperties(); | ||
|
||
public static Anodot2ReporterBuilder builderFor(AnodotReporterConfiguration conf) { | ||
return new Anodot2ReporterBuilder(conf); | ||
} | ||
|
||
public Anodot2ReporterBuilder withGlobalProperties(AnodotGlobalProperties globalProperties) { | ||
this.globalProperties = globalProperties; | ||
return this; | ||
} | ||
|
||
public Anodot2ReporterBuilder addFilter(AnodotMetricFilter filter) { | ||
this.filters.add(filter); | ||
return this; | ||
} | ||
|
||
public Anodot2ReporterBuilder turnZeroFilterOff() { | ||
this.filters.remove(NON_ZERO_FILTER); | ||
return this; | ||
} | ||
|
||
public AnodotReporterWrapper build(MetricsRegistry metricRegistry) { | ||
return new Anodot2ReporterFactory(conf, globalProperties).anodot2Reporter(metricRegistry); | ||
|
||
} | ||
private Anodot2ReporterBuilder(AnodotReporterConfiguration conf) { | ||
this.conf = conf; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
...t-reporter3/src/main/java/com/kenshoo/metrics/anodot/metrics3/Anodot3ReporterBuilder.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package com.kenshoo.metrics.anodot.metrics3; | ||
|
||
import com.anodot.metrics.AnodotMetricFilter; | ||
import com.codahale.metrics.MetricRegistry; | ||
import com.google.common.collect.Lists; | ||
import com.kenshoo.metrics.anodot.AnodotGlobalProperties; | ||
import com.kenshoo.metrics.anodot.AnodotReporterConfiguration; | ||
import com.kenshoo.metrics.anodot.AnodotReporterWrapper; | ||
import com.kenshoo.metrics.anodot.EmptyAnodotGlobalProperties; | ||
|
||
import java.util.List; | ||
|
||
/** | ||
* Created by tzachz on 4/21/17 | ||
*/ | ||
public class Anodot3ReporterBuilder { | ||
|
||
private static final Anodot3NonZeroFilter NON_ZERO_FILTER = new Anodot3NonZeroFilter(); | ||
|
||
private final AnodotReporterConfiguration conf; | ||
private final List<AnodotMetricFilter> filters = Lists.<AnodotMetricFilter>newArrayList(NON_ZERO_FILTER); | ||
private AnodotGlobalProperties globalProperties = new EmptyAnodotGlobalProperties(); | ||
|
||
public static Anodot3ReporterBuilder builderFor(AnodotReporterConfiguration conf) { | ||
return new Anodot3ReporterBuilder(conf); | ||
} | ||
|
||
public Anodot3ReporterBuilder withGlobalProperties(AnodotGlobalProperties globalProperties) { | ||
this.globalProperties = globalProperties; | ||
return this; | ||
} | ||
|
||
public Anodot3ReporterBuilder addFilter(AnodotMetricFilter filter) { | ||
this.filters.add(filter); | ||
return this; | ||
} | ||
|
||
public Anodot3ReporterBuilder turnZeroFilterOff() { | ||
this.filters.remove(NON_ZERO_FILTER); | ||
return this; | ||
} | ||
|
||
public AnodotReporterWrapper build(MetricRegistry metricRegistry) { | ||
return new Anodot3ReporterFactory(conf, globalProperties).anodot3Reporter(metricRegistry); | ||
|
||
} | ||
private Anodot3ReporterBuilder(AnodotReporterConfiguration conf) { | ||
this.conf = conf; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters