Skip to content

Commit

Permalink
feat: Add a metric for XMPP disconnects. (jitsi#1193)
Browse files Browse the repository at this point in the history
* ref: Rename the threads metric variable.

* feat: Add a metric for XMPP disconnects.
  • Loading branch information
bgrozev authored Dec 3, 2024
1 parent 2c7d4d5 commit dbcacfb
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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())
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
}
}
Expand Down
2 changes: 1 addition & 1 deletion jicofo/src/main/kotlin/org/jitsi/jicofo/JicofoServices.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit dbcacfb

Please sign in to comment.