Skip to content

Commit

Permalink
test: warn when lagnfuse tracer init with tracing disabled
Browse files Browse the repository at this point in the history
  • Loading branch information
isfuku committed Dec 9, 2024
1 parent e160978 commit 4465c18
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions integrations/langfuse/tests/test_tracer.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import datetime
import logging
import sys
from unittest.mock import MagicMock, Mock, patch

from haystack.dataclasses import ChatMessage
Expand Down Expand Up @@ -149,3 +151,17 @@ def test_context_is_empty_after_tracing(self):
pass

assert tracer._context == []

def test_init_with_tracing_disabled(self, monkeypatch, caplog):
# Clear haystack modules because ProxyTracer is initialized whenever haystack is imported
modules_to_clear = [name for name in sys.modules if name.startswith('haystack')]
for name in modules_to_clear:
sys.modules.pop(name, None)

# Re-import LangfuseTracer and instantiate it with tracing disabled
with caplog.at_level(logging.WARNING):
monkeypatch.setenv("HAYSTACK_CONTENT_TRACING_ENABLED", "false")
from haystack_integrations.tracing.langfuse import LangfuseTracer

LangfuseTracer(tracer=MockTracer(), name="Haystack", public=False)
assert "tracing is disabled" in caplog.text

0 comments on commit 4465c18

Please sign in to comment.