Troubleshooting and FAQ
This page addresses frequently asked questions and common troubleshooting topics for the Langfuse Python SDK.
If you don’t find a solution to your issue here, try using Ask AI for instant answers. For bug reports, please open a ticket on GitHub Issues. For general questions or support, visit our support page.
- Authentication Issues:
- Ensure
LANGFUSE_PUBLIC_KEY,LANGFUSE_SECRET_KEY, andLANGFUSE_HOST(if not using default cloud) are correctly set either as environment variables or in theLangfuse()constructor. - Use
langfuse.auth_check()after initialization to verify credentials. Do not use this in production as this method waits for a response from the server.
- Ensure
- No Traces Appearing:
- Check if
tracing_enabledisTrue(default). - Verify
sample_rateis not0.0. - Ensure
langfuse.shutdown()is called or the program exits cleanly to allowatexithooks to flush data. Manually calllangfuse.flush()to force data sending. - Enable debug logging (
debug=TrueorLANGFUSE_DEBUG="True") to see SDK activity and potential errors during exporting.
- Check if
- Incorrect Nesting or Missing Spans:
- If you are self-hosting Langfuse, the Python SDK v3 requires Langfuse platform version >= 3.63.0 for traces to be correctly processed. You can find a snapshot of the legacy v2 SDK documentation here.
- Ensure you are using context managers (
with langfuse.start_as_current_span(...)) for proper context propagation. - If manually creating spans (
langfuse.start_span()), ensure they are correctly ended with.end(). - In async code, ensure context is not lost across
awaitboundaries if not using Langfuse’s async-compatible methods.
- Langchain/OpenAI Integration Not Working:
- Confirm the respective integration (e.g.,
from langfuse.openai import openaiorLangfuseCallbackHandler) is correctly set up before the calls to the LLM libraries are made. - Check for version compatibility issues between Langfuse, Langchain, and OpenAI SDKs.
- Confirm the respective integration (e.g.,
- Media Not Appearing:
- Ensure
LangfuseMediaobjects are correctly initialized and passed ininput,output, ormetadata. - Check debug logs for any media upload errors. Media uploads happen in background threads.
- Ensure
If you encounter persistent issues, please:
- Enable debug logging to gather more information.
- Check the Langfuse status page (if applicable for cloud users).
- Raise an issue on our GitHub repository with details about your setup, SDK version, code snippets, and debug logs.