pageserver: remove bare tokio::spawn

Commit ddb9c2fe9 added this task, which is launched
with tokio::spawn rather than task_mgr::spawn, and is
not wrapped in a tracing Instrumented<>.

While the task doesn't overtly do any logging, for
consistency we should spawn all our tasks via the wrapper: in
future this task might be extended to e.g. emit log lines that
we would expect to have the proper tracing spans.
This commit is contained in:
John Spray
2023-08-03 09:53:38 +01:00
parent df49a9b7aa
commit a7ad080961

View File

@@ -2076,7 +2076,14 @@ impl Tenant {
) -> Tenant {
let (state, mut rx) = watch::channel(state);
tokio::spawn(async move {
task_mgr::spawn(
task_mgr::BACKGROUND_RUNTIME.handle(),
TaskKind::MetricsCollection,
Some(tenant_id),
None,
&format!("state metrics collector for tenant {tenant_id}"),
false,
async move {
let tid = tenant_id.to_string();
fn inspect_state(state: &TenantState) -> ([&'static str; 1], bool) {
@@ -2126,7 +2133,10 @@ impl Tenant {
.inc();
}
}
});
Ok(())
}
.instrument(info_span!("state_metrics", tenant_id = %tenant_id)),
);
Tenant {
tenant_id,