Skip to content

Commit 520ebeb

Browse files
committed
fix for CPU simulation ID
1 parent 1b606b6 commit 520ebeb

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/PerfProblemSimulator/Services/CpuStressService.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,11 @@ private void ExecuteCpuStress(Guid simulationId, int durationSeconds, string lev
212212
// Set simulation context for Application Insights telemetry correlation
213213
using var simulationScope = _simulationContext.SetContext(simulationId, SimulationType.Cpu.ToString());
214214

215+
// IMPORTANT: Brief delay to allow telemetry transmission before CPU saturation.
216+
// Without this, the spin loops start immediately and starve the I/O threads
217+
// that App Insights uses to send telemetry, causing events to be lost.
218+
Thread.Sleep(500);
219+
215220
// Convert level to internal percentage: moderate = 65%, high = 100%
216221
var targetPercentage = level == "moderate" ? 65 : 100;
217222

0 commit comments

Comments
 (0)