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]

test(callbacks): cover upstream langfuse debug env

user258edac7276a
diff --git a/tests/logging_callback_tests/test_langfuse_dynamic_credentials.py b/tests/logging_callback_tests/test_langfuse_dynamic_credentials.py
index ac4486639da..14478649ad3 100644
--- a/tests/logging_callback_tests/test_langfuse_dynamic_credentials.py
+++ b/tests/logging_callback_tests/test_langfuse_dynamic_credentials.py
@@ -1,3 +1,7 @@
+import sys
+from types import ModuleType, SimpleNamespace
+
+import litellm
from litellm.integrations.langfuse.langfuse import resolve_langfuse_credentials
@@ -44,3 +48,36 @@ def test_resolve_langfuse_credentials_keeps_env_for_global_config(monkeypatch):
assert public_key == "global-public"
assert secret_key == "global-secret"
assert host == "https://admin-configured.example"
+
+
+def test_upstream_langfuse_debug_env_is_passed(monkeypatch):
+ from litellm.integrations.langfuse.langfuse import LangFuseLogger
+
+ class FakeLangfuse:
+ instances = []
+
+ def __init__(self, **kwargs):
+ self.kwargs = kwargs
+ FakeLangfuse.instances.append(self)
+
+ fake_langfuse_module = ModuleType("langfuse")
+ fake_langfuse_module.Langfuse = FakeLangfuse
+ fake_langfuse_module.version = SimpleNamespace(__version__="2.6.0")
+
+ monkeypatch.setitem(sys.modules, "langfuse", fake_langfuse_module)
+ monkeypatch.setattr(litellm, "initialized_langfuse_clients", 0)
+ monkeypatch.setenv("LANGFUSE_MOCK", "true")
+ monkeypatch.setenv("UPSTREAM_LANGFUSE_SECRET_KEY", "upstream-secret")
+ monkeypatch.setenv("UPSTREAM_LANGFUSE_PUBLIC_KEY", "upstream-public")
+ monkeypatch.setenv("UPSTREAM_LANGFUSE_HOST", "https://upstream.example")
+ monkeypatch.setenv("UPSTREAM_LANGFUSE_RELEASE", "release")
+ monkeypatch.setenv("UPSTREAM_LANGFUSE_DEBUG", "true")
+
+ logger = LangFuseLogger(
+ langfuse_public_key="public",
+ langfuse_secret="secret",
+ langfuse_host="https://langfuse.example",
+ )
+
+ assert logger.upstream_langfuse_debug == "true"
+ assert FakeLangfuse.instances[-1].kwargs["debug"] is True