TelemetryClient does not send any data unless Flush is called

I use TelemetryClient (v0.17.0.576) directly in my code, and it looks like I can only transmit Azure data when I manually call Flush at the end, which feels wrong. Did I miss something?

var configuration = TelemetryConfiguration.CreateDefault(); configuration.InstrumentationKey = "KEY"; var client = new TelemetryClient(configuration); for (int i = 0; i < 10; i++) { log.Information("Loop: {0} {1}", i, value); client.Track(new TraceTelemetry(value)); } client.Flush(); 
+5
azure azure-application-insights
source share
2 answers

For performance reasons, the Insights application SDK selects telemetry and sends it to pieces. To see this in action, you can replace the Flush call with the Thread.Sleep (70000) call, and you will see that the toolkit is loaded into the AI ​​after the application terminates.

+7
source share

Adding the answer to Mario Hewardt. If you use a save channel:

 TelemetryConfiguration.Active.TelemetryChannel = new PersistenceChannel(); 

Flush() is synchronous (so you don't need to sleep a thread for its absolute length). It also has the advantage of storing telemetry data in a local file if the Insights application cannot be linked, which will then be sent the next time Flush() is called with a good connection.

0
source share

All Articles