diff --git a/skynet/modules/monitoring.py b/skynet/modules/monitoring.py index bccd336..8629c9f 100644 --- a/skynet/modules/monitoring.py +++ b/skynet/modules/monitoring.py @@ -51,6 +51,13 @@ subsystem=PROMETHEUS_STREAMING_WHISPER_SUBSYSTEM, ) +TRANSCRIBE_STRESS_LEVEL_METRIC = Gauge( + 'stress_level', + documentation='Whisper stress level', + namespace=PROMETHEUS_NAMESPACE, + subsystem=PROMETHEUS_STREAMING_WHISPER_SUBSYSTEM, +) + TRANSCRIBE_CONNECTIONS_COUNTER = Counter( 'LiveWsConnectionsCounter', documentation='Number of active WS connections', diff --git a/skynet/modules/stt/streaming_whisper/connection_manager.py b/skynet/modules/stt/streaming_whisper/connection_manager.py index f9d067c..c9257b0 100644 --- a/skynet/modules/stt/streaming_whisper/connection_manager.py +++ b/skynet/modules/stt/streaming_whisper/connection_manager.py @@ -4,9 +4,9 @@ from fastapi import WebSocket, WebSocketDisconnect from skynet.auth.jwt import authorize -from skynet.env import bypass_auth +from skynet.env import bypass_auth, whisper_max_connections from skynet.logs import get_logger -from skynet.modules.monitoring import CONNECTIONS_METRIC, TRANSCRIBE_CONNECTIONS_COUNTER +from skynet.modules.monitoring import CONNECTIONS_METRIC, TRANSCRIBE_CONNECTIONS_COUNTER, TRANSCRIBE_STRESS_LEVEL_METRIC from skynet.modules.stt.streaming_whisper.meeting_connection import MeetingConnection from skynet.modules.stt.streaming_whisper.utils import utils @@ -35,6 +35,7 @@ async def connect(self, websocket: WebSocket, meeting_id: str, auth_token: str | loop = asyncio.get_running_loop() self.flush_audio_task = loop.create_task(self.flush_working_audio_worker()) CONNECTIONS_METRIC.set(len(self.connections)) + TRANSCRIBE_STRESS_LEVEL_METRIC.set(len(self.connections)/whisper_max_connections) TRANSCRIBE_CONNECTIONS_COUNTER.inc() log.info(f'Meeting with id {meeting_id} started. Ongoing meetings {len(self.connections)}') @@ -63,6 +64,7 @@ def disconnect(self, meeting_id: str): except KeyError: log.warning(f'The meeting {meeting_id} doesn\'t exist anymore.') CONNECTIONS_METRIC.set(len(self.connections)) + TRANSCRIBE_STRESS_LEVEL_METRIC.set(len(self.connections)/whisper_max_connections) async def flush_working_audio_worker(self): """