diff --git a/pageserver/benches/bench_ingest.rs b/pageserver/benches/bench_ingest.rs index b1103948d6..272c3e2338 100644 --- a/pageserver/benches/bench_ingest.rs +++ b/pageserver/benches/bench_ingest.rs @@ -57,7 +57,8 @@ async fn ingest( tokio::fs::create_dir_all(conf.timeline_path(&tenant_shard_id, &timeline_id)).await?; - let ctx = RequestContext::new(TaskKind::DebugTool, DownloadBehavior::Error); + let ctx = + RequestContext::new(TaskKind::DebugTool, DownloadBehavior::Error).with_scope_debug_tools(); let gate = utils::sync::gate::Gate::default(); diff --git a/pageserver/ctl/src/layer_map_analyzer.rs b/pageserver/ctl/src/layer_map_analyzer.rs index b426f977cf..c49c8b58df 100644 --- a/pageserver/ctl/src/layer_map_analyzer.rs +++ b/pageserver/ctl/src/layer_map_analyzer.rs @@ -131,7 +131,8 @@ async fn get_holes(path: &Utf8Path, max_holes: usize, ctx: &RequestContext) -> R pub(crate) async fn main(cmd: &AnalyzeLayerMapCmd) -> Result<()> { let storage_path = &cmd.path; let max_holes = cmd.max_holes.unwrap_or(DEFAULT_MAX_HOLES); - let ctx = RequestContext::new(TaskKind::DebugTool, DownloadBehavior::Error); + let ctx = + RequestContext::new(TaskKind::DebugTool, DownloadBehavior::Error).with_scope_debug_tools(); // Initialize virtual_file (file desriptor cache) and page cache which are needed to access layer persistent B-Tree. pageserver::virtual_file::init( diff --git a/pageserver/ctl/src/layers.rs b/pageserver/ctl/src/layers.rs index 05fb35ff09..293c01eff0 100644 --- a/pageserver/ctl/src/layers.rs +++ b/pageserver/ctl/src/layers.rs @@ -76,7 +76,8 @@ async fn read_image_file(path: impl AsRef, ctx: &RequestContext) -> Result } pub(crate) async fn main(cmd: &LayerCmd) -> Result<()> { - let ctx = RequestContext::new(TaskKind::DebugTool, DownloadBehavior::Error); + let ctx = + RequestContext::new(TaskKind::DebugTool, DownloadBehavior::Error).with_scope_debug_tools(); match cmd { LayerCmd::List { path } => { for tenant in fs::read_dir(path.join(TENANTS_SEGMENT_NAME))? { @@ -176,7 +177,8 @@ pub(crate) async fn main(cmd: &LayerCmd) -> Result<()> { ); pageserver::page_cache::init(100); - let ctx = RequestContext::new(TaskKind::DebugTool, DownloadBehavior::Error); + let ctx = RequestContext::new(TaskKind::DebugTool, DownloadBehavior::Error) + .with_scope_debug_tools(); macro_rules! rewrite_closure { ($($summary_ty:tt)*) => {{ diff --git a/pageserver/ctl/src/main.rs b/pageserver/ctl/src/main.rs index 72a120a69b..1d81b839a8 100644 --- a/pageserver/ctl/src/main.rs +++ b/pageserver/ctl/src/main.rs @@ -208,7 +208,8 @@ async fn print_layerfile(path: &Utf8Path) -> anyhow::Result<()> { virtual_file::SyncMode::Sync, ); page_cache::init(100); - let ctx = RequestContext::new(TaskKind::DebugTool, DownloadBehavior::Error); + let ctx = + RequestContext::new(TaskKind::DebugTool, DownloadBehavior::Error).with_scope_debug_tools(); dump_layerfile_from_path(path, true, &ctx).await } diff --git a/pageserver/src/context.rs b/pageserver/src/context.rs index e2a84d0c24..d2caf030df 100644 --- a/pageserver/src/context.rs +++ b/pageserver/src/context.rs @@ -134,6 +134,9 @@ pub(crate) enum Scope { UnitTest { io_size_metrics: &'static crate::metrics::StorageIoSizeMetrics, }, + DebugTools { + io_size_metrics: &'static crate::metrics::StorageIoSizeMetrics, + }, } static GLOBAL_IO_SIZE_METRICS: Lazy = @@ -195,6 +198,12 @@ impl Scope { io_size_metrics: &GLOBAL_IO_SIZE_METRICS, } } + + pub(crate) fn new_debug_tools() -> Self { + Scope::DebugTools { + io_size_metrics: &GLOBAL_IO_SIZE_METRICS, + } + } } /// The kind of access to the page cache. @@ -435,6 +444,12 @@ impl RequestContext { .build() } + pub fn with_scope_debug_tools(&self) -> Self { + RequestContextBuilder::new(TaskKind::DebugTool) + .scope(Scope::new_debug_tools()) + .build() + } + pub fn task_kind(&self) -> TaskKind { self.task_kind } @@ -486,6 +501,7 @@ impl RequestContext { Scope::SecondaryTenant { io_size_metrics } => io_size_metrics, #[cfg(test)] Scope::UnitTest { io_size_metrics } => io_size_metrics, + Scope::DebugTools { io_size_metrics } => io_size_metrics, } } }