余尚辉 2 months ago
parent
commit
289bbc48d7
1 changed files with 5 additions and 3 deletions
  1. 5 3
      ai-slibra-assistant/api/AiBot.py

+ 5 - 3
ai-slibra-assistant/api/AiBot.py

@@ -24,7 +24,8 @@ from scene import Dialog,Msg
 from entity import Error
 import traceback
 from util import insert_log, timetic
-
+from prometheus_fastapi_instrumentator import Instrumentator
+from prometheus_client import Counter,Histogram
 import time
 
 
@@ -34,8 +35,9 @@ logger=get_logger("log")
 app = FastAPI()
 
 # 服务监控,qps,latent, cpu利用率
-
-from util.registry import AI_BOT_REQUEST_LATENCY
+Instrumentator().instrument(app).expose(app)
+# from util.registry import AI_BOT_REQUEST_LATENCY
+AI_BOT_REQUEST_LATENCY = Histogram('ai_bot_request_latency',  '文本机器人接口耗时',['bid'])
 
 
 @app.post("/botservice")