|
@@ -1,15 +1,11 @@
|
|
|
package cn.com.qmth.examcloud.web.actuator;
|
|
|
|
|
|
-import java.io.PrintStream;
|
|
|
-import java.text.DateFormat;
|
|
|
import java.util.Collections;
|
|
|
import java.util.Date;
|
|
|
import java.util.List;
|
|
|
-import java.util.Locale;
|
|
|
import java.util.Map;
|
|
|
import java.util.Set;
|
|
|
import java.util.SortedMap;
|
|
|
-import java.util.TimeZone;
|
|
|
import java.util.concurrent.ScheduledExecutorService;
|
|
|
import java.util.concurrent.TimeUnit;
|
|
|
|
|
@@ -54,14 +50,8 @@ public class DataReportor extends ScheduledReporter {
|
|
|
public static class Builder {
|
|
|
private final MetricRegistry registry;
|
|
|
|
|
|
- private PrintStream output;
|
|
|
-
|
|
|
- private Locale locale;
|
|
|
-
|
|
|
private Clock clock;
|
|
|
|
|
|
- private TimeZone timeZone;
|
|
|
-
|
|
|
private TimeUnit rateUnit;
|
|
|
|
|
|
private TimeUnit durationUnit;
|
|
@@ -76,10 +66,7 @@ public class DataReportor extends ScheduledReporter {
|
|
|
|
|
|
private Builder(MetricRegistry registry) {
|
|
|
this.registry = registry;
|
|
|
- this.output = System.out;
|
|
|
- this.locale = Locale.getDefault();
|
|
|
this.clock = Clock.defaultClock();
|
|
|
- this.timeZone = TimeZone.getDefault();
|
|
|
this.rateUnit = TimeUnit.SECONDS;
|
|
|
this.durationUnit = TimeUnit.MILLISECONDS;
|
|
|
this.filter = MetricFilter.ALL;
|
|
@@ -119,30 +106,6 @@ public class DataReportor extends ScheduledReporter {
|
|
|
return this;
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * Write to the given {@link PrintStream}.
|
|
|
- *
|
|
|
- * @param output
|
|
|
- * a {@link PrintStream} instance.
|
|
|
- * @return {@code this}
|
|
|
- */
|
|
|
- public Builder outputTo(PrintStream output) {
|
|
|
- this.output = output;
|
|
|
- return this;
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * Format numbers for the given {@link Locale}.
|
|
|
- *
|
|
|
- * @param locale
|
|
|
- * a {@link Locale}
|
|
|
- * @return {@code this}
|
|
|
- */
|
|
|
- public Builder formattedFor(Locale locale) {
|
|
|
- this.locale = locale;
|
|
|
- return this;
|
|
|
- }
|
|
|
-
|
|
|
/**
|
|
|
* Use the given {@link Clock} instance for the time.
|
|
|
*
|
|
@@ -155,18 +118,6 @@ public class DataReportor extends ScheduledReporter {
|
|
|
return this;
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * Use the given {@link TimeZone} for the time.
|
|
|
- *
|
|
|
- * @param timeZone
|
|
|
- * a {@link TimeZone}
|
|
|
- * @return {@code this}
|
|
|
- */
|
|
|
- public Builder formattedFor(TimeZone timeZone) {
|
|
|
- this.timeZone = timeZone;
|
|
|
- return this;
|
|
|
- }
|
|
|
-
|
|
|
/**
|
|
|
* Convert rates to the given time unit.
|
|
|
*
|
|
@@ -222,26 +173,19 @@ public class DataReportor extends ScheduledReporter {
|
|
|
* @return a {@link DataReportor}
|
|
|
*/
|
|
|
public DataReportor build() {
|
|
|
- return new DataReportor(registry, output, locale, clock, timeZone, rateUnit,
|
|
|
- durationUnit, filter, executor, shutdownExecutorOnStop,
|
|
|
- disabledMetricAttributes);
|
|
|
+ return new DataReportor(registry, clock, rateUnit, durationUnit, filter, executor,
|
|
|
+ shutdownExecutorOnStop, disabledMetricAttributes);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
private final Clock clock;
|
|
|
|
|
|
- private final DateFormat dateFormat;
|
|
|
-
|
|
|
- private DataReportor(MetricRegistry registry, PrintStream output, Locale locale, Clock clock,
|
|
|
- TimeZone timeZone, TimeUnit rateUnit, TimeUnit durationUnit, MetricFilter filter,
|
|
|
- ScheduledExecutorService executor, boolean shutdownExecutorOnStop,
|
|
|
- Set<MetricAttribute> disabledMetricAttributes) {
|
|
|
- super(registry, "console-reporter", filter, rateUnit, durationUnit, executor,
|
|
|
+ private DataReportor(MetricRegistry registry, Clock clock, TimeUnit rateUnit,
|
|
|
+ TimeUnit durationUnit, MetricFilter filter, ScheduledExecutorService executor,
|
|
|
+ boolean shutdownExecutorOnStop, Set<MetricAttribute> disabledMetricAttributes) {
|
|
|
+ super(registry, "data-reporter", filter, rateUnit, durationUnit, executor,
|
|
|
shutdownExecutorOnStop, disabledMetricAttributes);
|
|
|
this.clock = clock;
|
|
|
- this.dateFormat = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.MEDIUM,
|
|
|
- locale);
|
|
|
- dateFormat.setTimeZone(timeZone);
|
|
|
}
|
|
|
|
|
|
@Override
|