Skip to content

Commit 9a50b63

Browse files
authored
fix(console): fix task lookup in async ops view (#257)
#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]>
1 parent 4ec26a8 commit 9a50b63

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

console/src/state/async_ops.rs

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -119,13 +119,17 @@ impl AsyncOpsState {
119119
self.async_ops.values().map(Rc::downgrade)
120120
}
121121

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

157161
let span_id = async_op.id?.id;
158-
let stats =
159-
AsyncOpStats::from_proto(stats_update.remove(&span_id)?, meta, styles, strings);
162+
let stats = AsyncOpStats::from_proto(
163+
stats_update.remove(&span_id)?,
164+
meta,
165+
styles,
166+
strings,
167+
task_ids,
168+
);
160169

161170
let num = self.ids.id_for(span_id);
162171
let resource_id = resource_ids.id_for(async_op.resource_id?.id);
@@ -187,7 +196,8 @@ impl AsyncOpsState {
187196
if let Some(async_op) = self.async_ops.get_mut(&num) {
188197
let mut async_op = async_op.borrow_mut();
189198
if let Some(meta) = metas.get(&async_op.meta_id) {
190-
async_op.stats = AsyncOpStats::from_proto(stats, meta, styles, strings);
199+
async_op.stats =
200+
AsyncOpStats::from_proto(stats, meta, styles, strings, task_ids);
191201
}
192202
}
193203
}
@@ -275,6 +285,7 @@ impl AsyncOpStats {
275285
meta: &Metadata,
276286
styles: &view::Styles,
277287
strings: &mut intern::Strings,
288+
task_ids: &mut Ids,
278289
) -> Self {
279290
let mut pb = pb;
280291

@@ -304,7 +315,7 @@ impl AsyncOpStats {
304315
let busy = poll_stats.busy_time.map(pb_duration).unwrap_or_default();
305316
let idle = total.map(|total| total - busy);
306317
let formatted_attributes = Attribute::make_formatted(styles, &mut attributes);
307-
let task_id = pb.task_id.map(|id| id.id);
318+
let task_id = pb.task_id.map(|id| task_ids.id_for(id.id));
308319
let task_id_str = strings.string(
309320
task_id
310321
.as_ref()

console/src/state/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,7 @@ impl State {
166166
&self.metas,
167167
async_ops_update,
168168
&mut self.resources_state.ids,
169+
&mut self.tasks_state.ids,
169170
visibility,
170171
)
171172
}

0 commit comments

Comments
 (0)