Skip to content

Fix FIXME in telemetry by using functools.wraps#11569

Open
ritikraj2425 wants to merge 1 commit into
deepset-ai:mainfrom
ritikraj2425:fix-telemetry-wrapper-scope
Open

Fix FIXME in telemetry by using functools.wraps#11569
ritikraj2425 wants to merge 1 commit into
deepset-ai:mainfrom
ritikraj2425:fix-telemetry-wrapper-scope

Conversation

@ritikraj2425

Copy link
Copy Markdown
Contributor

Related Issues

Proposed Changes:

  • Added import functools to haystack/telemetry/_telemetry.py.
  • Applied the @functools.wraps(func) decorator to send_telemetry_wrapper.
  • Removed the obsolete # FIXME comment suggesting that functools.wraps makes the global telemetry variable out of scope.

This ensures that any telemetry-wrapped functions (such as pipeline_running and tutorial_running) retain their original metadata, such as __name__, __doc__, and __annotations__.

How did you test it?

  • Ran the local telemetry test suite to verify no scope or runtime errors occur:
    hatch -e test run python -m pytest test/test_telemetry.py
  • All 4 tests passed successfully.

Notes for the reviewer

The original # FIXME was likely caused by a missing functools import in this file rather than an actual scoping issue. Python resolves global variables at execution time, and functools.wraps merely copies function metadata at decoration time, meaning it has no effect on the runtime scope of the global telemetry variable.

Checklist

  • I have read the contributors guidelines and the code of conduct.
  • I have updated the related issue with new insights and changes.
  • I have added unit tests and updated the docstrings. (N/A: Existing telemetry tests were run and passed).
  • I've used one of the conventional commit types for my PR title: fix: telemetry decorator overwrites original function metadata.
  • I have documented my code.
  • I have added a release note file, following the contributors guidelines. (Note: If needed, you can generate this by running hatch run release-note "Fix telemetry decorator metadata loss")
  • I have run pre-commit hooks and fixed any issue.

@ritikraj2425 ritikraj2425 requested a review from a team as a code owner June 10, 2026 07:28
@ritikraj2425 ritikraj2425 requested review from julian-risch and removed request for a team June 10, 2026 07:28
@vercel

vercel Bot commented Jun 10, 2026

Copy link
Copy Markdown

@ritikraj2425 is attempting to deploy a commit to the deepset Team on Vercel.

A member of the Team first needs to authorize it.

@github-actions

Copy link
Copy Markdown
Contributor

Coverage report

Click to see where and how coverage changed

FileStatementsMissingCoverageCoverage
(new stmts)
Lines missing
  haystack/telemetry
  _telemetry.py
Project Total  

This report was generated by python-coverage-comment-action

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.

fix: telemetry decorator overwrites original function metadata

1 participant