Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions ddtrace/profiling/collector/_lock.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,8 +202,7 @@ def _flush_sample(self, start: int, end: int, is_acquire: bool) -> None:
# If we can't get the task frame, we use the caller frame.
# Call stack: 0: _flush_sample, 1: _acquire/_release, 2: acquire/release/__enter__/__exit__, 3: caller
frame: FrameType = task_frame or sys._getframe(3)
frames: List[DDFrame]
frames, _ = _traceback.pyframe_to_frames(frame, self.max_nframes)
frames: List[DDFrame] = _traceback.pyframe_to_frames(frame, self.max_nframes)
for ddframe in frames:
handle.push_frame(ddframe.function_name, ddframe.file_name, 0, ddframe.lineno)

Expand Down
2 changes: 1 addition & 1 deletion ddtrace/profiling/collector/_traceback.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ import typing

from .. import event

def pyframe_to_frames(frame: types.FrameType, max_nframes: int) -> typing.Tuple[typing.List[event.DDFrame], int]: ...
def pyframe_to_frames(frame: types.FrameType, max_nframes: int) -> typing.List[event.DDFrame]: ... # noqa: E302
Copy link
Contributor

Choose a reason for hiding this comment

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

Why did you have to add the noqa here? E302 is explained as

Expected {expected_blank_lines:?} blank lines, found {actual_blank_lines}

Can't we just fix it?

10 changes: 5 additions & 5 deletions ddtrace/profiling/collector/_traceback.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ cpdef pyframe_to_frames(frame, max_nframes):

:param frame: The frame object to serialize.
:param max_nframes: The maximum number of frames to return.
:return: The serialized frames and the number of frames present in the original traceback."""
:return: The serialized frames."""
# DEV: There are reports that Python 3.11 returns non-frame objects when
# retrieving frame objects and doing stack unwinding. If we detect a
# non-frame object we log a warning and return an empty stack, to avoid
Expand All @@ -23,7 +23,7 @@ cpdef pyframe_to_frames(frame, max_nframes):
log.warning(
"Got object of type '%s' instead of a frame object for the top frame of a thread", type(frame).__name__
)
return [], 0
return []

frames = []
nframes = 0
Expand All @@ -34,7 +34,7 @@ cpdef pyframe_to_frames(frame, max_nframes):
log.warning(
"Got object of type '%s' instead of a frame object during stack unwinding", type(frame).__name__
)
return [], 0
return []

if nframes < max_nframes:
code = frame.f_code
Expand All @@ -43,7 +43,7 @@ cpdef pyframe_to_frames(frame, max_nframes):
log.warning(
"Got object of type '%s' instead of a code object during stack unwinding", type(code).__name__
)
return [], 0
return []

lineno = 0 if frame.f_lineno is None else frame.f_lineno
IF PY_VERSION_HEX >= 0x030b0000:
Expand All @@ -52,4 +52,4 @@ cpdef pyframe_to_frames(frame, max_nframes):
frames.append(DDFrame(code.co_filename, lineno, code.co_name))
nframes += 1
frame = frame.f_back
return frames, nframes
return frames
1 change: 1 addition & 0 deletions ddtrace/profiling/collector/threading.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from __future__ import absolute_import

import threading
import typing
Copy link
Contributor

Choose a reason for hiding this comment

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

I guess this was part of the PR you already merged into main?


from ddtrace.internal._unpatched import _threading as ddtrace_threading
from ddtrace.internal.datadog.profiling import stack_v2
Expand Down
Loading