Application Insights跳过事件

问题描述 投票:0回答:1

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

        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();

现在我遇到的问题是它似乎没有记录我的所有事件,有时视觉工作室工具栏显示44,有时它是68而不是100。

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

是否有任何方法可以让应用程序见解将所有内容发送到azure而不是跳过事件?我想我给它足够的时间在退出之前发送所有东西。

azure azure-application-insights
1个回答
1
投票

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

  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);

© www.soinside.com 2019 - 2024. All rights reserved.