Skip to content

Commit

Permalink
fix(console): fix task lookup in async ops view (#257)
Browse files Browse the repository at this point in the history
#244 moved rewriting of ids to the console. We have however forgot to look up
the pretty ID when trying to figure out which task is running a particular async op.
The result of that was that we were displaying the raw ID for the task and we were
not able to properly resolve the name of the task if specified.


Before: 
<img width="838" alt="Screenshot 2022-01-09 at 19 52 27" src="https://user-images.githubusercontent.com/4391506/148694237-1d9b995c-a99a-42d8-865d-2af638524582.png">

After: 
<img width="861" alt="Screenshot 2022-01-09 at 19 53 24" src="https://user-images.githubusercontent.com/4391506/148694247-9af70d61-6b8b-4bca-bdcb-63c1a0a334f9.png">

Signed-off-by: Zahari Dichev <[email protected]>
  • Loading branch information
zaharidichev authored Jan 10, 2022
1 parent 4ec26a8 commit 9a50b63
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
19 changes: 15 additions & 4 deletions console/src/state/async_ops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,13 +119,17 @@ impl AsyncOpsState {
self.async_ops.values().map(Rc::downgrade)
}

// Clippy warns us that having too many arguments is bad style. In this case, however
// it does not make much sense to group any of them.
#[allow(clippy::too_many_arguments)]
pub(crate) fn update_async_ops(
&mut self,
styles: &view::Styles,
strings: &mut intern::Strings,
metas: &HashMap<u64, Metadata>,
update: proto::async_ops::AsyncOpUpdate,
resource_ids: &mut Ids,
task_ids: &mut Ids,
visibility: Visibility,
) {
let mut stats_update = update.stats_update;
Expand Down Expand Up @@ -155,8 +159,13 @@ impl AsyncOpsState {
};

let span_id = async_op.id?.id;
let stats =
AsyncOpStats::from_proto(stats_update.remove(&span_id)?, meta, styles, strings);
let stats = AsyncOpStats::from_proto(
stats_update.remove(&span_id)?,
meta,
styles,
strings,
task_ids,
);

let num = self.ids.id_for(span_id);
let resource_id = resource_ids.id_for(async_op.resource_id?.id);
Expand Down Expand Up @@ -187,7 +196,8 @@ impl AsyncOpsState {
if let Some(async_op) = self.async_ops.get_mut(&num) {
let mut async_op = async_op.borrow_mut();
if let Some(meta) = metas.get(&async_op.meta_id) {
async_op.stats = AsyncOpStats::from_proto(stats, meta, styles, strings);
async_op.stats =
AsyncOpStats::from_proto(stats, meta, styles, strings, task_ids);
}
}
}
Expand Down Expand Up @@ -275,6 +285,7 @@ impl AsyncOpStats {
meta: &Metadata,
styles: &view::Styles,
strings: &mut intern::Strings,
task_ids: &mut Ids,
) -> Self {
let mut pb = pb;

Expand Down Expand Up @@ -304,7 +315,7 @@ impl AsyncOpStats {
let busy = poll_stats.busy_time.map(pb_duration).unwrap_or_default();
let idle = total.map(|total| total - busy);
let formatted_attributes = Attribute::make_formatted(styles, &mut attributes);
let task_id = pb.task_id.map(|id| id.id);
let task_id = pb.task_id.map(|id| task_ids.id_for(id.id));
let task_id_str = strings.string(
task_id
.as_ref()
Expand Down
1 change: 1 addition & 0 deletions console/src/state/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ impl State {
&self.metas,
async_ops_update,
&mut self.resources_state.ids,
&mut self.tasks_state.ids,
visibility,
)
}
Expand Down

0 comments on commit 9a50b63

Please sign in to comment.