Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Flush() in Azure App Insights

For Flush() method in Azure App Insights, I was wondering if it impacts the performance of the project?

I tried to remove Flush() and all the custom data are still sent to App Insights.So my question should be why do we need the Flush()? Can we remove it?

like image 687
superninja Avatar asked Aug 21 '18 18:08

superninja


1 Answers

Flush() on TelemetryClient pushes all the data it currently has in a buffer to the App Insights service. You can see its source code here: https://github.com/Microsoft/ApplicationInsights-dotnet/blob/3115fe1cc866a15d09e9b5f1f7f596385406433d/src/Microsoft.ApplicationInsights/TelemetryClient.cs#L593.

Normally, Application Insights will send your data in batches in the background so it uses the network more efficiently. If you have developer mode enabled or call Flush() manually, data is sent immediately.

Typically you do not need to call Flush(). But in a case where you know the process will exit after that point, you'll want to call Flush() to make sure all the data is sent.

like image 121
juunas Avatar answered Sep 22 '22 14:09

juunas