Open
Description
- Microsoft.ApplicationInsights.WorkerService 2.21
- .NET 6
- AKS - Linux
Describe the bug
It seams that the heartbeat isn't working for applications that run shorter than 30 seconds, even when FlushAsync is called.
To Reproduce
- Create a console application that writes to the application insight traces
- Using this configuration:
services.ConfigureTelemetryModule<DiagnosticsTelemetryModule>((module, _) => { module.HeartbeatInterval = TimeSpan.FromSeconds(30); module.IsHeartbeatEnabled = true; }); services.AddApplicationInsightsTelemetry(config);
- Flush for 30 seconds. In the
finally
await _myTelemetryClient.FlushAsync(CancellationToken.None); await Task.Delay(TimeSpan.FromSeconds(30));
Sometimes it's too late.
The traces are sent really earlier (29 sec)
I tried lowering the HeartbeatInterval, but 30 seconds is the lowest possible value?
So the FlushAsync doesn't seem to send the heartbeat, that's the bug.
Is there a way to send the heartbeat manually?
Work around: await Task.Delay(TimeSpan.FromSeconds(45));
- we don't really like this. The job needs 5 seconds, and now 50 (10 times!)