|
@@ -30,23 +30,11 @@ import com.google.common.collect.Lists;
|
|
|
* @Copyright (c) 2018-? http://qmth.com.cn All Rights Reserved.
|
|
|
*/
|
|
|
public class DataReportor extends ScheduledReporter {
|
|
|
- /**
|
|
|
- * Returns a new {@link Builder} for {@link DataReportor}.
|
|
|
- *
|
|
|
- * @param registry
|
|
|
- * the registry to report
|
|
|
- * @return a {@link Builder} instance for a {@link DataReportor}
|
|
|
- */
|
|
|
+
|
|
|
public static Builder forRegistry(MetricRegistry registry) {
|
|
|
return new Builder(registry);
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * A builder for {@link DataReportor} instances. Defaults to using the
|
|
|
- * default locale and time zone, writing to {@code System.out}, converting
|
|
|
- * rates to events/second, converting durations to milliseconds, and not
|
|
|
- * filtering metrics.
|
|
|
- */
|
|
|
public static class Builder {
|
|
|
private final MetricRegistry registry;
|
|
|
|
|
@@ -75,103 +63,41 @@ public class DataReportor extends ScheduledReporter {
|
|
|
disabledMetricAttributes = Collections.emptySet();
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * Specifies whether or not, the executor (used for reporting) will be
|
|
|
- * stopped with same time with reporter. Default value is true. Setting
|
|
|
- * this parameter to false, has the sense in combining with providing
|
|
|
- * external managed executor via
|
|
|
- * {@link #scheduleOn(ScheduledExecutorService)}.
|
|
|
- *
|
|
|
- * @param shutdownExecutorOnStop
|
|
|
- * if true, then executor will be stopped in same time with
|
|
|
- * this reporter
|
|
|
- * @return {@code this}
|
|
|
- */
|
|
|
public Builder shutdownExecutorOnStop(boolean shutdownExecutorOnStop) {
|
|
|
this.shutdownExecutorOnStop = shutdownExecutorOnStop;
|
|
|
return this;
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * Specifies the executor to use while scheduling reporting of metrics.
|
|
|
- * Default value is null. Null value leads to executor will be auto
|
|
|
- * created on start.
|
|
|
- *
|
|
|
- * @param executor
|
|
|
- * the executor to use while scheduling reporting of metrics.
|
|
|
- * @return {@code this}
|
|
|
- */
|
|
|
public Builder scheduleOn(ScheduledExecutorService executor) {
|
|
|
this.executor = executor;
|
|
|
return this;
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * Use the given {@link Clock} instance for the time.
|
|
|
- *
|
|
|
- * @param clock
|
|
|
- * a {@link Clock} instance
|
|
|
- * @return {@code this}
|
|
|
- */
|
|
|
public Builder withClock(Clock clock) {
|
|
|
this.clock = clock;
|
|
|
return this;
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * Convert rates to the given time unit.
|
|
|
- *
|
|
|
- * @param rateUnit
|
|
|
- * a unit of time
|
|
|
- * @return {@code this}
|
|
|
- */
|
|
|
public Builder convertRatesTo(TimeUnit rateUnit) {
|
|
|
this.rateUnit = rateUnit;
|
|
|
return this;
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * Convert durations to the given time unit.
|
|
|
- *
|
|
|
- * @param durationUnit
|
|
|
- * a unit of time
|
|
|
- * @return {@code this}
|
|
|
- */
|
|
|
public Builder convertDurationsTo(TimeUnit durationUnit) {
|
|
|
this.durationUnit = durationUnit;
|
|
|
return this;
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * Only report metrics which match the given filter.
|
|
|
- *
|
|
|
- * @param filter
|
|
|
- * a {@link MetricFilter}
|
|
|
- * @return {@code this}
|
|
|
- */
|
|
|
public Builder filter(MetricFilter filter) {
|
|
|
this.filter = filter;
|
|
|
return this;
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * Don't report the passed metric attributes for all metrics (e.g.
|
|
|
- * "p999", "stddev" or "m15"). See {@link MetricAttribute}.
|
|
|
- *
|
|
|
- * @param disabledMetricAttributes
|
|
|
- * a {@link MetricFilter}
|
|
|
- * @return {@code this}
|
|
|
- */
|
|
|
public Builder disabledMetricAttributes(Set<MetricAttribute> disabledMetricAttributes) {
|
|
|
this.disabledMetricAttributes = disabledMetricAttributes;
|
|
|
return this;
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * Builds a {@link DataReportor} with the given properties.
|
|
|
- *
|
|
|
- * @return a {@link DataReportor}
|
|
|
- */
|
|
|
public DataReportor build() {
|
|
|
return new DataReportor(registry, clock, rateUnit, durationUnit, filter, executor,
|
|
|
shutdownExecutorOnStop, disabledMetricAttributes);
|