|
1 | 1 | from collections import defaultdict
|
2 | 2 | from collections import deque
|
3 |
| -from pathlib import Path |
4 | 3 | from types import CodeType
|
5 | 4 | from types import FunctionType
|
6 | 5 | from types import ModuleType
|
|
24 | 23 | from ddtrace.internal.utils.inspection import collect_code_objects
|
25 | 24 | from ddtrace.internal.utils.inspection import functions_for_code
|
26 | 25 | from ddtrace.internal.utils.inspection import linenos
|
| 26 | +from ddtrace.internal.utils.inspection import resolved_code_origin |
27 | 27 | from ddtrace.internal.utils.inspection import undecorated
|
28 | 28 |
|
29 | 29 |
|
@@ -209,7 +209,7 @@ def _collect_functions(module: ModuleType) -> Dict[str, _FunctionCodePair]:
|
209 | 209 |
|
210 | 210 | for name in (k, local_name) if isinstance(k, str) and k != local_name else (local_name,):
|
211 | 211 | fullname = ".".join((c.__fullname__, name)) if c.__fullname__ else name
|
212 |
| - if fullname not in functions or Path(code.co_filename).resolve() == path: |
| 212 | + if fullname not in functions or resolved_code_origin(code) == path: |
213 | 213 | # Give precedence to code objects from the module and
|
214 | 214 | # try to retrieve any potentially decorated function so
|
215 | 215 | # that we don't end up returning the decorator function
|
@@ -285,7 +285,7 @@ def __init__(self, module: ModuleType) -> None:
|
285 | 285 |
|
286 | 286 | if (
|
287 | 287 | function not in seen_functions
|
288 |
| - and Path(cast(FunctionType, function).__code__.co_filename).resolve() == module_path |
| 288 | + and resolved_code_origin(cast(FunctionType, function).__code__) == module_path |
289 | 289 | ):
|
290 | 290 | # We only map line numbers for functions that actually belong to
|
291 | 291 | # the module.
|
@@ -342,7 +342,7 @@ def _resolve_pair(self, pair: _FunctionCodePair, fullname: str) -> FullyNamedFun
|
342 | 342 |
|
343 | 343 | code = pair.code
|
344 | 344 | assert code is not None # nosec
|
345 |
| - f = undecorated(cast(FunctionType, target), cast(str, part), Path(code.co_filename).resolve()) |
| 345 | + f = undecorated(cast(FunctionType, target), cast(str, part), resolved_code_origin(code)) |
346 | 346 | if not (isinstance(f, FunctionType) and f.__code__ is code):
|
347 | 347 | raise e
|
348 | 348 |
|
|
0 commit comments