|
@@ -25,7 +25,7 @@ from entity import Error
|
|
|
import traceback
|
|
|
from util import insert_log, timetic
|
|
|
from prometheus_fastapi_instrumentator import Instrumentator
|
|
|
-
|
|
|
+from prometheus_client import generate_latest
|
|
|
import time
|
|
|
|
|
|
|
|
@@ -92,6 +92,9 @@ def botservice(reqbot:reqRobot):
|
|
|
print(f"Latency for {bid}: {latency}") # 日志记录
|
|
|
AI_BOT_REQUEST_LATENCY.labels(bid=bid).observe(latency)
|
|
|
|
|
|
+@app.get("/metrics")
|
|
|
+def metrics():
|
|
|
+ return generate_latest() # 暴露所有指标
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
uvicorn.run("AiBot:app", host='0.0.0.0', port=40072,workers=4)
|