Basil Fuchs
Basil Fuchs

Reputation: 1

ApplicationInsights not sending all Events to Azure

I'm trying to send Events from a simple console application to azure, the Events show up in the ApplicationInsights search in VisualStudio but around the first half won't show up in portal.azure.com.

        static void Main(string[] args)
    {
        TelemetryClient telemetry = new TelemetryClient();
        telemetry.InstrumentationKey = 
        telemetry.Context.User.Id = Environment.UserName;
        System.Threading.Thread.Sleep(3000);
        for (int i = 0; i < 100; i++)
        {

            var eve = new EventTelemetry();
            eve.Name = "Test4";
            eve.Metrics["SomeMetric"] = i;
            eve.Properties["SomeProperty"] = i.ToString();
            telemetry.TrackEvent(eve);
            telemetry.Flush();
            System.Threading.Thread.Sleep(300);
        }
     }

Upvotes: 0

Views: 128

Answers (1)

cijothomas
cijothomas

Reputation: 3126

Have you waited few minutes for events to show up in the portal? They typically arrive in under 5 mins, but could be delayed.

Also since you haven't configured channel, the default InMemoryChannel will be used - it won't retry sending events to backend if some temp error occurs. ServerTelemetryChannel does retry etc. Can you try with ServerTelemetryChannel.

var serverTelemetryChannel = new ServerTelemetryChannel();
serverTelemetryChannel.Initialize(TelemetryConfiguration.Active);
TelemetryConfiguration.Active.TelemetryChannel = serverTelemetryChannel;

You can just do a Flush and sleep outside the for loop, no need to flush in every iteration.

Upvotes: 1

Related Questions