Skip to content

The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]

Fix CI/CD pyroscope test failure (#21219)

Alexsander Hamir7944b6784232
diff --git a/litellm/proxy/proxy_server.py b/litellm/proxy/proxy_server.py
index bc2d32f141d..318c64e4a05 100644
--- a/litellm/proxy/proxy_server.py
+++ b/litellm/proxy/proxy_server.py
@@ -5831,6 +5831,7 @@ class ProxyStartupEvent:
verbose_proxy_logger.debug(
"LiteLLM: Pyroscope profiling is disabled (set LITELLM_ENABLE_PYROSCOPE=true to enable)."
)
+ return
try:
import pyroscope
diff --git a/tests/test_litellm/proxy/test_pyroscope.py b/tests/test_litellm/proxy/test_pyroscope.py
index 6bfdf81ec1a..548af35ba53 100644
--- a/tests/test_litellm/proxy/test_pyroscope.py
+++ b/tests/test_litellm/proxy/test_pyroscope.py
@@ -21,6 +21,10 @@ def test_init_pyroscope_returns_cleanly_when_disabled():
with patch(
"litellm.proxy.proxy_server.get_secret_bool",
return_value=False,
+ ), patch.dict(
+ os.environ,
+ {"LITELLM_ENABLE_PYROSCOPE": "false"},
+ clear=False,
):
ProxyStartupEvent._init_pyroscope()
@@ -37,6 +41,7 @@ def test_init_pyroscope_raises_when_enabled_but_missing_app_name():
), patch.dict(
os.environ,
{
+ "LITELLM_ENABLE_PYROSCOPE": "true",
"PYROSCOPE_APP_NAME": "",
"PYROSCOPE_SERVER_ADDRESS": "http://localhost:4040",
},
@@ -58,6 +63,7 @@ def test_init_pyroscope_raises_when_enabled_but_missing_server_address():
), patch.dict(
os.environ,
{
+ "LITELLM_ENABLE_PYROSCOPE": "true",
"PYROSCOPE_APP_NAME": "myapp",
"PYROSCOPE_SERVER_ADDRESS": "",
},
@@ -79,6 +85,7 @@ def test_init_pyroscope_raises_when_sample_rate_invalid():
), patch.dict(
os.environ,
{
+ "LITELLM_ENABLE_PYROSCOPE": "true",
"PYROSCOPE_APP_NAME": "myapp",
"PYROSCOPE_SERVER_ADDRESS": "http://localhost:4040",
"PYROSCOPE_SAMPLE_RATE": "not-a-number",
@@ -101,6 +108,7 @@ def test_init_pyroscope_accepts_integer_sample_rate():
), patch.dict(
os.environ,
{
+ "LITELLM_ENABLE_PYROSCOPE": "true",
"PYROSCOPE_APP_NAME": "myapp",
"PYROSCOPE_SERVER_ADDRESS": "http://localhost:4040",
"PYROSCOPE_SAMPLE_RATE": "100",
@@ -127,6 +135,7 @@ def test_init_pyroscope_accepts_float_sample_rate_parsed_as_int():
), patch.dict(
os.environ,
{
+ "LITELLM_ENABLE_PYROSCOPE": "true",
"PYROSCOPE_APP_NAME": "myapp",
"PYROSCOPE_SERVER_ADDRESS": "http://localhost:4040",
"PYROSCOPE_SAMPLE_RATE": "100.7",