Replies: 4 comments 1 reply
-
|
Based on the available documentation, here are several potential causes and debugging steps for missing spans in your production environment: Environment ConfigurationFirst, verify your Langfuse environment variables are correctly set in production(1): LANGFUSE_SECRET_KEY = "sk-lf-..."
LANGFUSE_PUBLIC_KEY = "pk-lf-..."
LANGFUSE_BASE_URL = "https://cloud.langfuse.com" # 🇪🇺 EU region
# LANGFUSE_BASE_URL = "https://us.cloud.langfuse.com" # 🇺🇸 US regionDebug LoggingEnable debug logging to see what's happening with span creation(1): import logging
langfuse_logger = logging.getLogger("langfuse")
langfuse_logger.setLevel(logging.DEBUG)Alternatively, set Data FlushingIn short-lived applications or serverless environments, spans might not be sent before the process terminates. Ensure you're calling from langfuse import get_client
langfuse = get_client()
# ... create traces and observations ...
langfuse.flush() # Ensures all pending data is sentFor proper cleanup, call langfuse.shutdown()Context Propagation IssuesIf you're using from opentelemetry.instrumentation.threading import ThreadingInstrumentor
ThreadingInstrumentor().instrument()Sampling ConfigurationCheck if sampling is accidentally enabled in production. If from langfuse import Langfuse
# Sample approximately 20% of traces
langfuse_sampled = Langfuse(sample_rate=0.2)Ensure your production environment doesn't have Recommended Debugging Steps
The most common cause for missing spans in production environments is data not being flushed before the process terminates(2). Start by adding explicit 📚 Sources: Have another question? Just tag @inkeep. |
Beta Was this translation helpful? Give feedback.
-
|
We have the exact same issue. Locally, with Langfuse debug logging on, spans are processed and sent to Langfuse. With the exact same configuration it does not show processed spans on an Azure AppService, even though we do see Langfuse doing something in the Azure logs: Is there anything under the hood we need to look at? We've done all steps as described above. We're using NestJS as platform. |
Beta Was this translation helpful? Give feedback.
-
|
OK. After about 36 hours of pulling my hair out, on Azure this works: |
Beta Was this translation helpful? Give feedback.
-
|
Hi @raimondkempees-arc, thank you very much for posting your solution here! |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Description:
I'm working on a chatbot using Chainlit and experiencing an issue where spans are not being generated in the production environment, despite working correctly locally.
Environment Details:
Local (working): Running on a dev branch- all spans appear correctly
Production (not working): Deployed website - no spans are generated
Expected Behavior:
Spans should be generated and visible in both local and production environments.
Actual Behavior:
✅ Local development: All spans are logged and visible
❌ Production website: No spans are generated or logged
Code Context:
I'm using Langfuse for observability with the following setup:
CallbackHandler for LLM tracing
Custom spans for various operations (RAG steps, retrieval, reranking, etc.)
Context managers like lf_client.start_as_current_observation()
Questions:
Are there known differences in how Chainlit handles spans between local and production deployments?
Could this be related to environment variables or configuration that needs to be set differently for production?
Are there any specific settings or middleware that might block span generation on the hosted website?
Should I check specific logs or enable certain debugging flags to diagnose this?
Additional Context:
The spans are created using Langfuse's start_as_current_observation() context managers throughout the codebase, and all Langfuse authentication checks pass successfully (lf_client.auth_check() returns True).
Beta Was this translation helpful? Give feedback.
All reactions