Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Heartbeat doesn't work for short-running WorkerServices (<30 sec) - FlushAsync won't sent the heartbeat #2759

Open
304NotModified opened this issue Apr 3, 2023 · 4 comments · May be fixed by #2762
Labels

Comments

@304NotModified
Copy link

304NotModified commented Apr 3, 2023

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

  1. Create a console application that writes to the application insight traces
  2. Using this configuration:
         services.ConfigureTelemetryModule<DiagnosticsTelemetryModule>((module, _) =>
         {
             module.HeartbeatInterval = TimeSpan.FromSeconds(30);
             module.IsHeartbeatEnabled = true;
         });
         services.AddApplicationInsightsTelemetry(config);
  3. 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!)

Related: #1689, #407

@304NotModified 304NotModified changed the title Heartbeat doens't work for short runnings WorkerServices (<30 sec) - FlushAsync doesn't sent heartbeats Heartbeat doens't work for short-running WorkerServices (<30 sec) - FlushAsync doesn't sent heartbeats Apr 3, 2023
@304NotModified 304NotModified changed the title Heartbeat doens't work for short-running WorkerServices (<30 sec) - FlushAsync doesn't sent heartbeats Heartbeat doens't work for short-running WorkerServices (<30 sec) - FlushAsync won't sent the heartbeat Apr 3, 2023
@304NotModified 304NotModified linked a pull request Apr 6, 2023 that will close this issue
2 tasks
Copy link

This issue is stale because it has been open 300 days with no activity. Remove stale label or this will be closed in 7 days. Commenting will instruct the bot to automatically remove the label.

@github-actions github-actions bot added the stale label Jan 29, 2024
@304NotModified
Copy link
Author

Yes indeed, im still waiting for a response...

@github-actions github-actions bot removed the stale label Jan 31, 2024
@304NotModified
Copy link
Author

A fix is here: #2762

@304NotModified
Copy link
Author

304NotModified commented Feb 22, 2024

@TimothyMothra could you please help me in getting a reaction/get the fix (#2762) merged?

@304NotModified 304NotModified changed the title Heartbeat doens't work for short-running WorkerServices (<30 sec) - FlushAsync won't sent the heartbeat Heartbeat doesn't work for short-running WorkerServices (<30 sec) - FlushAsync won't sent the heartbeat Feb 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant