Skip to content

Conversation

@hassiebp
Copy link
Contributor

@hassiebp hassiebp commented Oct 22, 2025

Important

Renamed host to base_url in Langfuse client, added LANGFUSE_BASE_URL env variable, and ensured backward compatibility with LANGFUSE_HOST.

  • Behavior:
    • Renamed host parameter to base_url in Langfuse.__init__() with backward compatibility.
    • Introduced LANGFUSE_BASE_URL environment variable, deprecated LANGFUSE_HOST.
    • Fallback order: base_url arg → LANGFUSE_BASE_URL env → host arg → LANGFUSE_HOST env → default.
  • Code Changes:
    • Updated Langfuse client initialization and internal references from self._host to self._base_url in client.py.
    • Modified LangfuseSpanProcessor and LangfuseResourceManager to use base_url.
    • Updated get_client.py to use base_url.
  • Testing:
    • Updated tests in test_additional_headers_simple.py and test_initialization.py to reflect base_url changes.
    • Added tests for base_url precedence and backward compatibility in test_initialization.py.

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


Disclaimer: Experimental PR review

Greptile Overview

Updated On: 2025-10-22 12:33:06 UTC

Summary

Renamed the host parameter to base_url across the Langfuse client codebase to improve API consistency and clarity.

Key changes:

  • Added new LANGFUSE_BASE_URL environment variable with LANGFUSE_HOST marked as deprecated
  • Updated Langfuse.__init__() to accept base_url parameter with full backward compatibility for host
  • Fallback priority: base_url arg → LANGFUSE_BASE_URL env → host arg → LANGFUSE_HOST env → default value
  • Renamed internal attribute from self._host to self._base_url throughout the client
  • Updated all component initializations (LangfuseResourceManager, LangfuseSpanProcessor, etc.) to use base_url
  • Updated tests to use new base_url parameter while maintaining existing test coverage

Backward compatibility:

  • The deprecated host parameter is preserved in the API signature
  • Existing code using host parameter or LANGFUSE_HOST environment variable will continue to work
  • No breaking changes to the public API

Confidence Score: 5/5

  • This PR is safe to merge with minimal risk
  • The refactoring is well-executed with complete backward compatibility. The parameter renaming follows a clear deprecation path, all internal references are consistently updated, and the fallback logic ensures existing code continues to work without modifications.
  • No files require special attention

Important Files Changed

File Analysis

Filename Score Overview
langfuse/_client/environment_variables.py 5/5 Added LANGFUSE_BASE_URL environment variable and marked LANGFUSE_HOST as deprecated with clear documentation
langfuse/_client/client.py 5/5 Renamed host parameter to base_url with backward compatibility fallback, updated all internal references from self._host to self._base_url
langfuse/_client/resource_manager.py 5/5 Renamed host parameter to base_url throughout the resource manager, updated all method signatures and internal references
langfuse/_client/span_processor.py 5/5 Renamed host parameter to base_url in span processor initialization and endpoint construction
langfuse/_client/get_client.py 5/5 Updated client creation to use base_url instead of host when creating clients from resource manager instances
tests/test_additional_headers_simple.py 5/5 Updated test file to use base_url parameter in LangfuseSpanProcessor initialization, maintaining test coverage

Sequence Diagram

sequenceDiagram
    participant User
    participant Langfuse
    participant ResourceManager
    participant SpanProcessor
    participant API

    User->>Langfuse: __init__(base_url="...", host="...")
    Note over Langfuse: Priority: base_url > LANGFUSE_BASE_URL env > host > LANGFUSE_HOST env
    Langfuse->>Langfuse: self._base_url = resolved value
    Langfuse->>ResourceManager: __new__(base_url=self._base_url)
    ResourceManager->>ResourceManager: Store base_url
    ResourceManager->>SpanProcessor: __init__(base_url=base_url)
    SpanProcessor->>SpanProcessor: endpoint = f"{base_url}/api/public/otel/v1/traces"
    SpanProcessor->>API: Configure OTLP exporter with endpoint
    ResourceManager->>API: Create FernLangfuse(base_url=base_url)
    ResourceManager->>API: Create AsyncFernLangfuse(base_url=base_url)
    ResourceManager->>API: Create LangfuseClient(base_url=base_url)
Loading

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.

6 files reviewed, no comments

Edit Code Review Agent Settings | Greptile

@hassiebp hassiebp merged commit 48ca028 into main Oct 22, 2025
12 checks passed
@hassiebp hassiebp deleted the hassieb/lfe-7344-move-to-base-url branch October 22, 2025 13:35
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