azure - 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 。
我要发送的信息类型很重要,因为我将从该服务监视多个控制台应用程序。
有没有办法让应用程序洞察力将所有内容发送到天蓝色而不是跳过事件?我想我给了它足够的时间在退出之前发送所有东西。
解决方案
没有完整的代码,很难说使用的配置。要寻找的几件事:
- 您是否启用了采样?如果您真的想要准确的事件计数,请禁用采样 ( https://docs.microsoft.com/en-us/azure/azure-monitor/app/sampling )
- 您是否明确配置了频道?如果不是,则默认为 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);
推荐阅读
- javascript - 发送邮件后php成功消息不起作用
- android - 是否可以创建一个应用程序,当您在 Instagram 等社交媒体应用程序中发送短信时触发事件?
- python - 合并具有唯一 ID 计数的列上的数据框
- javascript - 反应钩子。同时从多个孩子更新父状态
- oracle - 为什么 FGA Oracle 会捕获错误?
- flutter - 当光标在其上方时,在 BottomNavigationBarItem 上方正方形(颤动网络)
- javascript - 设备出现少量丢包后,约 30 秒内未发送或接收 WebSocket 消息
- node.js - 切换 NodeJS 模块依赖
- aws-api-gateway - AWS WebSocket API 网关必须对 $connect、$disconnect 和 $default 具有相同的集成?
- javascript - 防止 SweetAlert2 从 willClose 中关闭/解除?