Add Hotspot metrics
This commit is contained in:
parent
0045d53a51
commit
810e225915
4 changed files with 24 additions and 2 deletions
|
@ -36,6 +36,7 @@ dependencies {
|
|||
// You may need to force-disable transitiveness on them.
|
||||
implementation "io.prometheus:simpleclient:${project.prometheus_version}"
|
||||
implementation "io.prometheus:simpleclient_httpserver:${project.prometheus_version}"
|
||||
implementation "io.prometheus:simpleclient_hotspot:${project.prometheus_version}"
|
||||
|
||||
compileOnly "me.lucko:spark-api:0.1-SNAPSHOT"
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package ru.ruscalworld.fabricexporter;
|
||||
|
||||
import io.prometheus.client.exporter.HTTPServer;
|
||||
import io.prometheus.client.hotspot.DefaultExports;
|
||||
import net.fabricmc.api.ModInitializer;
|
||||
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerLifecycleEvents;
|
||||
import net.fabricmc.loader.api.FabricLoader;
|
||||
|
@ -44,6 +45,10 @@ public class FabricExporter implements ModInitializer {
|
|||
metricRegistry.registerDefault();
|
||||
this.setMetricRegistry(metricRegistry);
|
||||
|
||||
if (config.shouldExportJvmDefaults()) {
|
||||
DefaultExports.initialize();
|
||||
}
|
||||
|
||||
ServerLifecycleEvents.SERVER_STARTING.register(this::setServer);
|
||||
ServerLifecycleEvents.SERVER_STARTED.register(server -> {
|
||||
try {
|
||||
|
|
|
@ -8,6 +8,7 @@ public class MainConfig extends Config {
|
|||
private int port;
|
||||
private int updateInterval;
|
||||
private boolean useSpark;
|
||||
private boolean exportJvmDefaults;
|
||||
|
||||
public MainConfig(String name) {
|
||||
super(name);
|
||||
|
@ -24,6 +25,8 @@ public class MainConfig extends Config {
|
|||
this.setUpdateInterval(ConvertUtil.intToStringOrDefault(updateIntervalString, 1000));
|
||||
|
||||
this.setShouldUseSpark(properties.getProperty("use-spark", "true").equalsIgnoreCase("true"));
|
||||
|
||||
this.setShouldExportJvmDefaults(properties.getProperty("export-default-jvm-metrics", "true").equalsIgnoreCase("true"));
|
||||
}
|
||||
|
||||
public int getPort() {
|
||||
|
@ -49,4 +52,12 @@ public class MainConfig extends Config {
|
|||
public void setShouldUseSpark(boolean useSpark) {
|
||||
this.useSpark = useSpark;
|
||||
}
|
||||
|
||||
public boolean shouldExportJvmDefaults() {
|
||||
return exportJvmDefaults;
|
||||
}
|
||||
|
||||
public void setShouldExportJvmDefaults(boolean exportJvmDefaults) {
|
||||
this.exportJvmDefaults = exportJvmDefaults;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# On which port webserver should be started?
|
||||
# On which port Prometheus webserver should be started?
|
||||
# Default: 25585
|
||||
server-port=25585
|
||||
|
||||
|
@ -14,6 +14,11 @@ update-interval=1000
|
|||
# Default: true
|
||||
use-spark=true
|
||||
|
||||
# Should FabricExporter register default Hotspot exports?
|
||||
# This enables advanced metrics for JVM
|
||||
# Default: true
|
||||
export-default-jvm-metrics=true
|
||||
|
||||
# You can disable any metric that registered via MetricRegistry (all metrics by default) using the settings below
|
||||
# Names of properties consist of "enable" and metric name without prefix and "_" replaced with "-"
|
||||
# For example, if you want to disable "minecraft_players_online", you should set "enable-players-online" to "false"
|
||||
|
@ -46,4 +51,4 @@ enable-entities=true
|
|||
|
||||
# Exports count of handshake requests
|
||||
# Collected by FabricExporter
|
||||
enable-handshakes=true
|
||||
enable-handshakes=true
|
||||
|
|
Loading…
Reference in a new issue