Multiple instances of Langfuse client in PythonSDK #11367
Replies: 1 comment 2 replies
-
|
You've identified the core issue correctly. In Python SDK v3, the From the available sources, there is a confirmed limitation: "Sampling is being managed on the global OTEL TracerProvider, and thus only one sampling setting is possible per process"(1). This same constraint applies to the Your use case is not directly supported in SDK v3. The sources confirm that "you can't configure multiple clients with different sample rates for the same public key in the same process"(1), and this extends to tracing enablement as well. Potential workarounds:
The manual trace creation approach would likely work best for your scenario - keep tracing disabled globally, use the client for prompt management, and explicitly create traces only when users provide feedback. 📚 Sources:
Have another question? Just tag @inkeep. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Describe your question
Hi,
In my app, I configure a Langfuse instance with tracing_enabled=false. This allows me to use prompt management features. But I also want users to have the ability to share feedback. I can't collect traces for all queries due to privacy reasons. Whenever they share feedback, I add a trace manually through the SDK and score that trace. I don't have many details stored, mostly input and output, but it's fine.
The problem is that after I migrated from SDK v2 to SDK v3, this no longer seems possible. I have one main instance of the Langfuse client that I use in the app (for the prompt management feature), and I have another one with tracing_enabled=true to create a trace whenever a user decides to share feedback. The tracing_enabled setting seems to be ignored for the client that I use to write traces. My best guess is that both instances use the same OTEL settings under the hood. How do I isolate them from each other?
Best Regards,
Mateusz
Langfuse Cloud or Self-Hosted?
Self-Hosted
If Self-Hosted
No response
If Langfuse Cloud
No response
SDK and integration versions
Python v3
Pre-Submission Checklist
Beta Was this translation helpful? Give feedback.
All reactions