-
Notifications
You must be signed in to change notification settings - Fork 8
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 #36 from Peppi-Ressler/statsd-builder
added statsd builder
- Loading branch information
Showing
2 changed files
with
67 additions
and
2 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
49 changes: 49 additions & 0 deletions
49
statsd/src/main/java/com/avast/metrics/statsd/StatsDMetricsMonitorBuilder.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,49 @@ | ||
package com.avast.metrics.statsd; | ||
|
||
import com.avast.metrics.api.Naming; | ||
import com.avast.metrics.filter.MetricsFilter; | ||
|
||
import java.time.Duration; | ||
import java.util.concurrent.ScheduledExecutorService; | ||
|
||
public class StatsDMetricsMonitorBuilder { | ||
private final String host; | ||
private final int port; | ||
private final String prefix; | ||
private final ScheduledExecutorService scheduler; | ||
private boolean autoRegisterMetrics = false; | ||
private Naming naming = Naming.defaultNaming(); | ||
private Duration gaugeSendPeriod = Duration.ofSeconds(1); | ||
private MetricsFilter metricsFilter = MetricsFilter.ALL_ENABLED; | ||
|
||
public StatsDMetricsMonitorBuilder(String host, int port, String prefix, final ScheduledExecutorService scheduler) { | ||
this.host = host; | ||
this.port = port; | ||
this.prefix = prefix; | ||
this.scheduler = scheduler; | ||
} | ||
|
||
public StatsDMetricsMonitorBuilder withAutoRegisterMetrics(boolean autoRegisterMetrics) { | ||
this.autoRegisterMetrics = autoRegisterMetrics; | ||
return this; | ||
} | ||
|
||
public StatsDMetricsMonitorBuilder withNaming(Naming naming) { | ||
this.naming = naming; | ||
return this; | ||
} | ||
|
||
public StatsDMetricsMonitorBuilder withGaugeSendPeriod(Duration gaugeSendPeriod) { | ||
this.gaugeSendPeriod = gaugeSendPeriod; | ||
return this; | ||
} | ||
|
||
public StatsDMetricsMonitorBuilder withMetricsFilter(MetricsFilter metricsFilter) { | ||
this.metricsFilter = metricsFilter; | ||
return this; | ||
} | ||
|
||
public StatsDMetricsMonitor build() { | ||
return new StatsDMetricsMonitor(host, port, autoRegisterMetrics, prefix, naming, gaugeSendPeriod, scheduler, metricsFilter); | ||
} | ||
} |