diff --git a/jicofo-common/src/main/kotlin/org/jitsi/jicofo/metrics/GlobalMetrics.kt b/jicofo-common/src/main/kotlin/org/jitsi/jicofo/metrics/GlobalMetrics.kt index 4c6ce3c374..edbd52bb63 100644 --- a/jicofo-common/src/main/kotlin/org/jitsi/jicofo/metrics/GlobalMetrics.kt +++ b/jicofo-common/src/main/kotlin/org/jitsi/jicofo/metrics/GlobalMetrics.kt @@ -23,13 +23,18 @@ import org.jitsi.jicofo.metrics.JicofoMetricsContainer.Companion.instance as met class GlobalMetrics { companion object { @JvmField - val threadsMetrics = metricsContainer.registerLongGauge( + val threadCount = metricsContainer.registerLongGauge( "threads", "The current number of JVM threads" ) + val xmppDisconnects = metricsContainer.registerCounter( + "xmpp_disconnects", + "The number of times one of the XMPP connections has disconnected." + ) + fun update() { - threadsMetrics.set(ManagementFactory.getThreadMXBean().threadCount.toLong()) + threadCount.set(ManagementFactory.getThreadMXBean().threadCount.toLong()) } } } diff --git a/jicofo-common/src/main/kotlin/org/jitsi/jicofo/xmpp/XmppProvider.kt b/jicofo-common/src/main/kotlin/org/jitsi/jicofo/xmpp/XmppProvider.kt index bb017bebe6..db0df98ded 100644 --- a/jicofo-common/src/main/kotlin/org/jitsi/jicofo/xmpp/XmppProvider.kt +++ b/jicofo-common/src/main/kotlin/org/jitsi/jicofo/xmpp/XmppProvider.kt @@ -19,6 +19,7 @@ package org.jitsi.jicofo.xmpp import org.jitsi.impl.protocol.xmpp.log.PacketDebugger import org.jitsi.jicofo.TaskPools +import org.jitsi.jicofo.metrics.GlobalMetrics import org.jitsi.jicofo.xmpp.XmppProvider.RoomExistsException import org.jitsi.jicofo.xmpp.muc.ChatRoom import org.jitsi.jicofo.xmpp.muc.ChatRoomImpl @@ -116,11 +117,13 @@ class XmppProvider(val config: XmppConnectionConfig, parentLogger: Logger) { override fun connectionClosed() { logger.info("XMPP connection closed") + GlobalMetrics.xmppDisconnects.inc() registered = false } override fun connectionClosedOnError(e: Exception) { logger.error("XMPP connection closed on error: ${e.message}", e) + GlobalMetrics.xmppDisconnects.inc() registered = false } } diff --git a/jicofo/src/main/kotlin/org/jitsi/jicofo/JicofoServices.kt b/jicofo/src/main/kotlin/org/jitsi/jicofo/JicofoServices.kt index c161106bc5..8ed01a9235 100644 --- a/jicofo/src/main/kotlin/org/jitsi/jicofo/JicofoServices.kt +++ b/jicofo/src/main/kotlin/org/jitsi/jicofo/JicofoServices.kt @@ -210,7 +210,7 @@ class JicofoServices { JibriDetectorMetrics.appendStats(this) xmppServices.jigasiDetector?.let { put("jigasi_detector", it.stats) } put("jigasi", xmppServices.jigasiStats) - put("threads", GlobalMetrics.threadsMetrics.get()) + put("threads", GlobalMetrics.threadCount.get()) put("jingle", JingleStats.toJson()) put("version", CurrentVersionImpl.VERSION.toString()) healthChecker?.let {