Fix changing MSPT gauge value without label (#1)

This commit is contained in:
RuscalWorld 2021-09-07 22:21:56 +03:00
parent 5c688104ea
commit 3cee0a1ba3
No known key found for this signature in database
GPG key ID: 6FF416979DF2B416

View file

@ -13,11 +13,17 @@ public class MillisPerTick extends SparkMetric {
@Override
public void update(FabricExporter exporter) {
GenericStatistic<DoubleAverageInfo, StatisticWindow.MillisPerTick> mspt = this.getSpark().mspt();
if (mspt == null) this.getGauge().set(0);
else {
this.getGauge().labels("min").set(mspt.poll(StatisticWindow.MillisPerTick.MINUTES_1).min());
this.getGauge().labels("mean").set(mspt.poll(StatisticWindow.MillisPerTick.MINUTES_1).mean());
this.getGauge().labels("max").set(mspt.poll(StatisticWindow.MillisPerTick.MINUTES_1).max());
if (mspt == null) this.setValue(0, 0, 0);
else this.setValue(
mspt.poll(StatisticWindow.MillisPerTick.MINUTES_1).min(),
mspt.poll(StatisticWindow.MillisPerTick.MINUTES_1).mean(),
mspt.poll(StatisticWindow.MillisPerTick.MINUTES_1).max()
);
}
private void setValue(double min, double mean, double max) {
this.getGauge().labels("min").set(min);
this.getGauge().labels("mean").set(mean);
this.getGauge().labels("max").set(max);
}
}