Add bStats metrics.
Introduces the bStats metrics library to the plugin. This first commit contains just a single custom chart, the `store_type`, which will help figure out which stores to focus on for performance optimization and such.
This commit is contained in:
@@ -190,3 +190,14 @@ The operation runs _off_ the main thread, so it should not impact performance.
|
||||
## Getting Help
|
||||
|
||||
If you run into problems or need help with something, feel free to hop on the MobArena Discord server: [Instant Invite](https://discord.gg/5tnwQvC)
|
||||
|
||||
|
||||
## Metrics
|
||||
|
||||
MobArenaStats collects anonymous server metrics through [bStats](https://bstats.org/).
|
||||
The metrics include generic information like Minecraft version, as well as plugin-specific information like plugin version and store type.
|
||||
All collected metrics are publicly available [here](https://bstats.org/plugin/bukkit/MobArenaStats/11932).
|
||||
|
||||
Please note that the stats collected by the plugin itself never leave the server, and they are thus _not_ a part of the metrics collection.
|
||||
|
||||
To opt out of metrics collection, edit the `plugins/bStats/config.yml` file.
|
||||
|
||||
@@ -27,6 +27,13 @@
|
||||
<version>1.7.31</version>
|
||||
</dependency>
|
||||
|
||||
<!-- https://bstats.org/getting-started/include-metrics -->
|
||||
<dependency>
|
||||
<groupId>org.bstats</groupId>
|
||||
<artifactId>bstats-bukkit</artifactId>
|
||||
<version>2.2.1</version>
|
||||
</dependency>
|
||||
|
||||
<!-- https://hub.spigotmc.org/nexus/content/groups/public/org/bukkit/bukkit/ -->
|
||||
<dependency>
|
||||
<groupId>org.bukkit</groupId>
|
||||
@@ -175,6 +182,10 @@
|
||||
<minimizeJar>true</minimizeJar>
|
||||
<createDependencyReducedPom>false</createDependencyReducedPom>
|
||||
<relocations>
|
||||
<relocation>
|
||||
<pattern>org.bstats</pattern>
|
||||
<shadedPattern>org.mobarena.stats.libs.bstats</shadedPattern>
|
||||
</relocation>
|
||||
<relocation>
|
||||
<pattern>org.jdbi</pattern>
|
||||
<shadedPattern>org.mobarena.stats.libs.jdbi</shadedPattern>
|
||||
|
||||
@@ -2,6 +2,7 @@ package org.mobarena.stats;
|
||||
|
||||
import com.garbagemule.MobArena.MobArena;
|
||||
import com.garbagemule.MobArena.commands.CommandHandler;
|
||||
import org.bstats.bukkit.Metrics;
|
||||
import org.bukkit.command.PluginCommand;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.event.HandlerList;
|
||||
@@ -12,6 +13,7 @@ import org.mobarena.stats.command.ExportCommand;
|
||||
import org.mobarena.stats.command.GlobalStatsCommand;
|
||||
import org.mobarena.stats.command.ImportCommand;
|
||||
import org.mobarena.stats.command.PlayerStatsCommand;
|
||||
import org.mobarena.stats.metrics.StoreTypeChart;
|
||||
import org.mobarena.stats.platform.AsyncBukkitExecutor;
|
||||
import org.mobarena.stats.platform.SyncBukkitExecutor;
|
||||
import org.mobarena.stats.session.SessionListener;
|
||||
@@ -79,6 +81,7 @@ public class MobArenaStatsPlugin extends JavaPlugin implements MobArenaStats {
|
||||
createConfigFile();
|
||||
setupExecutors();
|
||||
setupCommands();
|
||||
setupMetrics();
|
||||
} catch (Exception up) {
|
||||
// If setup fails, we can't recover, so throw up
|
||||
throw new RuntimeException(up);
|
||||
@@ -131,6 +134,11 @@ public class MobArenaStatsPlugin extends JavaPlugin implements MobArenaStats {
|
||||
handler.register(ImportCommand.class);
|
||||
}
|
||||
|
||||
private void setupMetrics() {
|
||||
Metrics metrics = new Metrics(this, 11932);
|
||||
metrics.addCustomChart(new StoreTypeChart(this));
|
||||
}
|
||||
|
||||
private void reload() {
|
||||
try {
|
||||
createSessionStore();
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
package org.mobarena.stats.metrics;
|
||||
|
||||
import org.bstats.charts.SimplePie;
|
||||
import org.bukkit.configuration.Configuration;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.mobarena.stats.MobArenaStatsPlugin;
|
||||
import org.mobarena.stats.store.StatsStore;
|
||||
|
||||
public class StoreTypeChart extends SimplePie {
|
||||
|
||||
public StoreTypeChart(MobArenaStatsPlugin plugin) {
|
||||
super("store_type", () -> {
|
||||
StatsStore store = plugin.getStatsStore();
|
||||
if (store == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// If the store isn't null, it means whatever type is set in
|
||||
// the config-file is valid and has already been parsed, so
|
||||
// we can just extract and submit it.
|
||||
Configuration config = plugin.getConfig();
|
||||
ConfigurationSection section = config.getConfigurationSection("store");
|
||||
return section.getString("type");
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user