fix(get_client): preserve properties on client such as environment#1341
Merged
fix(get_client): preserve properties on client such as environment#1341
Conversation
hassiebp
approved these changes
Sep 16, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Important
Introduces
_create_client_from_instanceto ensureLangfuseclient settings are preserved, updatesget_clientfor consistent client creation, and adds tests for settings preservation._create_client_from_instanceinget_client.pyto preserve all client settings when creating aLangfuseclient.get_clientinget_client.pyto use_create_client_from_instancefor consistent client creation._initialize_instanceinresource_manager.py.test_get_client_preserves_all_settingsandtest_get_client_multiple_clients_preserve_different_settingsintest_resource_manager.pyto verify settings preservation.This description was created by
for 7dd8c5e. You can customize this summary. It will automatically update as commits are pushed.
Disclaimer: Experimental PR review
Greptile Summary
Updated On: 2025-09-16 09:51:13 UTC
This PR fixes a critical bug in the
get_client()function where client configuration properties were not being properly preserved when retrieving existing Langfuse client instances. Previously, the function only preserved 4 basic properties (public_key, secret_key, host, tracing_enabled) and would return clients with default values for all other settings.The fix involves three key changes:
Enhanced Property Storage: Modified
LangfuseResourceManagerto store all 12+ client configuration properties as instance attributes, includingtimeout,flush_at,flush_interval,release,sample_rate,additional_headers, etc.New Helper Function: Added
_create_client_from_instance()inget_client.pythat constructs new Langfuse clients using all stored properties from the resource manager instance, ensuring complete configuration preservation.Updated Client Creation: Replaced hardcoded
Langfuse()constructor calls with calls to the new helper function at the two locations where clients are recreated.This change is essential for maintaining consistency in multi-client scenarios and decorator-based tracing patterns where
get_client()is the primary access method. The fix ensures that retrieved clients behave identically to their original configured instances, following the principle of least surprise.Confidence score: 5/5