Skip to content

fix(observe): resolve names for partial functions - #2104

Open
Aminark wants to merge 1 commit into
langfuse:mainfrom
Aminark:fix/observe-partial-functions
Open

Aminark wants to merge 1 commit into
langfuse:mainfrom
Aminark:fix/observe-partial-functions

Conversation

@Aminark

@Aminark Aminark commented Nov 5, 2026 •

Copy link
Copy Markdown

What does this PR do?

observe()(partial(fn, ...)) raises AttributeError before calling fn, because partial objects do not have a __name__. This affects both sync and async functions when no observation name is supplied.

Resolve the default name from the wrapped function, including nested partials. Explicit observation names and a partial's own __name__ keep their precedence; the original partial is still used for execution and argument inspection.

Adds six regression cases for sync/async partials, explicit names, and nested partials with or without a custom function name. Four fail on the current main branch.

Type of change

  • Bug fix

Verification

uv run --frozen pytest tests/unit/test_observe.py -q
uv run --frozen ruff check .
uv run --frozen ruff format --check langfuse/_client/observe.py tests/unit/test_observe.py
uv run --frozen mypy langfuse --no-error-summary

All 21 observe unit tests pass on Python 3.13. Lint, formatting, and type checks pass. E2E and live-provider tests were not run; these cases use the shared in-memory exporter and do not need a Langfuse server or provider calls.

Checklist

  • I self-reviewed the diff using code_review.md.
  • I added or updated tests for behavior changes.
  • I updated docs, examples, or .env.template if needed (no changes needed).
  • I did not hand-edit generated files.
  • I did not commit secrets or credentials.

RetriggerView in GreptileConfidence Score: 5/5

This PR appears safe to merge.

Summary

Fixes default observation names for partial functions in both sync and async calls.

  • Observed partials get a name from the wrapped function.

No actionable issues found.

Reviews (1) · Last reviewed commit: "fix(observe): resolve names for partial ..." · Reviewed by Greptile

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Claude Code Review

This pull request is from a fork — automated review is disabled. A repository maintainer can comment @claude review to run a one-time review.

@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

This branch has not been deployed

No deployments
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