WANG 6 سال پیش
والد
کامیت
8b13c2d3f9
1فایلهای تغییر یافته به همراه14 افزوده شده و 0 حذف شده
  1. 14 0
      src/main/java/cn/com/qmth/examcloud/web/actuator/DataReportor.java

+ 14 - 0
src/main/java/cn/com/qmth/examcloud/web/actuator/DataReportor.java

@@ -180,6 +180,10 @@ public class DataReportor extends ScheduledReporter {
 
 	private final Clock clock;
 
+	private List<ReportInfo> reportInfoList = Lists.newArrayList();
+
+	private int maxReportInfoSize = 10;
+
 	private DataReportor(MetricRegistry registry, Clock clock, TimeUnit rateUnit,
 			TimeUnit durationUnit, MetricFilter filter, ScheduledExecutorService executor,
 			boolean shutdownExecutorOnStop, Set<MetricAttribute> disabledMetricAttributes) {
@@ -215,6 +219,11 @@ public class DataReportor extends ScheduledReporter {
 			}
 		}
 
+		if (reportInfoList.size() >= maxReportInfoSize) {
+			reportInfoList = reportInfoList.subList(0, maxReportInfoSize);
+		}
+
+		reportInfoList.add(0, info);
 	}
 
 	private MeterInfo getMeterInfo(String key, Meter meter) {
@@ -302,4 +311,9 @@ public class DataReportor extends ScheduledReporter {
 	private boolean isEnabled(MetricAttribute type) {
 		return !getDisabledMetricAttributes().contains(type);
 	}
+
+	public List<ReportInfo> getReportInfoList() {
+		return reportInfoList;
+	}
+
 }