From e5037a705fc6114fdf3ca14391a12a13a75a5a8c Mon Sep 17 00:00:00 2001 From: Napster Date: Thu, 24 May 2018 18:30:08 +0200 Subject: [PATCH 1/3] Bump feature and patch level dependencies --- build.gradle | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/build.gradle b/build.gradle index dbec9b358..757c5b330 100644 --- a/build.gradle +++ b/build.gradle @@ -13,7 +13,7 @@ allprojects { subprojects { buildscript { ext { - springBootVersion = '2.0.1.RELEASE' + springBootVersion = '2.0.2.RELEASE' gradleGitVersion = '1.4.21' } repositories { @@ -43,23 +43,23 @@ subprojects { //@formatter:off lavaplayerVersion = '1.2.63' - jdaAudioVersion = '91438c36d7107cf838c2f2eb147b08f989d929db' + jdaAudioVersion = '4d7abb48aec49f0a996ba0d87df34fdc67f71275' jdaNasVersion = '1.0.6.2-JDA-Audio' jappVersion = '1.2' - jdaVersion = '3.6.0_355' + jdaVersion = '3.6.0_367' springBootVersion = "${springBootVersion}" javaWebSocketVersion = '1.3.8' logbackVersion = '1.2.3' slf4jVersion = '1.7.25' sentryLogbackVersion = '1.7.0' - oshiVersion = '3.4.4' + oshiVersion = '3.5.0' jsonOrgVersion = '20180130' spotbugsAnnotationsVersion = '3.1.3' prometheusVersion = '0.4.0' - junitJupiterVersion = '5.1.0' - junitPlatformVersion = '1.1.0' + junitJupiterVersion = '5.2.0' + junitPlatformVersion = '1.2.0' unirestVersion = '1.4.9' //@formatter:on From 2d640ada57ad3d3c4010b62679f321f6ec5c5555 Mon Sep 17 00:00:00 2001 From: "Frederik Ar. Mikkelsen" Date: Sat, 2 Jun 2018 18:21:51 +0200 Subject: [PATCH 2/3] Update lavaplayer --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 757c5b330..a38fd05e4 100644 --- a/build.gradle +++ b/build.gradle @@ -42,7 +42,7 @@ subprojects { ext { //@formatter:off - lavaplayerVersion = '1.2.63' + lavaplayerVersion = '1.2.64' jdaAudioVersion = '4d7abb48aec49f0a996ba0d87df34fdc67f71275' jdaNasVersion = '1.0.6.2-JDA-Audio' jappVersion = '1.2' From a5e04efdd1261113edc10a7905f2fb530ad2cf7c Mon Sep 17 00:00:00 2001 From: Napster Date: Sun, 3 Jun 2018 17:24:57 +0300 Subject: [PATCH 3/3] Add Histogram for GC pauses (#106) * Make lavaplayer gc warnings optional * [Metrics] Add Histogram for GC pauses --- LavalinkServer/application.yml.example | 1 + .../config/AudioPlayerConfiguration.java | 5 ++- .../lavalink/server/config/ServerConfig.java | 22 +++++++---- .../metrics/GcNotificationListener.java | 39 +++++++++++++++++++ .../server/metrics/PrometheusMetrics.java | 12 ++++++ 5 files changed, 70 insertions(+), 9 deletions(-) create mode 100644 LavalinkServer/src/main/java/lavalink/server/metrics/GcNotificationListener.java diff --git a/LavalinkServer/application.yml.example b/LavalinkServer/application.yml.example index e30e1144b..fb119f26b 100644 --- a/LavalinkServer/application.yml.example +++ b/LavalinkServer/application.yml.example @@ -19,6 +19,7 @@ lavalink: sentryDsn: "" bufferDurationMs: 400 youtubePlaylistLoadLimit: 600 + gc-warnings: true metrics: prometheus: diff --git a/LavalinkServer/src/main/java/lavalink/server/config/AudioPlayerConfiguration.java b/LavalinkServer/src/main/java/lavalink/server/config/AudioPlayerConfiguration.java index 78dacb5dd..2b74f028a 100644 --- a/LavalinkServer/src/main/java/lavalink/server/config/AudioPlayerConfiguration.java +++ b/LavalinkServer/src/main/java/lavalink/server/config/AudioPlayerConfiguration.java @@ -23,7 +23,10 @@ public class AudioPlayerConfiguration { public AudioPlayerManager audioPlayerManager(AudioSourcesConfig sources, ServerConfig serverConfig) { AudioPlayerManager audioPlayerManager = new DefaultAudioPlayerManager(); - audioPlayerManager.enableGcMonitoring(); + + if (serverConfig.isGcWarnings()) { + audioPlayerManager.enableGcMonitoring(); + } if (sources.isYoutube()) { YoutubeAudioSourceManager youtube = new YoutubeAudioSourceManager(); diff --git a/LavalinkServer/src/main/java/lavalink/server/config/ServerConfig.java b/LavalinkServer/src/main/java/lavalink/server/config/ServerConfig.java index a3d16a2a5..01d973039 100644 --- a/LavalinkServer/src/main/java/lavalink/server/config/ServerConfig.java +++ b/LavalinkServer/src/main/java/lavalink/server/config/ServerConfig.java @@ -32,6 +32,12 @@ public class ServerConfig { private String password; + private String sentryDsn = ""; + @Nullable + private Integer bufferDurationMs; + @Nullable + private Integer youtubePlaylistLoadLimit; + private boolean gcWarnings = true; public String getPassword() { return password; @@ -41,8 +47,6 @@ public void setPassword(String password) { this.password = password; } - private String sentryDsn = ""; - public String getSentryDsn() { return sentryDsn; } @@ -51,9 +55,6 @@ public void setSentryDsn(String sentryDsn) { this.sentryDsn = sentryDsn; } - @Nullable - public Integer bufferDurationMs; - @Nullable public Integer getBufferDurationMs() { return bufferDurationMs; @@ -63,9 +64,6 @@ public void setBufferDurationMs(@Nullable Integer bufferDurationMs) { this.bufferDurationMs = bufferDurationMs; } - @Nullable - private Integer youtubePlaylistLoadLimit; - @Nullable public Integer getYoutubePlaylistLoadLimit() { return youtubePlaylistLoadLimit; @@ -74,4 +72,12 @@ public Integer getYoutubePlaylistLoadLimit() { public void setYoutubePlaylistLoadLimit(@Nullable Integer youtubePlaylistLoadLimit) { this.youtubePlaylistLoadLimit = youtubePlaylistLoadLimit; } + + public boolean isGcWarnings() { + return gcWarnings; + } + + public void setGcWarnings(boolean gcWarnings) { + this.gcWarnings = gcWarnings; + } } diff --git a/LavalinkServer/src/main/java/lavalink/server/metrics/GcNotificationListener.java b/LavalinkServer/src/main/java/lavalink/server/metrics/GcNotificationListener.java new file mode 100644 index 000000000..73783a59d --- /dev/null +++ b/LavalinkServer/src/main/java/lavalink/server/metrics/GcNotificationListener.java @@ -0,0 +1,39 @@ +package lavalink.server.metrics; + +import com.sun.management.GarbageCollectionNotificationInfo; +import com.sun.management.GcInfo; +import io.prometheus.client.Collector; +import io.prometheus.client.Histogram; + +import javax.management.Notification; +import javax.management.NotificationListener; +import javax.management.openmbean.CompositeData; + +import static com.sun.management.GarbageCollectionNotificationInfo.GARBAGE_COLLECTION_NOTIFICATION; +import static com.sun.management.GarbageCollectionNotificationInfo.from; + +/** + * Created by napster on 21.05.18. + *

+ * General idea taken from {@link com.sedmelluq.discord.lavaplayer.tools.GarbageCollectionMonitor}, thanks! + */ +public class GcNotificationListener implements NotificationListener { + + private final Histogram gcPauses = Histogram.build() + .name("lavalink_gc_pauses_seconds") + .help("Garbage collection pauses by buckets") + .buckets(25, 50, 100, 200, 400, 800, 1600) + .register(); + + @Override + public void handleNotification(Notification notification, Object handback) { + if (GARBAGE_COLLECTION_NOTIFICATION.equals(notification.getType())) { + GarbageCollectionNotificationInfo notificationInfo = from((CompositeData) notification.getUserData()); + GcInfo info = notificationInfo.getGcInfo(); + + if (info != null && !"No GC".equals(notificationInfo.getGcCause())) { + gcPauses.observe(info.getDuration() / Collector.MILLISECONDS_PER_SECOND); + } + } + } +} diff --git a/LavalinkServer/src/main/java/lavalink/server/metrics/PrometheusMetrics.java b/LavalinkServer/src/main/java/lavalink/server/metrics/PrometheusMetrics.java index be1ea1d44..a13ba8ea4 100644 --- a/LavalinkServer/src/main/java/lavalink/server/metrics/PrometheusMetrics.java +++ b/LavalinkServer/src/main/java/lavalink/server/metrics/PrometheusMetrics.java @@ -8,6 +8,10 @@ import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import org.springframework.stereotype.Component; +import javax.management.NotificationEmitter; +import java.lang.management.GarbageCollectorMXBean; +import java.lang.management.ManagementFactory; + /** * Created by napster on 08.05.18. */ @@ -30,6 +34,14 @@ public PrometheusMetrics() { //jvm (hotspot) metrics DefaultExports.initialize(); + //gc pause buckets + final GcNotificationListener gcNotificationListener = new GcNotificationListener(); + for (GarbageCollectorMXBean gcBean : ManagementFactory.getGarbageCollectorMXBeans()) { + if (gcBean instanceof NotificationEmitter) { + ((NotificationEmitter) gcBean).addNotificationListener(gcNotificationListener, null, gcBean); + } + } + log.info("Prometheus metrics set up"); } }