Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

feat(observe): allow disabling function io capture by env var #1196

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 27, 2025

Conversation

hassiebp
Copy link
Contributor

@hassiebp hassiebp commented May 27, 2025

Important

Add environment variable to control IO capture in @observe decorator, improving performance for large objects.

  • Environment Variables:
    • Add LANGFUSE_OBSERVE_DECORATOR_IO_CAPTURE_ENABLED to environment_variables.py to control IO capture in @observe decorator.
    • Default value is True, allowing automatic capture of function args, kwargs, and return values.
  • Decorator Behavior:
    • Modify LangfuseDecorator.observe() in observe.py to check LANGFUSE_OBSERVE_DECORATOR_IO_CAPTURE_ENABLED.
    • IO capture (capture_input and capture_output) is conditional on the environment variable being True.
  • Performance:
    • Disabling IO capture can improve performance for functions with large or deeply nested objects.

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

Greptile Summary

Disclaimer: Experimental PR review

Added environment variable LANGFUSE_OBSERVE_DECORATOR_IO_CAPTURE_ENABLED to control automatic function input/output capture in the @observe decorator, helping optimize performance when dealing with large objects.

  • Added new environment variable definition in langfuse/_client/environment_variables.py with clear documentation about performance implications
  • Modified langfuse/_client/observe.py to respect the environment variable setting when determining if IO capture should be enabled
  • Environment variable defaults to True and combines with per-function capture flags using logical AND
  • Implementation maintains type safety and consistency across both synchronous and asynchronous code paths

@hassiebp hassiebp enabled auto-merge (squash) May 27, 2025 08:04
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.

LGTM

2 file(s) reviewed, no comment(s)
Edit PR Review Bot Settings | Greptile

langfuse/_client/observe.py Outdated Show resolved Hide resolved
Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com>
@hassiebp hassiebp disabled auto-merge May 27, 2025 08:14
@hassiebp hassiebp merged commit 3dd812a into main May 27, 2025
7 of 8 checks passed
@hassiebp hassiebp deleted the add-env-var-observe-io-capture branch May 27, 2025 08:14
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
Morty Proxy This is a proxified and sanitized view of the page, visit original site.