首页 > 解决方案 > Application Insights 跳过事件

问题描述

我正在使用此代码将事件发送到控制台应用程序中的应用程序洞察力

        TelemetryConfiguration.Active.InstrumentationKey = "XXXXXXXXX";

        TelemetryClient telemetryClient = new TelemetryClient(); 

        for (int i = 0; i < 100; i++)
        {

            telemetryClient.TrackEvent("Hello World!");

            telemetryClient.TrackException(new OutOfMemoryException());
        }

        telemetryClient.Flush();
        Task.Delay(60000).Wait();

现在我遇到的问题是它似乎没有记录我所有的事件,有时 Visual Studio 工具栏显示 44 ,有时它是 68 而从来没有 100 。

我要发送的信息类型很重要,因为我将从该服务监视多个控制台应用程序。

有没有办法让应用程序洞察力将所有内容发送到天蓝色而不是跳过事件?我想我给了它足够的时间在退出之前发送所有东西。

标签: azureazure-application-insights

解决方案


没有完整的代码,很难说使用的配置。要寻找的几件事:

  1. 您是否启用了采样?如果您真的想要准确的事件计数,请禁用采样 ( https://docs.microsoft.com/en-us/azure/azure-monitor/app/sampling )
  2. 您是否明确配置了频道?如果不是,则默认为 InMemoryChannel,它不会对暂时性问题进行任何重试。最好使用 ServerTelemetryChannel,以保护网络问题或应用程序洞察后端瞬态问题中的数据丢失。
var config = new TelemetryConfiguration(); // or active or create default...
var channel = new ServerTelemetryChannel();
channel.initialize(config)

// create client from the config.
TelemetryClient tc= new TelemetryClient(config);


推荐阅读