wip redundant code

This commit is contained in:
Ryan Crabbe 2026-02-25 17:43:45 -08:00 committed by Sameer Kankute
parent 7f77cd4e00
commit cdaff4f0e3
2 changed files with 12 additions and 19 deletions

View file

@ -322,9 +322,6 @@ class ProxyInitializationHelpers:
"""
Auto-create PROMETHEUS_MULTIPROC_DIR when running with multiple workers
and prometheus is configured as a callback.
If the env var is already set by the user, just ensure the directory exists.
Otherwise, create a temp directory and set the env var.
"""
import tempfile
@ -341,25 +338,25 @@ class ProxyInitializationHelpers:
from litellm.proxy.prometheus_cleanup import wipe_directory
existing_dir = os.environ.get(
"PROMETHEUS_MULTIPROC_DIR"
) or os.environ.get("prometheus_multiproc_dir")
if existing_dir:
os.makedirs(existing_dir, exist_ok=True)
wipe_directory(existing_dir)
print( # noqa
f"LiteLLM: Using existing PROMETHEUS_MULTIPROC_DIR={existing_dir}"
)
return
multiproc_dir = (
os.environ.get("PROMETHEUS_MULTIPROC_DIR")
or os.environ.get("prometheus_multiproc_dir")
)
auto_created = not multiproc_dir
if not multiproc_dir:
multiproc_dir = os.path.join(
tempfile.gettempdir(), "litellm_prometheus_multiproc"
)
multiproc_dir = os.path.join(
tempfile.gettempdir(), "litellm_prometheus_multiproc"
)
os.makedirs(multiproc_dir, exist_ok=True)
wipe_directory(multiproc_dir)
os.environ["PROMETHEUS_MULTIPROC_DIR"] = multiproc_dir
action = "Auto-created" if auto_created else "Use existing"
print( # noqa
f"LiteLLM: Auto-created PROMETHEUS_MULTIPROC_DIR={multiproc_dir}"
f"LiteLLM {action}: Auto-created PROMETHEUS_MULTIPROC_DIR={multiproc_dir}"
)

View file

@ -2064,10 +2064,6 @@ def _schedule_background_health_check_db_save(
async def _periodic_prometheus_cleanup():
"""
Periodically mark dead worker PIDs in the prometheus multiproc directory.
Uses mark_process_dead() which only removes gauge_live* files, preserving
counter/histogram data for correct aggregation. First run is 1 hour after
startup (startup wipe handles stale files), then every hour thereafter.
"""
from litellm.proxy.prometheus_cleanup import mark_dead_pids