Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: warn if LangfuseTracer initialized without tracing enabled #1231

Merged
merged 2 commits into from
Dec 10, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
from haystack import logging
from haystack.components.generators.openai_utils import _convert_message_to_openai_format
from haystack.dataclasses import ChatMessage
from haystack.tracing import Span, Tracer, tracer
from haystack.tracing import Span, Tracer
from haystack.tracing import tracer as proxy_tracer
from haystack.tracing import utils as tracing_utils

import langfuse
Expand Down Expand Up @@ -78,7 +79,7 @@ def set_content_tag(self, key: str, value: Any) -> None:
:param key: The content tag key.
:param value: The content tag value.
"""
if not tracer.is_content_tracing_enabled:
if not proxy_tracer.is_content_tracing_enabled:
return
if key.endswith(".input"):
if "messages" in value:
Expand Down Expand Up @@ -126,6 +127,12 @@ def __init__(self, tracer: "langfuse.Langfuse", name: str = "Haystack", public:
be publicly accessible to anyone with the tracing URL. If set to `False`, the tracing data will be private
and only accessible to the Langfuse account owner.
"""
if not proxy_tracer.is_content_tracing_enabled:
logger.warning(
"Traces will not be logged to Langfuse because Haystack tracing is disabled. "
"To enable, set the HAYSTACK_CONTENT_TRACING_ENABLED environment variable to true "
"before importing Haystack."
)
self._tracer = tracer
self._context: List[LangfuseSpan] = []
self._name = name
Expand Down
Loading