mirror of
https://github.com/langgenius/dify.git
synced 2026-11-11 05:41:09 +08:00
Co-authored-by: Jyong <76649700+JohnJyong@users.noreply.github.com> Co-authored-by: hjlarry <hjlarry@163.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> Co-authored-by: zhaohao1004 <zhaohao1004@gmail.com> Co-authored-by: yyh <yuanyouhuilyz@gmail.com> Co-authored-by: FFXN <lizy@dify.ai>
25 lines
840 B
Python
25 lines
840 B
Python
"""Production assembly for KnowledgeFS database-backed metrics."""
|
|
|
|
from __future__ import annotations
|
|
|
|
import logging
|
|
|
|
from flask import Flask
|
|
|
|
from core.db.session_factory import session_factory
|
|
from repositories.sqlalchemy_knowledge_fs_control_space_state_metrics import (
|
|
SQLAlchemyKnowledgeFSControlSpaceStateCountReader,
|
|
)
|
|
from services.knowledge_fs.observability import get_knowledge_fs_operational_metrics
|
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
|
|
def init_app(app: Flask) -> None:
|
|
del app
|
|
try:
|
|
reader = SQLAlchemyKnowledgeFSControlSpaceStateCountReader(session_factory.get_session_maker())
|
|
get_knowledge_fs_operational_metrics().register_control_space_state_gauge(reader)
|
|
except Exception:
|
|
logger.exception("KnowledgeFS operational metric registration failed; continuing application startup")
|