Skip to content

Commit

Permalink
refac(console): match span id earlier (#533)
Browse files Browse the repository at this point in the history
Just a simple refactoring to match and get span ID first. Then we don't need to
check it twice.

Also, align logs to use "id".

Signed-off-by: hi-rustin <rustin.liu@gmail.com>
  • Loading branch information
hi-rustin committed Mar 7, 2024
1 parent 5a4ca26 commit 5e64936
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions tokio-console/src/state/tasks.rs
Expand Up @@ -159,14 +159,18 @@ impl TasksState {

self.tasks
.insert_with(visibility, update.new_tasks, |ids, mut task| {
if task.id.is_none() {
tracing::warn!(?task, "skipping task with no id");
}
let span_id = match task.id.as_ref() {
Some(id) => id.id,
None => {
tracing::warn!(?task, "task has no id, skipping");
return None;
}
};

let meta_id = match task.metadata.as_ref() {
Some(id) => id.id,
None => {
tracing::warn!(?task, "task has no metadata ID, skipping");
tracing::warn!(?task, "task has no metadata id, skipping");
return None;
}
};
Expand Down Expand Up @@ -214,7 +218,6 @@ impl TasksState {
.collect::<Vec<_>>();

let formatted_fields = Field::make_formatted(styles, &mut fields);
let span_id = task.id?.id;

let stats = stats_update.remove(&span_id)?.into();
let location = format_location(task.location);
Expand Down

0 comments on commit 5e64936

Please sign in to comment.