Skip to content
This repository has been archived by the owner on Sep 10, 2021. It is now read-only.

Commit

Permalink
1.3.0
Browse files Browse the repository at this point in the history
added mean tick time metric via forge gradle, moved to our package
naming
  • Loading branch information
phit committed Oct 25, 2017
1 parent 4d519cd commit b09cbb6
Show file tree
Hide file tree
Showing 6 changed files with 63 additions and 32 deletions.
57 changes: 38 additions & 19 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,3 +1,22 @@
buildscript {
repositories {
jcenter()
mavenCentral()
maven {
name = 'sponge'
url = 'http://repo.spongepowered.org/maven'
}
maven {
name = 'forge'
url = 'http://files.minecraftforge.net/maven'
}
}

dependencies {
classpath 'net.minecraftforge.gradle:ForgeGradle:2.3-SNAPSHOT'
}
}

plugins {
id 'java'
id 'idea'
Expand All @@ -7,31 +26,28 @@ plugins {
id 'org.spongepowered.plugin' version '0.8.1'
}

group = 'de.sldk.mc.prometheusexporter'
version = '1.2.0'
apply plugin: 'net.minecraftforge.gradle.forge'

minecraft {
mappings = 'snapshot_20171007'
makeObfSourceJar = false
runDir = "run"
version = '14.23.0.2503'
}

group = 'org.stonebound.prometheusexporter'
version = '1.3.0'
description = "Sponge Minecraft Prometheus Exporter"
ext.url = 'https://github.com/Stonebound/minecraft-prometheus-exporter'

compileJava {
sourceCompatibility = '1.8'
targetCompatibility = '1.8'
}

repositories {
jcenter()
mavenCentral()
maven {
name = 'sponge'
url = 'http://repo.spongepowered.org/maven'
}
}

configurations {

}
defaultTasks 'build', 'shadowJar'

dependencies {
compile 'org.spongepowered:spongeapi:6.0.0'
compile 'org.spongepowered:spongeapi:7.0.0-SNAPSHOT'
compile 'io.prometheus:simpleclient_common:0.0.26'
compile 'org.eclipse.jetty:jetty-server:9.4.6.v20170531'
compile 'javax.servlet:javax.servlet-api:4.0.0'
Expand All @@ -42,7 +58,6 @@ shadowJar {
relocate 'io.prometheus', 'prometheus.shadow.prometheus'
relocate 'javax.servlet', 'prometheus.shadow.servlet'

configurations = [project.configurations.compile]
dependencies {
include dependency('io.prometheus:simpleclient_common:0.0.26')
include dependency('io.prometheus:simpleclient:0.0.26')
Expand All @@ -60,14 +75,18 @@ shadowJar {
}

blossom {
def location = 'src/main/java/de/sldk/mc/prometheusexporter/PluginInfo.java'
def location = 'src/main/java/org/stonebound/prometheusexporter/PluginInfo.java'

replaceToken '@name@', project.name, location
replaceToken '@version@', project.version, location
replaceToken '@description@', project.description, location
replaceToken '@url@', project.url, location
}

reobf {
shadowJar{}
}

tasks.build.dependsOn reobfShadowJar

signing {
if (project.hasProperty('signing.keyId') && project.hasProperty('signing.password') && project.hasProperty('signing.secretKeyRingFile')) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package de.sldk.mc.prometheusexporter;
package org.stonebound.prometheusexporter;

import org.eclipse.jetty.util.log.Logger;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
package de.sldk.mc.prometheusexporter;
package org.stonebound.prometheusexporter;

import com.google.common.collect.Iterables;
import io.prometheus.client.CollectorRegistry;
import io.prometheus.client.Gauge;
import io.prometheus.client.exporter.common.TextFormat;
import net.minecraft.server.MinecraftServer;
import org.eclipse.jetty.server.Request;
import org.eclipse.jetty.server.handler.AbstractHandler;
import org.spongepowered.api.Sponge;
Expand Down Expand Up @@ -43,8 +44,10 @@ public void handle(String target, Request baseRequest, HttpServletRequest reques
entities.labels(world.getName()).set(world.getEntities().size());
tileEntities.labels(world.getName()).set(world.getTileEntities().size());
}
double meanTickTime = MetricsController.mean(((MinecraftServer) Sponge.getServer()).tickTimeArray) * 1.0E-6D;

tps.labels("tps").set(Sponge.getGame().getServer().getTicksPerSecond());
tps.labels("meanticktime").set(meanTickTime);
memory.labels("max").set(Runtime.getRuntime().maxMemory());
memory.labels("free").set(Runtime.getRuntime().freeMemory());
memory.labels("used").set(Runtime.getRuntime().maxMemory() - Runtime.getRuntime().freeMemory());
Expand All @@ -61,4 +64,15 @@ public void handle(String target, Request baseRequest, HttpServletRequest reques
response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
}
}

private static long mean(long[] values)
{
long sum = 0l;
for (long v : values)
{
sum+=v;
}

return sum / values.length;
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package de.sldk.mc.prometheusexporter;
package org.stonebound.prometheusexporter;

public class PluginInfo {
private PluginInfo() {}
Expand All @@ -7,6 +7,6 @@ private PluginInfo() {}
public static final String NAME = "@name@";
public static final String VERSION = "@version@";
public static final String DESCRIPTION = "@description@";
public static final String URL = "@url@";
public static final String URL = "https://github.com/Stonebound/minecraft-prometheus-exporter";
public static final String AUTHORS = "sladkoff, phit";
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package de.sldk.mc.prometheusexporter;
package org.stonebound.prometheusexporter;

import com.google.inject.Inject;
import ninja.leaping.configurate.ConfigurationNode;
Expand All @@ -15,13 +15,11 @@

import java.io.File;

import static de.sldk.mc.prometheusexporter.PluginInfo.*;

@Plugin(id = ID,
name = NAME,
version = VERSION,
description = DESCRIPTION,
url = URL
@Plugin(id = PluginInfo.ID,
name = PluginInfo.NAME,
version = PluginInfo.VERSION,
description = PluginInfo.DESCRIPTION,
url = PluginInfo.URL
)

public class PrometheusExporter {
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/jetty-logging.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
org.eclipse.jetty.util.log.class=de.sldk.mc.prometheusexporter.JettyNullLogger
org.eclipse.jetty.util.log.class=org.stonebound.prometheusexporter.JettyNullLogger

0 comments on commit b09cbb6

Please sign in to comment.