Skip to content

Conversation

@nimarb
Copy link
Contributor

@nimarb nimarb commented Sep 16, 2025

Important

Introduces _create_client_from_instance to ensure Langfuse client settings are preserved, updates get_client for consistent client creation, and adds tests for settings preservation.

  • Behavior:
    • Introduces _create_client_from_instance in get_client.py to preserve all client settings when creating a Langfuse client.
    • Updates get_client in get_client.py to use _create_client_from_instance for consistent client creation.
  • Resource Manager:
    • Adds storage of additional client settings in _initialize_instance in resource_manager.py.
  • Tests:
    • Adds test_get_client_preserves_all_settings and test_get_client_multiple_clients_preserve_different_settings in test_resource_manager.py to verify settings preservation.

This description was created by Ellipsis 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:

  1. Enhanced Property Storage: Modified LangfuseResourceManager to store all 12+ client configuration properties as instance attributes, including timeout, flush_at, flush_interval, release, sample_rate, additional_headers, etc.

  2. New Helper Function: Added _create_client_from_instance() in get_client.py that constructs new Langfuse clients using all stored properties from the resource manager instance, ensuring complete configuration preservation.

  3. 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

  • This PR is extremely safe to merge with minimal risk of production issues
  • Score reflects straightforward property preservation with comprehensive test coverage and no breaking changes to existing APIs
  • No files require special attention as the changes are well-tested and follow established patterns

@nimarb nimarb marked this pull request as ready for review September 16, 2025 09:50
@nimarb nimarb requested a review from hassiebp September 16, 2025 09:50
Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

3 files reviewed, no comments

Edit Code Review Bot Settings | Greptile

@nimarb nimarb merged commit bd1a5d3 into main Sep 16, 2025
18 of 23 checks passed
@nimarb nimarb deleted the nimar/lfe-6732-preserve-get-client-properties branch September 16, 2025 13:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants