Skip to content

Conversation

@hassiebp
Copy link
Contributor

@hassiebp hassiebp commented Dec 22, 2025

Important

Reuse existing httpx_client in _create_client_from_instance() in get_client.py to improve performance.

  • Behavior:
    • Reuse existing httpx_client in _create_client_from_instance() in get_client.py to improve performance by avoiding new client creation.
  • Functions:
    • Add httpx_client=instance.httpx_client parameter to _create_client_from_instance() in get_client.py.

This description was created by Ellipsis for ce6c6c5. You can customize this summary. It will automatically update as commits are pushed.

Disclaimer: Experimental PR review

Greptile Summary

This PR fixes a bug in _create_client_from_instance where the httpx_client was not being passed when creating a new Langfuse client from an existing LangfuseResourceManager instance. This ensures proper reuse of the httpx connection pool, preventing potential TCP socket exhaustion issues as documented in the codebase.

  • Added httpx_client=instance.httpx_client parameter to the Langfuse constructor call in _create_client_from_instance

Confidence Score: 5/5

  • This PR is safe to merge - it's a minimal, targeted fix that adds a missing parameter to ensure proper resource reuse.
  • Single-line change that correctly propagates an existing parameter. The change aligns with the documented design pattern in the codebase (httpx client singleton for connection pool management). No risk of regression.
  • No files require special attention.

Important Files Changed

Filename Overview
langfuse/_client/get_client.py Added httpx_client parameter to _create_client_from_instance to reuse the existing httpx client from the resource manager instance, preventing potential connection pool exhaustion.

Sequence Diagram

sequenceDiagram
    participant User
    participant get_client
    participant _create_client_from_instance
    participant Langfuse
    participant LangfuseResourceManager

    User->>get_client: get_client()
    get_client->>LangfuseResourceManager: Check _instances
    alt Instance exists
        get_client->>_create_client_from_instance: Create client from instance
        _create_client_from_instance->>Langfuse: new Langfuse(httpx_client=instance.httpx_client)
        Langfuse->>LangfuseResourceManager: Get singleton (reuses existing)
        Note right of LangfuseResourceManager: Reuses existing httpx_client<br/>from connection pool
        Langfuse-->>_create_client_from_instance: Return client
        _create_client_from_instance-->>get_client: Return client
    end
    get_client-->>User: Return Langfuse client
Loading

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Dec 22, 2025

Greptile's behavior is changing!

From now on, if a review finishes with no comments, we will not post an additional "statistics" comment to confirm that our review found nothing to comment on. However, you can confirm that we reviewed your changes in the status check section.

This feature can be toggled off in your Code Review Settings by deselecting "Create a status check for each PR".

@hassiebp hassiebp merged commit 600325d into main Dec 22, 2025
12 checks passed
@hassiebp hassiebp deleted the hassieb/lfe-8111-bug-missing-httpx-configuration-in branch December 22, 2025 09:25
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.

2 participants