diff --git a/profiling/src/profiling/mod.rs b/profiling/src/profiling/mod.rs index bf0ab395b6..f214ed2561 100644 --- a/profiling/src/profiling/mod.rs +++ b/profiling/src/profiling/mod.rs @@ -346,6 +346,12 @@ impl TimeCollector { profiles: &mut HashMap, started_at: &WallTime, ) { + if message.key.sample_types.len() == 0 { + // profiling disabled, this should not happen! + warn!("A sample with no sample types was recorded in the profiler. Please report this to Datadog."); + return; + } + let profile: &mut InternalProfile = if let Some(value) = profiles.get_mut(&message.key) { value } else { @@ -1034,6 +1040,7 @@ impl Profiler { let mut sample_types = Vec::with_capacity(SAMPLE_TYPES.len()); let mut sample_values = Vec::with_capacity(SAMPLE_TYPES.len()); + if locals.profiling_enabled { // sample, wall-time, cpu-time let len = 2 + locals.profiling_experimental_cpu_time_enabled as usize;