From a7ad080961bf02e885f49e995b826ec0b5cc8e50 Mon Sep 17 00:00:00 2001 From: John Spray Date: Thu, 3 Aug 2023 09:53:38 +0100 Subject: [PATCH] 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. --- pageserver/src/tenant.rs | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/pageserver/src/tenant.rs b/pageserver/src/tenant.rs index 9fd6005330..adb3e86ffd 100644 --- a/pageserver/src/tenant.rs +++ b/pageserver/src/tenant.rs @@ -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,