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

This commit is contained in:
Yonghua Li
2025-11-12 17:11:51 +08:00
committed by GitHub
parent 0d7f29841d
commit c599268f57
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

@@ -60,7 +60,6 @@ from fastdeploy.entrypoints.openai.utils import UVICORN_CONFIG, make_arg_parser
from fastdeploy.envs import environment_variables
from fastdeploy.metrics.metrics import (
EXCLUDE_LABELS,
cleanup_prometheus_files,
get_filtered_metrics,
main_process_metrics,
)
@@ -586,8 +585,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)