Skip to content

Conversation

ecarrara
Copy link
Contributor

Change trace_to_thread method to retrieve the function name from the func attribute of the functools.partial instance.

partial objects are like function objects in that they are callable, weak referenceable, and can have attributes. There are some important differences. For instance, the name and function.doc attributes are not created automatically. Also, partial objects defined in classes behave like static methods and do not transform into bound methods during instance attribute look-up.
https://docs.python.org/3.12/library/functools.html#partial-objects

Fixes #2910

…hread

Change `trace_to_thread` method to retrieve the function name from the
`func` attribute of the `functools.partial` instance.

> partial objects are like function objects in that they are callable, weak
> referenceable, and can have attributes. There are some important differences.
> For instance, the __name__ and function.__doc__ attributes are not created
> automatically. Also, partial objects defined in classes behave like static
> methods and do not transform into bound methods during instance attribute
> look-up.
>
> Reference: https://docs.python.org/3.12/library/functools.html#partial-objects
@linux-foundation-easycla
Copy link

linux-foundation-easycla bot commented Oct 17, 2024

CLA Signed

The committers listed above are authorized under a signed CLA.

@ecarrara ecarrara requested a review from a team as a code owner October 17, 2024 12:54
@lzchen lzchen merged commit 5145a07 into open-telemetry:main Oct 24, 2024
536 checks passed
xrmx pushed a commit to xrmx/opentelemetry-python-contrib that referenced this pull request Jan 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

AttributeError: 'functools.partial' object has no attribute '__name__' in AsyncioInstrumentor.trace_to_thread

4 participants