Skip to content
Closed
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
13 changes: 13 additions & 0 deletions ddtrace/internal/_threads.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ typedef struct periodic_thread
double interval;
PyObject* name;
PyObject* ident;
PyObject* native_id;

PyObject* _target;
PyObject* _on_shutdown;
Expand Down Expand Up @@ -159,6 +160,7 @@ static PyMemberDef PeriodicThread_members[] = {

{ "name", T_OBJECT_EX, offsetof(PeriodicThread, name), 0, "thread name" },
{ "ident", T_OBJECT_EX, offsetof(PeriodicThread, ident), 0, "thread ID" },
{ "native_id", T_OBJECT_EX, offsetof(PeriodicThread, native_id), 0, "thread native ID" },

{ "_ddtrace_profiling_ignore",
T_OBJECT_EX,
Expand Down Expand Up @@ -189,6 +191,9 @@ PeriodicThread_init(PeriodicThread* self, PyObject* args, PyObject* kwargs)
Py_INCREF(Py_None);
self->ident = Py_None;

Py_INCREF(Py_None);
self->native_id = Py_None;

Py_INCREF(Py_True);
self->_ddtrace_profiling_ignore = Py_True;

Expand Down Expand Up @@ -257,6 +262,13 @@ PeriodicThread_start(PeriodicThread* self, PyObject* args)
Py_DECREF(self->ident);
self->ident = PyLong_FromLong((long)PyThreadState_Get()->thread_id);

Py_DECREF(self->native_id);
#if PY_VERSION_HEX >= 0x030b0000
self->native_id = PyLong_FromLong((long)PyThreadState_Get()->native_thread_id);
#else // PY_VERSION_HEX < 0x030b0000
self->native_id = PyLong_FromLong((long)PyThread_get_thread_native_id());
#endif // PY_VERSION_HEX >= 0x030b0000

// Map the PeriodicThread object to its thread ID
PyDict_SetItem(_periodic_threads, self->ident, (PyObject*)self);
}
Expand Down Expand Up @@ -469,6 +481,7 @@ PeriodicThread_dealloc(PeriodicThread* self)
Py_XDECREF(self->_on_shutdown);

Py_XDECREF(self->ident);
Py_XDECREF(self->native_id);
Py_XDECREF(self->_ddtrace_profiling_ignore);

self->_thread = nullptr;
Expand Down
1 change: 1 addition & 0 deletions ddtrace/internal/_threads.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import typing as t
class PeriodicThread:
name: str
ident: int
native_id: int
interval: float

def __init__(
Expand Down
3 changes: 0 additions & 3 deletions tests/profiling_v2/collector/test_stack.py
Original file line number Diff line number Diff line change
Expand Up @@ -664,9 +664,6 @@ def test_max_time_usage_over():
[True, False],
)
def test_ignore_profiler(stack_v2_enabled, ignore_profiler, tmp_path):
if stack_v2_enabled:
pytest.xfail("Echion doesn't support ignore_profiler yet, and the test flakes")

test_name = "test_ignore_profiler"
pprof_prefix = str(tmp_path / test_name)
output_filename = pprof_prefix + "." + str(os.getpid())
Expand Down
Loading