diff --git a/src/internal_telemetry/allocations/mod.rs b/src/internal_telemetry/allocations/mod.rs index 6cbd433b00b62..b34c40d136d0c 100644 --- a/src/internal_telemetry/allocations/mod.rs +++ b/src/internal_telemetry/allocations/mod.rs @@ -21,12 +21,17 @@ pub(crate) use self::allocator::{ }; const NUM_GROUPS: usize = 128; + // Allocations are not tracked during startup. // We use the Relaxed ordering for both stores and loads of this atomic as no other threads exist when // this code is running, and all future threads will have a happens-after relationship with // this thread -- the main thread -- ensuring that they see the latest value of TRACK_ALLOCATIONS. pub static TRACK_ALLOCATIONS: AtomicBool = AtomicBool::new(false); +pub fn is_allocation_tracing_enabled() -> bool { + TRACK_ALLOCATIONS.load(Ordering::Acquire) +} + /// Track allocations and deallocations separately. struct GroupMemStatsStorage { allocations: [AtomicU64; NUM_GROUPS], @@ -207,6 +212,6 @@ pub fn acquire_allocation_group_id( // TODO: Technically, `NUM_GROUPS` is lower (128) than the upper bound for the // `AllocationGroupId::register` call itself (253), so we can hardcode `NUM_GROUPS` here knowing // it's the lower of the two values and will trigger first.. but this may not always be true. - info!("Maximum number of registrable allocation group IDs reached ({}). Allocations for component '{}' will be attributed to the root allocation group.", NUM_GROUPS, component_id); + warn!("Maximum number of registrable allocation group IDs reached ({}). Allocations for component '{}' will be attributed to the root allocation group.", NUM_GROUPS, component_id); AllocationGroupId::ROOT } diff --git a/src/topology/running.rs b/src/topology/running.rs index 78cf93bab28d4..bb300dd7e5652 100644 --- a/src/topology/running.rs +++ b/src/topology/running.rs @@ -839,7 +839,7 @@ impl RunningTopology { let task_span = span.or_current(); #[cfg(feature = "allocation-tracing")] - { + if crate::internal_telemetry::allocations::is_allocation_tracing_enabled() { let group_id = crate::internal_telemetry::allocations::acquire_allocation_group_id( task.id().to_string(), "sink".to_string(), @@ -882,7 +882,7 @@ impl RunningTopology { let task_span = span.or_current(); #[cfg(feature = "allocation-tracing")] - { + if crate::internal_telemetry::allocations::is_allocation_tracing_enabled() { let group_id = crate::internal_telemetry::allocations::acquire_allocation_group_id( task.id().to_string(), "transform".to_string(), @@ -925,7 +925,7 @@ impl RunningTopology { let task_span = span.or_current(); #[cfg(feature = "allocation-tracing")] - { + if crate::internal_telemetry::allocations::is_allocation_tracing_enabled() { let group_id = crate::internal_telemetry::allocations::acquire_allocation_group_id( task.id().to_string(), "source".to_string(),