Skip to content

Commit 3afda3c

Browse files
authored
fix(core): don't show warning about max allocation groups if tracing not enabled (vectordotdev#18589)
1 parent 0e60001 commit 3afda3c

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

src/internal_telemetry/allocations/mod.rs

+6-1
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,17 @@ pub(crate) use self::allocator::{
2121
};
2222

2323
const NUM_GROUPS: usize = 128;
24+
2425
// Allocations are not tracked during startup.
2526
// We use the Relaxed ordering for both stores and loads of this atomic as no other threads exist when
2627
// this code is running, and all future threads will have a happens-after relationship with
2728
// this thread -- the main thread -- ensuring that they see the latest value of TRACK_ALLOCATIONS.
2829
pub static TRACK_ALLOCATIONS: AtomicBool = AtomicBool::new(false);
2930

31+
pub fn is_allocation_tracing_enabled() -> bool {
32+
TRACK_ALLOCATIONS.load(Ordering::Acquire)
33+
}
34+
3035
/// Track allocations and deallocations separately.
3136
struct GroupMemStatsStorage {
3237
allocations: [AtomicU64; NUM_GROUPS],
@@ -207,6 +212,6 @@ pub fn acquire_allocation_group_id(
207212
// TODO: Technically, `NUM_GROUPS` is lower (128) than the upper bound for the
208213
// `AllocationGroupId::register` call itself (253), so we can hardcode `NUM_GROUPS` here knowing
209214
// it's the lower of the two values and will trigger first.. but this may not always be true.
210-
info!("Maximum number of registrable allocation group IDs reached ({}). Allocations for component '{}' will be attributed to the root allocation group.", NUM_GROUPS, component_id);
215+
warn!("Maximum number of registrable allocation group IDs reached ({}). Allocations for component '{}' will be attributed to the root allocation group.", NUM_GROUPS, component_id);
211216
AllocationGroupId::ROOT
212217
}

src/topology/running.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -839,7 +839,7 @@ impl RunningTopology {
839839

840840
let task_span = span.or_current();
841841
#[cfg(feature = "allocation-tracing")]
842-
{
842+
if crate::internal_telemetry::allocations::is_allocation_tracing_enabled() {
843843
let group_id = crate::internal_telemetry::allocations::acquire_allocation_group_id(
844844
task.id().to_string(),
845845
"sink".to_string(),
@@ -882,7 +882,7 @@ impl RunningTopology {
882882

883883
let task_span = span.or_current();
884884
#[cfg(feature = "allocation-tracing")]
885-
{
885+
if crate::internal_telemetry::allocations::is_allocation_tracing_enabled() {
886886
let group_id = crate::internal_telemetry::allocations::acquire_allocation_group_id(
887887
task.id().to_string(),
888888
"transform".to_string(),
@@ -925,7 +925,7 @@ impl RunningTopology {
925925

926926
let task_span = span.or_current();
927927
#[cfg(feature = "allocation-tracing")]
928-
{
928+
if crate::internal_telemetry::allocations::is_allocation_tracing_enabled() {
929929
let group_id = crate::internal_telemetry::allocations::acquire_allocation_group_id(
930930
task.id().to_string(),
931931
"source".to_string(),

0 commit comments

Comments
 (0)