Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Monitor for exceptions and dropped events #23

Merged
merged 2 commits into from
Dec 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions src/main/kotlin/org/jitsi/recorder/MediaJsonMkaRecorder.kt
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import org.jitsi.recorder.opus.GapTooLargeException
import org.jitsi.recorder.opus.OpusPacket
import org.jitsi.recorder.opus.PacketLossConcealmentInserter
import org.jitsi.utils.logging2.Logger
import org.jitsi.utils.queue.ErrorHandler
import org.jitsi.utils.queue.PacketQueue
import java.io.File
import java.time.Clock
Expand All @@ -43,6 +44,17 @@ class MediaJsonMkaRecorder(directory: File, parentLogger: Logger) : MediaJsonRec
val queue = EventQueue {
handleEvent(it)
true
}.also {
it.setErrorHandler(object : ErrorHandler {
override fun packetDropped() {
logger.warn("Dropped an event.")
RecorderMetrics.instance.queueEventsDropped.inc()
}
override fun packetHandlingFailed(t: Throwable) {
logger.error("Error handling event: ", t)
RecorderMetrics.instance.queueExceptions.inc()
}
})
}
private val trackRecorders = mutableMapOf<String, TrackRecorder>()

Expand Down
2 changes: 2 additions & 0 deletions src/main/kotlin/org/jitsi/recorder/RecorderMetrics.kt
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ class RecorderMetrics private constructor() : MetricsContainer(namespace = "jits
"plc_milliseconds",
"Duration of recorded packet concealment packets in milliseconds"
)
val queueEventsDropped = registerCounter("queue_events_dropped", "Number of events dropped")
val queueExceptions = registerCounter("queue_exceptions", "Number of exceptions from the event queue")

companion object {
/**
Expand Down
5 changes: 5 additions & 0 deletions src/test/kotlin/org/jitsi/recorder/KotestProjectConfig.kt
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
package org.jitsi.recorder

import io.kotest.core.config.AbstractProjectConfig
import io.kotest.matchers.shouldBe
import org.jitsi.metaconfig.MetaconfigSettings

class KotestProjectConfig : AbstractProjectConfig() {
Expand All @@ -26,4 +27,8 @@ class KotestProjectConfig : AbstractProjectConfig() {
// freely modify the config without affecting other tests executing afterwards).
MetaconfigSettings.cacheEnabled = false
}
override suspend fun afterProject() = super.afterProject().also {
RecorderMetrics.instance.queueExceptions.get() shouldBe 0
RecorderMetrics.instance.queueEventsDropped.get() shouldBe 0
}
}
Loading