Skip to content

Commit

Permalink
Added convention for naming tasks
Browse files Browse the repository at this point in the history
  • Loading branch information
fulmicoton committed Jan 25, 2024
1 parent 6141450 commit 79c6e27
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 5 deletions.
2 changes: 1 addition & 1 deletion quickwit/quickwit-actors/src/scheduler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ pub fn start_scheduler() -> SchedulerClient {
}
}
},
"Scheduler",
"scheduler",
);
scheduler_client
}
Expand Down
3 changes: 0 additions & 3 deletions quickwit/quickwit-common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,7 @@ tracing = { workspace = true }
testsuite = []
named_tasks = ["tokio/tracing"]



[dev-dependencies]
serde_json = { workspace = true }
tempfile = { workspace = true }

quickwit-macros = { workspace = true }
20 changes: 20 additions & 0 deletions quickwit/quickwit-common/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,26 @@ pub const fn div_ceil(lhs: i64, rhs: i64) -> i64 {
}
}


// The following are helpers to build named tasks.
//
// Named tasks require the tokio feature `tracing` to be enabled.
// If the `named_tasks` feature is disabled, this is no-op.
//
// By default, these function will just ignore the name passed and just act
// like a regular call to `tokio::spawn`.
//
// If the user compiles `quickwit-cli` with the `tokio-console` feature,
// then tasks will automatically be named. This is not just "visual sugar".
//
// Without names, tasks will only show their spawn site on tokio-console.
// This is a catastrophy for actors who all share the same spawn site.
//
// # Naming
//
// Actors will get named after their type, which is fine.
// For other tasks, please use `snake_case`.

#[cfg(not(feature = "named_tasks"))]
pub fn spawn_named_task<F>(future: F, _name: &'static str) -> tokio::task::JoinHandle<F::Output>
where
Expand Down
2 changes: 1 addition & 1 deletion quickwit/quickwit-indexing/src/actors/uploader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@ impl Handler<PackagedSplitBatch> for Uploader {
Result::<(), anyhow::Error>::Ok(())
}
.instrument(Span::current()),
"upload-single-task"
"upload_single_task"
);
fail_point!("uploader:intask:after");
Ok(())
Expand Down

0 comments on commit 79c6e27

Please sign in to comment.