Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(console): surface dropped events if there are any #316

Merged
merged 6 commits into from
Apr 12, 2022
Merged
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
19 changes: 19 additions & 0 deletions tokio-console/src/main.rs
Original file line number Diff line number Diff line change
@@ -126,6 +126,25 @@ async fn main() -> color_eyre::Result<()> {
.0
.push(Span::styled(" PAUSED", view.styles.fg(Color::Red)));
}
let dropped_async_ops_state = state.async_ops_state().dropped_events();
let dropped_tasks_state = state.tasks_state().dropped_events();
let dropped_resources_state = state.resources_state().dropped_events();
if (dropped_async_ops_state + dropped_tasks_state + dropped_resources_state) > 0 {
let mut dropped_texts = vec![];
if dropped_async_ops_state > 0 {
dropped_texts.push(format!("{} async_ops", dropped_async_ops_state))
}
if dropped_tasks_state > 0 {
dropped_texts.push(format!("{} tasks", dropped_tasks_state))
}
if dropped_resources_state > 0 {
dropped_texts.push(format!("{} resources", dropped_resources_state))
}
header_text.0.push(Span::styled(
format!(" dropped: {}", dropped_texts.join(", ")),
view.styles.fg(Color::Red),
));
}
let header = Paragraph::new(header_text).wrap(Wrap { trim: true });
let view_controls = Paragraph::new(Spans::from(vec![
Span::raw("views: "),
7 changes: 7 additions & 0 deletions tokio-console/src/state/async_ops.rs
Original file line number Diff line number Diff line change
@@ -18,6 +18,7 @@ pub(crate) struct AsyncOpsState {
async_ops: HashMap<u64, Rc<RefCell<AsyncOp>>>,
ids: Ids,
new_async_ops: Vec<AsyncOpRef>,
dropped_events: u64,
}

#[derive(Debug, Copy, Clone)]
@@ -201,6 +202,8 @@ impl AsyncOpsState {
}
}
}

self.dropped_events += update.dropped_events;
}

pub(crate) fn retain_active(&mut self, now: SystemTime, retain_for: Duration) {
@@ -217,6 +220,10 @@ impl AsyncOpsState {
.unwrap_or(true)
})
}

pub(crate) fn dropped_events(&self) -> u64 {
self.dropped_events
}
}

impl AsyncOp {
4 changes: 4 additions & 0 deletions tokio-console/src/state/mod.rs
Original file line number Diff line number Diff line change
@@ -200,6 +200,10 @@ impl State {
&mut self.tasks_state
}

pub(crate) fn resources_state(&mut self) -> &ResourcesState {
&self.resources_state
}

pub(crate) fn resources_state_mut(&mut self) -> &mut ResourcesState {
&mut self.resources_state
}
7 changes: 7 additions & 0 deletions tokio-console/src/state/resources.rs
Original file line number Diff line number Diff line change
@@ -16,6 +16,7 @@ pub(crate) struct ResourcesState {
resources: HashMap<u64, Rc<RefCell<Resource>>>,
pub(crate) ids: Ids,
new_resources: Vec<ResourceRef>,
dropped_events: u64,
}

#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd)]
@@ -225,6 +226,8 @@ impl ResourcesState {
Some((num, resource))
});

self.dropped_events += update.dropped_events;

self.resources.extend(new_resources);

for (span_id, stats) in stats_update {
@@ -252,6 +255,10 @@ impl ResourcesState {
.unwrap_or(true)
})
}

pub(crate) fn dropped_events(&self) -> u64 {
self.dropped_events
}
}

impl Resource {
7 changes: 7 additions & 0 deletions tokio-console/src/state/tasks.rs
Original file line number Diff line number Diff line change
@@ -22,6 +22,7 @@ pub(crate) struct TasksState {
pub(crate) ids: Ids,
new_tasks: Vec<TaskRef>,
pub(crate) linters: Vec<Linter<Task>>,
dropped_events: u64,
}

#[derive(Debug, Default)]
@@ -197,6 +198,8 @@ impl TasksState {
task.lint(linters);
}
}

self.dropped_events += update.dropped_events;
}

pub(crate) fn retain_active(&mut self, now: SystemTime, retain_for: Duration) {
@@ -220,6 +223,10 @@ impl TasksState {
pub(crate) fn task(&self, id: u64) -> Option<TaskRef> {
self.tasks.get(&id).map(Rc::downgrade)
}

pub(crate) fn dropped_events(&self) -> u64 {
self.dropped_events
}
}

impl Details {