[BugFix] fix work metrics not returned by metrics api (#4921)

This commit is contained in:
Yonghua Li
2025-11-12 17:11:40 +08:00
committed by GitHub
parent cf61d30fd7
commit 6d564d5e05
2 changed files with 12 additions and 3 deletions

View File

@@ -17,11 +17,20 @@
import os
import subprocess
import sys
import uuid
# suppress warning log from paddlepaddle
os.environ["GLOG_minloglevel"] = "2"
# suppress log from aistudio
os.environ["AISTUDIO_LOG"] = "critical"
# set prometheus dir
if os.getenv("PROMETHEUS_MULTIPROC_DIR", "") == "":
prom_dir = f"/tmp/fd_prom_{str(uuid.uuid4())}"
os.environ["PROMETHEUS_MULTIPROC_DIR"] = prom_dir
if os.path.exists(prom_dir):
os.rmdir(prom_dir)
os.mkdir(prom_dir)
import typing
from paddleformers.utils.log import logger as pf_logger

View File

@@ -52,7 +52,6 @@ from fastdeploy.entrypoints.openai.tool_parsers import ToolParserManager
from fastdeploy.entrypoints.openai.utils import UVICORN_CONFIG
from fastdeploy.metrics.metrics import (
EXCLUDE_LABELS,
cleanup_prometheus_files,
get_filtered_metrics,
main_process_metrics,
)
@@ -476,8 +475,9 @@ def launch_metrics_server():
if not is_port_available(args.host, args.metrics_port):
raise Exception(f"The parameter `metrics_port`:{args.metrics_port} is already in use.")
prom_dir = cleanup_prometheus_files(True)
os.environ["PROMETHEUS_MULTIPROC_DIR"] = prom_dir
# Move setting prometheus directory to fastdeploy/__init__.py
# prom_dir = cleanup_prometheus_files(True)
# os.environ["PROMETHEUS_MULTIPROC_DIR"] = prom_dir
metrics_server_thread = threading.Thread(target=run_metrics_server, daemon=True)
metrics_server_thread.start()
time.sleep(1)