fix: preserve telemetry function metadata with functools.wraps#11617
Closed
santino18727-debug wants to merge 1 commit into
Closed
fix: preserve telemetry function metadata with functools.wraps#11617santino18727-debug wants to merge 1 commit into
functools.wraps#11617santino18727-debug wants to merge 1 commit into
Conversation
…et-ai#11568) The `send_telemetry` decorator did not use `functools.wraps`, so decorated functions lost their `__name__`, `__doc__`, and `__annotations__`. The old `# FIXME` comment claimed `functools.wraps` made `telemetry` "out of scope", but the global `telemetry` is resolved at call time, not decoration time, so wrapping is safe. Add `functools.wraps`, import `functools`, and drop the FIXME.
|
@santino18727-debug is attempting to deploy a commit to the deepset Team on Vercel. A member of the Team first needs to authorize it. |
Member
|
Thank you for opening this PR @santino18727-debug . There was already another PR open that addresses the same issue and that one got merged now. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Related Issues
Fixes #11568
Proposed Changes
The
send_telemetrydecorator wrapped functions likepipeline_runningandtutorial_runningwithoutfunctools.wraps, so the decorated functions lost their original metadata (__name__,__doc__,__annotations__). This makes stack traces and generated API docs confusing.The old
# FIXMEcomment claimed thatfunctools.wrapsput the globaltelemetryobject "out of scope". That concern is incorrect: the global is resolved at call time, not at decoration time. (The original author most likely hit aNameErrorbecausefunctoolswas not imported.)This change imports
functools, applies@functools.wraps(func)to the wrapper, and removes the obsolete comment.How did you test it?
Added a unit test asserting
pipeline_running.__name__and__doc__are preserved. Existing telemetry tests pass.Notes for the reviewer
Includes a release note. Prepared with the assistance of an AI agent; reviewed and verified locally (tests +
ruff).