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
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ class ThreadInfo
};

private:
void render_unwound_stacks(EchionSampler&);
[[nodiscard]] Result<void> unwind_tasks(EchionSampler&, PyThreadState*);
void unwind_greenlets(EchionSampler&, PyThreadState*, unsigned long);
[[nodiscard]] Result<std::vector<TaskInfo::Ptr>> get_all_tasks(EchionSampler&, PyThreadState* tstate);
Expand Down
34 changes: 21 additions & 13 deletions ddtrace/internal/datadog/profiling/stack/src/echion/threads.cc
Original file line number Diff line number Diff line change
Expand Up @@ -708,21 +708,10 @@ ThreadInfo::unwind_greenlets(EchionSampler& echion, PyThreadState* tstate, unsig
}

// ----------------------------------------------------------------------------
Result<void>
ThreadInfo::sample(EchionSampler& echion, PyThreadState* tstate, microsecond_t delta)
void
ThreadInfo::render_unwound_stacks(EchionSampler& echion)
{
auto& renderer = echion.renderer();
renderer.render_thread_begin(tstate, name, delta, thread_id, native_id);

microsecond_t previous_cpu_time = cpu_time;
auto update_cpu_time_success = update_cpu_time();
if (!update_cpu_time_success) {
return ErrorKind::CpuTimeError;
}

renderer.render_cpu_time(cpu_time - previous_cpu_time);

this->unwind(echion, tstate);

// Render in this order of priority
// 1. asyncio Tasks stacks (if any)
Expand Down Expand Up @@ -755,6 +744,25 @@ ThreadInfo::sample(EchionSampler& echion, PyThreadState* tstate, microsecond_t d
python_stack.render(echion);
renderer.render_stack_end();
}
}

// ----------------------------------------------------------------------------
Result<void>
ThreadInfo::sample(EchionSampler& echion, PyThreadState* tstate, microsecond_t delta)
{
auto& renderer = echion.renderer();
renderer.render_thread_begin(tstate, name, delta, thread_id, native_id);

microsecond_t previous_cpu_time = cpu_time;
auto update_cpu_time_success = update_cpu_time();
if (!update_cpu_time_success) {
return ErrorKind::CpuTimeError;
}

renderer.render_cpu_time(cpu_time - previous_cpu_time);

this->unwind(echion, tstate);
this->render_unwound_stacks(echion);

return Result<void>::ok();
}
Expand Down
Loading