Skip to content

feat(client): allow setting separate tracerprovider#1254

Merged
hassiebp merged 2 commits intomainfrom
hassieb/lfe-5804-separate-tracerprovider
Jul 14, 2025
Merged

feat(client): allow setting separate tracerprovider#1254
hassiebp merged 2 commits intomainfrom
hassieb/lfe-5804-separate-tracerprovider

Conversation

@hassiebp
Copy link
Copy Markdown
Contributor

@hassiebp hassiebp commented Jul 14, 2025

Disclaimer: Experimental PR review

Greptile Summary

This PR introduces a new feature that allows users to specify a custom OpenTelemetry TracerProvider in the Langfuse Python SDK. The change affects two main files: resource_manager.py and client.py. The key addition is a new optional parameter tracer_provider that gives users more control over their tracing configuration.

The changes allow organizations to:

  1. Separate Langfuse tracing from other OpenTelemetry instrumentation
  2. Customize trace collection and management specifically for Langfuse
  3. Better integrate with existing OpenTelemetry setups

The implementation maintains backward compatibility by making the parameter optional while providing advanced users with full control over their tracing setup.

Confidence score: 5/5

  1. This PR is very safe to merge - it's a backwards-compatible feature addition with no breaking changes
  2. The implementation is clean and follows best practices for handling optional parameters
  3. Files needing attention:
    • langfuse/_client/client.py: Review the documentation comments for accuracy
    • langfuse/_client/resource_manager.py: Verify the tracer initialization logic

2 files reviewed, no comments
Edit PR Review Bot Settings | Greptile


Important

Add support for custom OpenTelemetry TracerProvider in Langfuse client and resource manager.

  • Behavior:
    • Add tracer_provider parameter to Langfuse class in client.py to allow setting a custom OpenTelemetry TracerProvider.
    • Add tracer_provider parameter to LangfuseResourceManager class in resource_manager.py for custom tracing management.
    • Defaults to existing tracer provider if tracer_provider is not provided.
  • Initialization:
    • Modify _initialize_instance() in resource_manager.py to use provided tracer_provider or initialize a new one.
    • Update __new__() in resource_manager.py to pass tracer_provider to _initialize_instance().
  • Misc:
    • Update docstring in client.py to document the new tracer_provider parameter.

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

Copy link
Copy Markdown
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 enabled auto-merge (squash) July 14, 2025 11:23
@hassiebp hassiebp merged commit 60947d5 into main Jul 14, 2025
10 checks passed
@hassiebp hassiebp deleted the hassieb/lfe-5804-separate-tracerprovider branch July 14, 2025 11:30
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.

1 participant