pub struct Inspector { /* private fields */ }Expand description
Main inspector for tracking async execution
Implementations§
Source§impl Inspector
impl Inspector
Sourcepub fn is_enabled(&self) -> bool
pub fn is_enabled(&self) -> bool
Check if the inspector is enabled
Sourcepub fn register_task(&self, name: String) -> TaskId
pub fn register_task(&self, name: String) -> TaskId
Register a new task
Sourcepub fn register_child_task(&self, name: String, parent_id: TaskId) -> TaskId
pub fn register_child_task(&self, name: String, parent_id: TaskId) -> TaskId
Register a child task with a parent
Sourcepub fn register_task_with_info(&self, task: TaskInfo) -> TaskId
pub fn register_task_with_info(&self, task: TaskInfo) -> TaskId
Register a task with additional metadata
Sourcepub fn update_task_state(&self, task_id: TaskId, new_state: TaskState)
pub fn update_task_state(&self, task_id: TaskId, new_state: TaskState)
Update task state
Sourcepub fn poll_started(&self, task_id: TaskId)
pub fn poll_started(&self, task_id: TaskId)
Record a poll start
Sourcepub fn poll_ended(&self, task_id: TaskId, duration: Duration)
pub fn poll_ended(&self, task_id: TaskId, duration: Duration)
Record a poll end
Sourcepub fn await_started(
&self,
task_id: TaskId,
await_point: String,
location: Option<String>,
)
pub fn await_started( &self, task_id: TaskId, await_point: String, location: Option<String>, )
Record an await start
Sourcepub fn await_ended(
&self,
task_id: TaskId,
await_point: String,
duration: Duration,
)
pub fn await_ended( &self, task_id: TaskId, await_point: String, duration: Duration, )
Record an await end
Sourcepub fn task_completed(&self, task_id: TaskId)
pub fn task_completed(&self, task_id: TaskId)
Mark task as completed
Sourcepub fn task_failed(&self, task_id: TaskId, error: Option<String>)
pub fn task_failed(&self, task_id: TaskId, error: Option<String>)
Mark task as failed
Sourcepub fn inspection_point(
&self,
task_id: TaskId,
label: String,
message: Option<String>,
)
pub fn inspection_point( &self, task_id: TaskId, label: String, message: Option<String>, )
Record an inspection point
Sourcepub fn get_all_tasks(&self) -> Vec<TaskInfo>
pub fn get_all_tasks(&self) -> Vec<TaskInfo>
Get all tasks
Sourcepub fn get_tasks_filtered(&self, filter: &TaskFilter) -> Vec<TaskInfo>
pub fn get_tasks_filtered(&self, filter: &TaskFilter) -> Vec<TaskInfo>
Get tasks matching a filter
§Example
use async_inspect::{Inspector, task::{TaskFilter, TaskState}};
use std::time::Duration;
let inspector = Inspector::new();
// Find all running tasks with "fetch" in the name
let filter = TaskFilter::new()
.with_state(TaskState::Running)
.with_name_pattern("fetch");
let tasks = inspector.get_tasks_filtered(&filter);Sourcepub fn get_tasks_sorted(
&self,
filter: &TaskFilter,
sort_by: TaskSortBy,
direction: SortDirection,
) -> Vec<TaskInfo>
pub fn get_tasks_sorted( &self, filter: &TaskFilter, sort_by: TaskSortBy, direction: SortDirection, ) -> Vec<TaskInfo>
Get tasks matching a filter, sorted by the given criteria
§Example
use async_inspect::{Inspector, task::{TaskFilter, TaskState, TaskSortBy, SortDirection}};
let inspector = Inspector::new();
// Get blocked tasks sorted by age (oldest first)
let filter = TaskFilter::new().with_state(TaskState::Blocked { await_point: String::new() });
let tasks = inspector.get_tasks_sorted(&filter, TaskSortBy::Age, SortDirection::Descending);Sourcepub fn get_running_tasks(&self) -> Vec<TaskInfo>
pub fn get_running_tasks(&self) -> Vec<TaskInfo>
Get running tasks
Sourcepub fn get_blocked_tasks(&self) -> Vec<TaskInfo>
pub fn get_blocked_tasks(&self) -> Vec<TaskInfo>
Get blocked tasks
Sourcepub fn get_long_running_tasks(&self, min_duration: Duration) -> Vec<TaskInfo>
pub fn get_long_running_tasks(&self, min_duration: Duration) -> Vec<TaskInfo>
Get long-running tasks (older than the specified duration)
Sourcepub fn get_root_tasks(&self) -> Vec<TaskInfo>
pub fn get_root_tasks(&self) -> Vec<TaskInfo>
Get root tasks (tasks without a parent)
Sourcepub fn get_child_tasks(&self, parent_id: TaskId) -> Vec<TaskInfo>
pub fn get_child_tasks(&self, parent_id: TaskId) -> Vec<TaskInfo>
Get child tasks of a specific parent
Sourcepub fn get_events(&self) -> Vec<Event>
pub fn get_events(&self) -> Vec<Event>
Get all events
Sourcepub fn get_task_events(&self, task_id: TaskId) -> Vec<Event>
pub fn get_task_events(&self, task_id: TaskId) -> Vec<Event>
Get events for a specific task
Sourcepub fn build_profiler(&self) -> Profiler
pub fn build_profiler(&self) -> Profiler
Build a performance profiler from collected data
Sourcepub fn stats(&self) -> InspectorStats
pub fn stats(&self) -> InspectorStats
Get statistics
Sourcepub fn deadlock_detector(&self) -> &DeadlockDetector
pub fn deadlock_detector(&self) -> &DeadlockDetector
Get the deadlock detector
Returns a reference to the integrated deadlock detector for resource tracking and deadlock analysis.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Inspector
impl !RefUnwindSafe for Inspector
impl Send for Inspector
impl Sync for Inspector
impl Unpin for Inspector
impl !UnwindSafe for Inspector
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
Source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more