Make separate metrics for min and max MSPT

This commit is contained in:
RuscalWorld 2021-05-25 00:32:20 +03:00
parent 0961890d47
commit a48d73c30a
No known key found for this signature in database
GPG key ID: 4F53776031D128ED
2 changed files with 8 additions and 4 deletions

View file

@ -7,13 +7,17 @@ import ru.ruscalworld.fabricexporter.FabricExporter;
public class MillisPerTick extends SparkMetric { public class MillisPerTick extends SparkMetric {
public MillisPerTick() { public MillisPerTick() {
super("mspt", "Milliseconds per tick (MSPT)"); super("mspt", "Milliseconds per tick (MSPT)", "type");
} }
@Override @Override
public void update(FabricExporter exporter) { public void update(FabricExporter exporter) {
GenericStatistic<DoubleAverageInfo, StatisticWindow.MillisPerTick> mspt = this.getSpark().mspt(); GenericStatistic<DoubleAverageInfo, StatisticWindow.MillisPerTick> mspt = this.getSpark().mspt();
if (mspt == null) this.getGauge().set(0); if (mspt == null) this.getGauge().set(0);
else this.getGauge().set(mspt.poll(StatisticWindow.MillisPerTick.MINUTES_1).mean()); 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());
}
} }
} }

View file

@ -4,8 +4,8 @@ import me.lucko.spark.api.Spark;
import me.lucko.spark.api.SparkProvider; import me.lucko.spark.api.SparkProvider;
public abstract class SparkMetric extends Metric { public abstract class SparkMetric extends Metric {
public SparkMetric(String name, String help) { public SparkMetric(String name, String help, String... labels) {
super(name, help); super(name, help, labels);
} }
public Spark getSpark() { public Spark getSpark() {