- Adding a Tenant Type
- Allow filtering on Tenant Types & searching for parts of Tenant names - Implement health checks - Start Prometheus monitoring (needs to be finalized) - Refine audio_processor and srt_processor to reduce duplicate code and support for larger files - Introduce repopack to reason in LLMs about the code
This commit is contained in:
@@ -1,10 +1,13 @@
|
||||
import uuid
|
||||
from functools import wraps
|
||||
|
||||
from flask_jwt_extended import create_access_token, get_jwt_identity, verify_jwt_in_request, decode_token
|
||||
from flask_socketio import emit, disconnect, join_room, leave_room
|
||||
from flask import current_app, request, session
|
||||
from sqlalchemy.exc import SQLAlchemyError
|
||||
from datetime import datetime, timedelta
|
||||
from prometheus_client import Counter, Histogram
|
||||
from time import time
|
||||
|
||||
from common.extensions import socketio, db, simple_encryption
|
||||
from common.models.user import Tenant
|
||||
@@ -12,8 +15,27 @@ from common.models.interaction import Interaction
|
||||
from common.utils.celery_utils import current_celery
|
||||
from common.utils.database import Database
|
||||
|
||||
# Define custom metrics
|
||||
socketio_message_counter = Counter('socketio_message_count', 'Count of SocketIO messages', ['event_type'])
|
||||
socketio_message_latency = Histogram('socketio_message_latency_seconds', 'Latency of SocketIO message processing', ['event_type'])
|
||||
|
||||
|
||||
# Decorator to measure SocketIO events
|
||||
def track_socketio_event(func):
|
||||
@wraps(func)
|
||||
def wrapper(*args, **kwargs):
|
||||
event_type = func.__name__
|
||||
socketio_message_counter.labels(event_type=event_type).inc()
|
||||
start_time = time()
|
||||
result = func(*args, **kwargs)
|
||||
latency = time() - start_time
|
||||
socketio_message_latency.labels(event_type=event_type).observe(latency)
|
||||
return result
|
||||
return wrapper
|
||||
|
||||
|
||||
@socketio.on('connect')
|
||||
@track_socketio_event
|
||||
def handle_connect():
|
||||
try:
|
||||
current_app.logger.debug(f'SocketIO: Connection handling started using {request.args}')
|
||||
@@ -58,6 +80,7 @@ def handle_connect():
|
||||
|
||||
|
||||
@socketio.on('disconnect')
|
||||
@track_socketio_event
|
||||
def handle_disconnect():
|
||||
room = session.get('room')
|
||||
if room:
|
||||
|
||||
Reference in New Issue
Block a user