Skip to content
Merged
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
20 changes: 20 additions & 0 deletions ddtrace/internal/datadog/profiling/stack_v2/src/stack_v2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,10 @@ stack_v2_thread_register(PyObject* self, PyObject* args)
return NULL;
}

Py_BEGIN_ALLOW_THREADS;
Sampler::get().register_thread(id, native_id, name);
Py_END_ALLOW_THREADS;

Py_RETURN_NONE;
}

Expand All @@ -87,8 +90,11 @@ stack_v2_thread_unregister(PyObject* self, PyObject* args)
return NULL;
}

Py_BEGIN_ALLOW_THREADS;
Sampler::get().unregister_thread(id);
ThreadSpanLinks::get_instance().unlink_span(id);
Py_END_ALLOW_THREADS;

Py_RETURN_NONE;
}

Expand Down Expand Up @@ -122,7 +128,9 @@ _stack_v2_link_span(PyObject* self, PyObject* args, PyObject* kwargs)
span_type = empty_string.c_str();
}

Py_BEGIN_ALLOW_THREADS;
ThreadSpanLinks::get_instance().link_span(thread_id, span_id, local_root_span_id, std::string(span_type));
Py_END_ALLOW_THREADS;

Py_RETURN_NONE;
}
Expand All @@ -140,7 +148,9 @@ stack_v2_track_asyncio_loop(PyObject* self, PyObject* args)
return NULL;
}

Py_BEGIN_ALLOW_THREADS;
Sampler::get().track_asyncio_loop(thread_id, loop);
Py_END_ALLOW_THREADS;

Py_RETURN_NONE;
}
Expand Down Expand Up @@ -172,7 +182,9 @@ stack_v2_link_tasks(PyObject* self, PyObject* args)
return NULL;
}

Py_BEGIN_ALLOW_THREADS;
Sampler::get().link_tasks(parent, child);
Py_END_ALLOW_THREADS;

Py_RETURN_NONE;
}
Expand Down Expand Up @@ -211,7 +223,9 @@ track_greenlet(PyObject* Py_UNUSED(m), PyObject* args)
return NULL;
}

Py_BEGIN_ALLOW_THREADS;
Sampler::get().track_greenlet(greenlet_id, greenlet_name, frame);
Py_END_ALLOW_THREADS;

Py_RETURN_NONE;
}
Expand All @@ -223,7 +237,9 @@ untrack_greenlet(PyObject* Py_UNUSED(m), PyObject* args)
if (!PyArg_ParseTuple(args, "l", &greenlet_id))
return NULL;

Py_BEGIN_ALLOW_THREADS;
Sampler::get().untrack_greenlet(greenlet_id);
Py_END_ALLOW_THREADS;

Py_RETURN_NONE;
}
Expand All @@ -236,7 +252,9 @@ link_greenlets(PyObject* Py_UNUSED(m), PyObject* args)
if (!PyArg_ParseTuple(args, "ll", &child, &parent))
return NULL;

Py_BEGIN_ALLOW_THREADS;
Sampler::get().link_greenlets(parent, child);
Py_END_ALLOW_THREADS;

Py_RETURN_NONE;
}
Expand All @@ -250,7 +268,9 @@ update_greenlet_frame(PyObject* Py_UNUSED(m), PyObject* args)
if (!PyArg_ParseTuple(args, "lO", &greenlet_id, &frame))
return NULL;

Py_BEGIN_ALLOW_THREADS;
Sampler::get().update_greenlet_frame(greenlet_id, frame);
Py_END_ALLOW_THREADS;

Py_RETURN_NONE;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
fixes:
- |
Profiling: prevent potential deadlocks with thread pools.
Loading