Skip to content

Conversation

@hassiebp
Copy link
Contributor

@hassiebp hassiebp commented Sep 10, 2025

Important

Fixes bug in client.py by passing self._environment to LangfuseResourceManager, ensuring consistent environment tagging.

  • Behavior:
    • Fixes bug in client.py by passing self._environment to LangfuseResourceManager instead of raw environment parameter.
    • Ensures consistent environment tagging across traces, generations, and scores.
  • Tests:
    • Adds sleep(1) in test_openai.py to ensure proper test execution timing.

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


Disclaimer: Experimental PR review

Greptile Summary

Updated On: 2025-09-10 16:36:03 UTC

This PR fixes a bug in the Langfuse client's environment variable handling. The issue was in the client.py file where the LangfuseResourceManager was receiving the raw environment parameter instead of the processed self._environment value.

The bug occurred because the client constructor has proper fallback logic that sets self._environment to either the provided environment parameter or reads from the LANGFUSE_TRACING_ENVIRONMENT environment variable if no explicit environment is provided. However, when initializing the LangfuseResourceManager on line 260, the code was incorrectly passing the unprocessed environment parameter instead of self._environment.

This change ensures consistency between the client and resource manager by making both use the same processed environment value. The fix is critical for maintaining proper environment tagging across traces, generations, and scores, as demonstrated by the test cases in test_core_sdk.py which verify that environment settings are correctly propagated throughout the tracing system.

The change integrates seamlessly with the existing codebase architecture where the client acts as the main interface and delegates resource management to the LangfuseResourceManager. This fix ensures both components operate with the same environment configuration, preventing potential inconsistencies in trace metadata.

Confidence score: 5/5

  • This PR is safe to merge with minimal risk as it fixes a clear bug with a simple one-line change
  • Score reflects the straightforward nature of the fix and alignment with existing test coverage that validates environment handling
  • No files require special attention as the change is isolated and well-understood

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.

Reviewing changes made in this pull request

@hassiebp hassiebp merged commit 017e488 into main Sep 11, 2025
7 of 10 checks passed
@hassiebp hassiebp deleted the fix-env-to-resource-manager branch September 11, 2025 13:17
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